From 359a8abdc32f66cbc2ca54289208089c9494a7c5 Mon Sep 17 00:00:00 2001 From: Sauli Ketola Date: Sat, 16 Mar 2024 10:13:43 +0200 Subject: [PATCH] Add integration tests for jaxb-resteasy-reactive --- .../jaxb-resteasy-reactive/pom.xml | 79 +++++++++++++++++++ .../io/quarkus/it/reactive/jaxb/Book.java | 18 +++++ .../it/reactive/jaxb/JaxbResource.java | 22 ++++++ .../io/quarkus/it/reactive/jaxb/JaxbTest.java | 43 ++++++++++ integration-tests/pom.xml | 1 + 5 files changed, 163 insertions(+) create mode 100644 integration-tests/jaxb-resteasy-reactive/pom.xml create mode 100644 integration-tests/jaxb-resteasy-reactive/src/main/java/io/quarkus/it/reactive/jaxb/Book.java create mode 100644 integration-tests/jaxb-resteasy-reactive/src/main/java/io/quarkus/it/reactive/jaxb/JaxbResource.java create mode 100644 integration-tests/jaxb-resteasy-reactive/src/test/java/io/quarkus/it/reactive/jaxb/JaxbTest.java diff --git a/integration-tests/jaxb-resteasy-reactive/pom.xml b/integration-tests/jaxb-resteasy-reactive/pom.xml new file mode 100644 index 00000000000000..4e89a8bea06a5e --- /dev/null +++ b/integration-tests/jaxb-resteasy-reactive/pom.xml @@ -0,0 +1,79 @@ + + + + quarkus-integration-tests-parent + io.quarkus + 999-SNAPSHOT + + 4.0.0 + + quarkus-integration-test-jaxb-resteasy-reactive + Quarkus - Integration Tests - JAXB - Resteasy Reactive + + + + io.quarkus + quarkus-rest-jaxb + + + + + io.quarkus + quarkus-junit5 + test + + + io.rest-assured + rest-assured + test + + + + + io.quarkus + quarkus-resteasy-deployment + ${project.version} + pom + test + + + * + * + + + + + io.quarkus + quarkus-resteasy-jaxb-deployment + ${project.version} + pom + test + + + * + * + + + + + + + + + io.quarkus + quarkus-maven-plugin + + + + build + + + + + + + + + diff --git a/integration-tests/jaxb-resteasy-reactive/src/main/java/io/quarkus/it/reactive/jaxb/Book.java b/integration-tests/jaxb-resteasy-reactive/src/main/java/io/quarkus/it/reactive/jaxb/Book.java new file mode 100644 index 00000000000000..a6fba70ceb36c0 --- /dev/null +++ b/integration-tests/jaxb-resteasy-reactive/src/main/java/io/quarkus/it/reactive/jaxb/Book.java @@ -0,0 +1,18 @@ +package io.quarkus.it.reactive.jaxb; + +import jakarta.xml.bind.annotation.XmlElement; +import jakarta.xml.bind.annotation.XmlRootElement; + +@XmlRootElement +public class Book { + + @XmlElement + private String title; + + public Book() { + } + + public Book(String title) { + this.title = title; + } +} diff --git a/integration-tests/jaxb-resteasy-reactive/src/main/java/io/quarkus/it/reactive/jaxb/JaxbResource.java b/integration-tests/jaxb-resteasy-reactive/src/main/java/io/quarkus/it/reactive/jaxb/JaxbResource.java new file mode 100644 index 00000000000000..23f5cc7c710766 --- /dev/null +++ b/integration-tests/jaxb-resteasy-reactive/src/main/java/io/quarkus/it/reactive/jaxb/JaxbResource.java @@ -0,0 +1,22 @@ +package io.quarkus.it.reactive.jaxb; + +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; + +@Path("/jaxb") +@ApplicationScoped +public class JaxbResource { + + @Path("/book") + @POST + @Consumes(MediaType.APPLICATION_XML) + @Produces(MediaType.APPLICATION_XML) + public Book postBookXml(Book book) { + return book; + } + +} diff --git a/integration-tests/jaxb-resteasy-reactive/src/test/java/io/quarkus/it/reactive/jaxb/JaxbTest.java b/integration-tests/jaxb-resteasy-reactive/src/test/java/io/quarkus/it/reactive/jaxb/JaxbTest.java new file mode 100644 index 00000000000000..b9fc694f4b883f --- /dev/null +++ b/integration-tests/jaxb-resteasy-reactive/src/test/java/io/quarkus/it/reactive/jaxb/JaxbTest.java @@ -0,0 +1,43 @@ +package io.quarkus.it.reactive.jaxb; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.Matchers.is; + +import org.junit.jupiter.api.Test; + +import io.quarkus.test.junit.QuarkusTest; +import io.restassured.http.ContentType; + +@QuarkusTest +public class JaxbTest { + @Test + public void testMarshallingAndUnmarshalling() { + given().when() + .contentType(ContentType.XML) + .body(new Book("1984")) + .post("/jaxb/book") + .then() + .statusCode(200) + .contentType(ContentType.XML) + .log().ifValidationFails() + .body(is( + "1984")); + } + + @Test + public void testInvalidXmlInRequestBody() { + String invalidXml = """ + + + 1984 + + """; + given().when() + .contentType(ContentType.XML) + .body(invalidXml) + .post("/jaxb/book") + .then() + .statusCode(400); + } + +} diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index bd23f41c363e28..112f837aa7d961 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -358,6 +358,7 @@ opentelemetry-reactive-messaging logging-json jaxb + jaxb-resteasy-reactive jaxp mailer native-config-profile