From 57476912c5ef7dd8a4d690cd3e67537c2e66a9e5 Mon Sep 17 00:00:00 2001 From: Adam Anderson Date: Tue, 12 Mar 2024 11:49:48 -0500 Subject: [PATCH] Add a Default Exception Mapper test. --- .../webappexception/nomapper/JAXRSClientIT.java | 17 ++++++++++++++++- .../webappexception/nomapper/Resource.java | 6 ++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/jaxrs-tck/src/main/java/ee/jakarta/tck/ws/rs/ee/resource/webappexception/nomapper/JAXRSClientIT.java b/jaxrs-tck/src/main/java/ee/jakarta/tck/ws/rs/ee/resource/webappexception/nomapper/JAXRSClientIT.java index f984281c6..ef9ac03e7 100644 --- a/jaxrs-tck/src/main/java/ee/jakarta/tck/ws/rs/ee/resource/webappexception/nomapper/JAXRSClientIT.java +++ b/jaxrs-tck/src/main/java/ee/jakarta/tck/ws/rs/ee/resource/webappexception/nomapper/JAXRSClientIT.java @@ -30,9 +30,9 @@ import org.junit.jupiter.api.TestInfo; import org.junit.jupiter.api.extension.ExtendWith; -import jakarta.ws.rs.core.Response.Status; import ee.jakarta.tck.ws.rs.common.JAXRSCommonClient; import ee.jakarta.tck.ws.rs.lib.util.TestUtil; +import jakarta.ws.rs.core.Response.Status; /* * @class.setup_props: webServerHost; @@ -296,4 +296,19 @@ public void throwableStatusCodeTest() throws Fault { setProperty(STATUS_CODE, getStatusCode(Status.NO_CONTENT)); invoke(); } + + /* + * @testName: defaultExceptionMapperTest + * + * @assertion_ids: JAXRS:JAVADOC:19; + * + * @test_Strategy: Client invokes GET on root resource at /resource; Verify + * that Throwable is mapped to HTTP 500. + */ + @Test + public void defaultExceptionMapperTest() throws Fault { + setProperty(REQUEST, buildRequest(GET, "DefaultExceptionMapperTest")); + setProperty(STATUS_CODE, getStatusCode(Status.INTERNAL_SERVER_ERROR)); + invoke(); + } } \ No newline at end of file diff --git a/jaxrs-tck/src/main/java/ee/jakarta/tck/ws/rs/ee/resource/webappexception/nomapper/Resource.java b/jaxrs-tck/src/main/java/ee/jakarta/tck/ws/rs/ee/resource/webappexception/nomapper/Resource.java index e714d01c2..14f48d4fc 100644 --- a/jaxrs-tck/src/main/java/ee/jakarta/tck/ws/rs/ee/resource/webappexception/nomapper/Resource.java +++ b/jaxrs-tck/src/main/java/ee/jakarta/tck/ws/rs/ee/resource/webappexception/nomapper/Resource.java @@ -138,6 +138,12 @@ public Response throwableStatusCodeTest() { new Throwable(id("-throwableStatusCodeTest")), 204); } + @GET + @Path("/DefaultExceptionMapperTest") + public Response defaultExceptionMapperTest() throws Throwable { + throw new Throwable(id("-defaultExceptionMapperTest")); + } + public static String id(String suffix) { return new StringBuilder().append(TESTID).append(suffix).toString(); }