diff --git a/integration-tests/vertx/src/main/java/org/apache/camel/quarkus/component/vertx/it/VertxResource.java b/integration-tests/vertx/src/main/java/org/apache/camel/quarkus/component/vertx/it/VertxResource.java index 4045ef31d1b5..f01aeb76c482 100644 --- a/integration-tests/vertx/src/main/java/org/apache/camel/quarkus/component/vertx/it/VertxResource.java +++ b/integration-tests/vertx/src/main/java/org/apache/camel/quarkus/component/vertx/it/VertxResource.java @@ -21,11 +21,14 @@ import javax.inject.Inject; import javax.ws.rs.Consumes; import javax.ws.rs.GET; +import javax.ws.rs.NotFoundException; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import javax.ws.rs.ext.ExceptionMapper; +import javax.ws.rs.ext.Provider; import io.vertx.core.Vertx; import org.apache.camel.CamelContext; @@ -60,4 +63,31 @@ public boolean quarkusVertxInstanceUsedInVertxComponent() { VertxComponent component = camelContext.getComponent("vertx", VertxComponent.class); return component.getVertx() == vertx; } + + @Path("/exception") + @GET + @Produces("text/html") + public String exception() { + throw new RuntimeException("My runtime exception"); + } + + @Provider + public static class CustomNotFoundExceptionMapper implements ExceptionMapper { + @Override + public Response toResponse(NotFoundException exception) { + return Response.status(404) + .entity("Custom Not Found exception") + .build(); + } + } + + @Provider + public static class CustomWebApplicationExceptionMapper implements ExceptionMapper { + @Override + public Response toResponse(Exception exception) { + return Response.status(400) + .entity("Custom exception") + .build(); + } + } } diff --git a/integration-tests/vertx/src/test/java/org/apache/camel/quarkus/component/vertx/it/VertxTest.java b/integration-tests/vertx/src/test/java/org/apache/camel/quarkus/component/vertx/it/VertxTest.java index 3e26e12e3b73..ac81d598ff35 100644 --- a/integration-tests/vertx/src/test/java/org/apache/camel/quarkus/component/vertx/it/VertxTest.java +++ b/integration-tests/vertx/src/test/java/org/apache/camel/quarkus/component/vertx/it/VertxTest.java @@ -21,6 +21,7 @@ import io.restassured.http.ContentType; import org.junit.jupiter.api.Test; +import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.is; @QuarkusTest @@ -45,4 +46,22 @@ public void testVertxComponent() { .statusCode(201) .body(is("Hello " + message)); } + + @Test + public void testDefaultExceptionMapper() { + RestAssured.given().accept("text/html") + .get("/vertx/exception") + .then() + .statusCode(400) + .body(containsString("Custom exception")); + } + + @Test + public void testNotFoundExceptionMapper() { + RestAssured.given().accept("text/html") + .get("/vertx/exception2") + .then() + .statusCode(404) + .body(containsString("Custom Not Found exception")); + } }