Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RESTEASY-3225] Minor follow-ups from review. #3294

Merged
merged 1 commit into from
Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
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();
}
}
}
Original file line number Diff line number Diff line change
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