-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add integration tests for jaxb-resteasy-reactive
- Loading branch information
Showing
5 changed files
with
163 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>quarkus-integration-tests-parent</artifactId> | ||
<groupId>io.quarkus</groupId> | ||
<version>999-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>quarkus-integration-test-jaxb-resteasy-reactive</artifactId> | ||
<name>Quarkus - Integration Tests - JAXB - Resteasy Reactive</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-rest-jaxb</artifactId> | ||
</dependency> | ||
|
||
<!-- test dependencies --> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-junit5</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.rest-assured</groupId> | ||
<artifactId>rest-assured</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<!-- Minimal test dependencies to *-deployment artifacts for consistent build order --> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-resteasy-deployment</artifactId> | ||
<version>${project.version}</version> | ||
<type>pom</type> | ||
<scope>test</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>*</groupId> | ||
<artifactId>*</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-resteasy-jaxb-deployment</artifactId> | ||
<version>${project.version}</version> | ||
<type>pom</type> | ||
<scope>test</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>*</groupId> | ||
<artifactId>*</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-maven-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>build</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
|
||
</project> |
18 changes: 18 additions & 0 deletions
18
integration-tests/jaxb-resteasy-reactive/src/main/java/io/quarkus/it/reactive/jaxb/Book.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...-tests/jaxb-resteasy-reactive/src/main/java/io/quarkus/it/reactive/jaxb/JaxbResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
|
||
} |
43 changes: 43 additions & 0 deletions
43
...tion-tests/jaxb-resteasy-reactive/src/test/java/io/quarkus/it/reactive/jaxb/JaxbTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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( | ||
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><book><title>1984</title></book>")); | ||
} | ||
|
||
@Test | ||
public void testInvalidXmlInRequestBody() { | ||
String invalidXml = """ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<book> | ||
<title>1984</title> | ||
</boo> | ||
"""; | ||
given().when() | ||
.contentType(ContentType.XML) | ||
.body(invalidXml) | ||
.post("/jaxb/book") | ||
.then() | ||
.statusCode(400); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters