Search in sources :

Example 1 with DefaultOptionsMethodException

use of org.jboss.resteasy.spi.DefaultOptionsMethodException in project resteasy by resteasy.

the class SegmentTest method testDefaultOptions.

/**
 * @tpTestDetails Check default option for segment
 * @tpSince RESTEasy 3.0.16
 */
@Test
public void testDefaultOptions() throws URISyntaxException {
    ResourceMethodRegistry registry = new ResourceMethodRegistry(ResteasyProviderFactory.getInstance());
    registry.addPerRequestResource(SegmentResource.class);
    try {
        ResourceInvoker invoker = registry.getResourceInvoker(MockHttpRequest.options("/resource/sub"));
    } catch (DefaultOptionsMethodException e) {
    }
    try {
        ResourceInvoker invoker = registry.getResourceInvoker(MockHttpRequest.put("/resource/sub"));
    } catch (NotAllowedException e) {
    }
}
Also used : NotAllowedException(jakarta.ws.rs.NotAllowedException) ResourceMethodRegistry(org.jboss.resteasy.core.ResourceMethodRegistry) ResourceInvoker(org.jboss.resteasy.spi.ResourceInvoker) DefaultOptionsMethodException(org.jboss.resteasy.spi.DefaultOptionsMethodException) Test(org.junit.Test)

Example 2 with DefaultOptionsMethodException

use of org.jboss.resteasy.spi.DefaultOptionsMethodException in project candlepin by candlepin.

the class DefaultOptionsMethodExceptionMapperTest method exceptionWithResponse.

@Test
public void exceptionWithResponse() {
    Response mockr = mock(Response.class);
    when(mockr.getStatus()).thenReturn(500);
    DefaultOptionsMethodException dome = new DefaultOptionsMethodException("oops", mockr);
    DefaultOptionsMethodExceptionMapper domem = injector.getInstance(DefaultOptionsMethodExceptionMapper.class);
    Response r = domem.toResponse(dome);
    assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), r.getStatus());
    assertEquals(mockr, r);
    assertEquals("oops", dome.getMessage());
}
Also used : Response(javax.ws.rs.core.Response) DefaultOptionsMethodException(org.jboss.resteasy.spi.DefaultOptionsMethodException) Test(org.junit.Test)

Example 3 with DefaultOptionsMethodException

use of org.jboss.resteasy.spi.DefaultOptionsMethodException in project candlepin by candlepin.

the class DefaultOptionsMethodExceptionMapperTest method verifyResponse.

@Test
public void verifyResponse() {
    DefaultOptionsMethodException dome = new DefaultOptionsMethodException("oops", null);
    DefaultOptionsMethodExceptionMapper domem = injector.getInstance(DefaultOptionsMethodExceptionMapper.class);
    Response r = domem.toResponse(dome);
    assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), r.getStatus());
    verifyMessage(r, rtmsg("oops"));
}
Also used : Response(javax.ws.rs.core.Response) DefaultOptionsMethodException(org.jboss.resteasy.spi.DefaultOptionsMethodException) Test(org.junit.Test)

Example 4 with DefaultOptionsMethodException

use of org.jboss.resteasy.spi.DefaultOptionsMethodException in project candlepin by candlepin.

the class RuntimeExceptionMapperTest method defaultOptionsException.

@Ignore
@Test
public void defaultOptionsException() {
    Response forex = mock(Response.class);
    when(req.getHeader(HttpHeaderNames.ACCEPT)).thenReturn("application/json");
    Response r = rem.toResponse(new DefaultOptionsMethodException("", forex));
    assertEquals(forex, r);
}
Also used : Response(javax.ws.rs.core.Response) DefaultOptionsMethodException(org.jboss.resteasy.spi.DefaultOptionsMethodException) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 5 with DefaultOptionsMethodException

use of org.jboss.resteasy.spi.DefaultOptionsMethodException in project candlepin by candlepin.

the class DefaultOptionsMethodExceptionMapperTest method verifyResponse.

@Test
public void verifyResponse() {
    DefaultOptionsMethodException dome = new DefaultOptionsMethodException("oops", null);
    DefaultOptionsMethodExceptionMapper domem = injector.getInstance(DefaultOptionsMethodExceptionMapper.class);
    Response r = domem.toResponse(dome);
    assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), r.getStatus());
    verifyMessage(r, rtmsg("oops"));
}
Also used : Response(javax.ws.rs.core.Response) DefaultOptionsMethodException(org.jboss.resteasy.spi.DefaultOptionsMethodException) Test(org.junit.jupiter.api.Test)

Aggregations

DefaultOptionsMethodException (org.jboss.resteasy.spi.DefaultOptionsMethodException)8 Response (javax.ws.rs.core.Response)6 Test (org.junit.Test)4 Test (org.junit.jupiter.api.Test)3 NotAllowedException (jakarta.ws.rs.NotAllowedException)2 NotAcceptableException (jakarta.ws.rs.NotAcceptableException)1 NotSupportedException (jakarta.ws.rs.NotSupportedException)1 MediaType (jakarta.ws.rs.core.MediaType)1 Response (jakarta.ws.rs.core.Response)1 ResponseBuilder (jakarta.ws.rs.core.Response.ResponseBuilder)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 ResourceMethodInvoker (org.jboss.resteasy.core.ResourceMethodInvoker)1 ResourceMethodRegistry (org.jboss.resteasy.core.ResourceMethodRegistry)1 ResourceInvoker (org.jboss.resteasy.spi.ResourceInvoker)1 WeightedMediaType (org.jboss.resteasy.util.WeightedMediaType)1 Ignore (org.junit.Ignore)1 Disabled (org.junit.jupiter.api.Disabled)1