Skip to content

Commit

Permalink
[RESTEASY-3225] Minor follow-ups from review.
Browse files Browse the repository at this point in the history
https://issues.redhat.com/browse/RESTEASY-3225
Signed-off-by: James R. Perkins <jperkins@redhat.com>
  • Loading branch information
jamezp committed Oct 6, 2022
1 parent f8e03aa commit 46b8c1d
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 36 deletions.
Expand Up @@ -23,14 +23,10 @@

import jakarta.inject.Inject;
import jakarta.ws.rs.ApplicationPath;
import jakarta.ws.rs.ConstrainedTo;
import jakarta.ws.rs.RuntimeType;
import jakarta.ws.rs.client.Client;
import jakarta.ws.rs.core.Application;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.UriInfo;
import jakarta.ws.rs.ext.ExceptionMapper;
import jakarta.ws.rs.ext.Provider;
import jakarta.ws.rs.ext.Providers;

import org.jboss.arquillian.test.api.ArquillianResource;
Expand Down Expand Up @@ -70,39 +66,8 @@ public void waeException() throws Exception {
Assert.assertEquals(ExceptionResource.WAE_RESPONSE.readEntity(String.class), response.readEntity(String.class));
}


/**
* Tests that a defined exception mapper is used
*
* @throws Exception if an exception occurs
*/
@Test
public void defaultExceptionMapperNotUsed() throws Exception {
final ExceptionMapper<UnsupportedOperationException> mapper = providers.getExceptionMapper(UnsupportedOperationException.class);
Assert.assertTrue("Mapper was not an instance of UnsupportedOperationException: " + mapper, mapper instanceof UnsupportedOperationExceptionMapper);
final Response response = client.target(TestUtil.generateUri(url, "/exception/not-impl"))
.request()
.get();
Assert.assertEquals(Response.Status.NOT_FOUND, response.getStatusInfo());
Assert.assertEquals("Path /exception/not-impl was not found", response.readEntity(String.class));
}

@ApplicationPath("/")
public static class TestApplication extends Application {

}

@Provider
@ConstrainedTo(RuntimeType.SERVER)
public static class UnsupportedOperationExceptionMapper implements ExceptionMapper<UnsupportedOperationException> {
@Inject
private UriInfo uriInfo;

@Override
public Response toResponse(final UnsupportedOperationException exception) {
return Response.status(Response.Status.NOT_FOUND)
.entity(String.format("Path %s was not found", uriInfo.getPath()))
.build();
}
}
}
Expand Up @@ -79,7 +79,6 @@ public static WebArchive createDeployment() {
@Test
public void defaultExceptionMapper() {
final ExceptionMapper<?> mapper = providers.getExceptionMapper(RuntimeException.class);
Assert.assertNotNull("Expected expected our default exception mapper", mapper);
Assert.assertTrue(String.format("Expected mapper %s to be instance of %s.", mapper, ThrowableExceptionMapper.class),
mapper instanceof ThrowableExceptionMapper);
}
Expand Down

0 comments on commit 46b8c1d

Please sign in to comment.