This is an automated email from the ASF dual-hosted git repository. jamesnetherton pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/main by this push: new 9157c3e Move RestBindingMode XML tests to rest itest module 9157c3e is described below commit 9157c3e5ef56878d1748e3ee84f60eba54d4769b Author: James Netherton <jamesnether...@gmail.com> AuthorDate: Fri May 7 11:55:17 2021 +0100 Move RestBindingMode XML tests to rest itest module --- integration-tests/pom.xml | 1 - integration-tests/rest-binding-mode-xml/pom.xml | 136 --------------------- .../component/rest/it/RestBindingModeXmlRoute.java | 32 ----- .../quarkus/component/rest/it/UserJaxbPojo.java | 51 -------- .../component/rest/it/RestBindingModeXmlIT.java | 23 ---- .../component/rest/it/RestBindingModeXmlTest.java | 36 ------ integration-tests/rest/pom.xml | 34 ++++++ .../camel/quarkus/component/rest/it/Person.java | 12 ++ .../quarkus/component/rest/it/RestRoutes.java | 11 +- .../camel/quarkus/component/rest/it/RestTest.java | 24 +++- tooling/scripts/test-categories.yaml | 1 - 11 files changed, 79 insertions(+), 282 deletions(-) diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index 4afb05f..d3f1dec 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -179,7 +179,6 @@ <module>rabbitmq</module> <module>reactive-streams</module> <module>rest</module> - <module>rest-binding-mode-xml</module> <module>rest-openapi</module> <module>saga</module> <module>salesforce</module> diff --git a/integration-tests/rest-binding-mode-xml/pom.xml b/integration-tests/rest-binding-mode-xml/pom.xml deleted file mode 100644 index 077e38a..0000000 --- a/integration-tests/rest-binding-mode-xml/pom.xml +++ /dev/null @@ -1,136 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ---> -<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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-integration-tests</artifactId> - <version>1.9.0-SNAPSHOT</version> - </parent> - - <artifactId>camel-quarkus-integration-test-rest-binding-mode-xml</artifactId> - <name>Camel Quarkus :: Integration Tests :: Rest :: Binding Mode XML</name> - <description>Integration tests for Camel Quarkus Rest extension with XML binding mode</description> - - <dependencies> - <dependency> - <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-rest</artifactId> - </dependency> - <dependency> - <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-xml-jaxb</artifactId> - </dependency> - <dependency> - <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-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> - <dependency> - <groupId>org.assertj</groupId> - <artifactId>assertj-core</artifactId> - <scope>test</scope> - </dependency> - - <!-- The following dependencies guarantee that this module is built after them. You can update them by running `mvn process-resources -Pformat -N` from the source tree root directory --> - <dependency> - <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-jaxb-deployment</artifactId> - <version>${project.version}</version> - <type>pom</type> - <scope>test</scope> - <exclusions> - <exclusion> - <groupId>*</groupId> - <artifactId>*</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-rest-deployment</artifactId> - <version>${project.version}</version> - <type>pom</type> - <scope>test</scope> - <exclusions> - <exclusion> - <groupId>*</groupId> - <artifactId>*</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-xml-jaxb-deployment</artifactId> - <version>${project.version}</version> - <type>pom</type> - <scope>test</scope> - <exclusions> - <exclusion> - <groupId>*</groupId> - <artifactId>*</artifactId> - </exclusion> - </exclusions> - </dependency> - </dependencies> - - - <profiles> - <profile> - <id>native</id> - <activation> - <property> - <name>native</name> - </property> - </activation> - <properties> - <quarkus.package.type>native</quarkus.package.type> - </properties> - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-failsafe-plugin</artifactId> - <executions> - <execution> - <goals> - <goal>integration-test</goal> - <goal>verify</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - </profile> - </profiles> - -</project> diff --git a/integration-tests/rest-binding-mode-xml/src/main/java/org/apache/camel/quarkus/component/rest/it/RestBindingModeXmlRoute.java b/integration-tests/rest-binding-mode-xml/src/main/java/org/apache/camel/quarkus/component/rest/it/RestBindingModeXmlRoute.java deleted file mode 100644 index 84b63f9..0000000 --- a/integration-tests/rest-binding-mode-xml/src/main/java/org/apache/camel/quarkus/component/rest/it/RestBindingModeXmlRoute.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.quarkus.component.rest.it; - -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.model.rest.RestBindingMode; - -public class RestBindingModeXmlRoute extends RouteBuilder { - @Override - public void configure() { - rest() - .post("/platform-http/nameOf") - .bindingMode(RestBindingMode.xml) - .type(UserJaxbPojo.class) - .route() - .transform().body(UserJaxbPojo.class, UserJaxbPojo::getName); - } -} diff --git a/integration-tests/rest-binding-mode-xml/src/main/java/org/apache/camel/quarkus/component/rest/it/UserJaxbPojo.java b/integration-tests/rest-binding-mode-xml/src/main/java/org/apache/camel/quarkus/component/rest/it/UserJaxbPojo.java deleted file mode 100644 index 4070b6f..0000000 --- a/integration-tests/rest-binding-mode-xml/src/main/java/org/apache/camel/quarkus/component/rest/it/UserJaxbPojo.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.quarkus.component.rest.it; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlRootElement; - -import io.quarkus.runtime.annotations.RegisterForReflection; - -@RegisterForReflection -@XmlRootElement(name = "user") -@XmlAccessorType(XmlAccessType.FIELD) -public class UserJaxbPojo { - - @XmlAttribute - private int id; - @XmlAttribute - private String name; - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -} diff --git a/integration-tests/rest-binding-mode-xml/src/test/java/org/apache/camel/quarkus/component/rest/it/RestBindingModeXmlIT.java b/integration-tests/rest-binding-mode-xml/src/test/java/org/apache/camel/quarkus/component/rest/it/RestBindingModeXmlIT.java deleted file mode 100644 index 0cb43a1..0000000 --- a/integration-tests/rest-binding-mode-xml/src/test/java/org/apache/camel/quarkus/component/rest/it/RestBindingModeXmlIT.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.quarkus.component.rest.it; - -import io.quarkus.test.junit.NativeImageTest; - -@NativeImageTest -class RestBindingModeXmlIT extends RestBindingModeXmlTest { -} diff --git a/integration-tests/rest-binding-mode-xml/src/test/java/org/apache/camel/quarkus/component/rest/it/RestBindingModeXmlTest.java b/integration-tests/rest-binding-mode-xml/src/test/java/org/apache/camel/quarkus/component/rest/it/RestBindingModeXmlTest.java deleted file mode 100644 index b3b2892..0000000 --- a/integration-tests/rest-binding-mode-xml/src/test/java/org/apache/camel/quarkus/component/rest/it/RestBindingModeXmlTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.quarkus.component.rest.it; - -import io.quarkus.test.junit.QuarkusTest; -import io.restassured.RestAssured; -import org.junit.jupiter.api.Test; - -import static org.hamcrest.Matchers.is; - -@QuarkusTest -class RestBindingModeXmlTest { - @Test - public void extractNameFromXml() { - RestAssured.given() - .body("<user name=\"Donald Duck\" id=\"123\"></user>") - .post("/platform-http/nameOf") - .then() - .statusCode(200) - .body(is("Donald Duck")); - } -} diff --git a/integration-tests/rest/pom.xml b/integration-tests/rest/pom.xml index 9c52dcb..cfca332 100644 --- a/integration-tests/rest/pom.xml +++ b/integration-tests/rest/pom.xml @@ -44,9 +44,17 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-jaxb</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-rest</artifactId> </dependency> <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-xml-jaxb</artifactId> + </dependency> + <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-resteasy-jsonb</artifactId> </dependency> @@ -105,6 +113,19 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-jaxb-deployment</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>*</groupId> + <artifactId>*</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-rest-deployment</artifactId> <version>${project.version}</version> <type>pom</type> @@ -116,6 +137,19 @@ </exclusion> </exclusions> </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-xml-jaxb-deployment</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>*</groupId> + <artifactId>*</artifactId> + </exclusion> + </exclusions> + </dependency> </dependencies> diff --git a/integration-tests/rest/src/main/java/org/apache/camel/quarkus/component/rest/it/Person.java b/integration-tests/rest/src/main/java/org/apache/camel/quarkus/component/rest/it/Person.java index 7fa4ee4..563feed 100644 --- a/integration-tests/rest/src/main/java/org/apache/camel/quarkus/component/rest/it/Person.java +++ b/integration-tests/rest/src/main/java/org/apache/camel/quarkus/component/rest/it/Person.java @@ -18,13 +18,25 @@ package org.apache.camel.quarkus.component.rest.it; import java.util.Objects; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlRootElement; + import io.quarkus.runtime.annotations.RegisterForReflection; @RegisterForReflection(fields = false) +@XmlRootElement(name = "person") +@XmlAccessorType(XmlAccessType.FIELD) public class Person { + @XmlAttribute private String firstName; + + @XmlAttribute private String lastName; + + @XmlAttribute private int age; public String getFirstName() { diff --git a/integration-tests/rest/src/main/java/org/apache/camel/quarkus/component/rest/it/RestRoutes.java b/integration-tests/rest/src/main/java/org/apache/camel/quarkus/component/rest/it/RestRoutes.java index 4825053..22c4c25 100644 --- a/integration-tests/rest/src/main/java/org/apache/camel/quarkus/component/rest/it/RestRoutes.java +++ b/integration-tests/rest/src/main/java/org/apache/camel/quarkus/component/rest/it/RestRoutes.java @@ -60,13 +60,22 @@ public class RestRoutes extends RouteBuilder { .setBody(simple("${header.messageStart} ${header.messageEnd}")) .endRest() - .post("/pojo/binding") + .post("/pojo/binding/json") .bindingMode(RestBindingMode.json) .type(Person.class) .produces(MediaType.TEXT_PLAIN) .route() .setBody(simple("Name: ${body.firstName} ${body.lastName}, Age: ${body.age}")) .setHeader(Exchange.CONTENT_TYPE, constant("text/plain")) + .endRest() + + .post("/pojo/binding/xml") + .bindingMode(RestBindingMode.xml) + .type(Person.class) + .produces(MediaType.TEXT_PLAIN) + .route() + .setBody(simple("Name: ${body.firstName} ${body.lastName}, Age: ${body.age}")) + .setHeader(Exchange.CONTENT_TYPE, constant("text/plain")) .endRest(); } } diff --git a/integration-tests/rest/src/test/java/org/apache/camel/quarkus/component/rest/it/RestTest.java b/integration-tests/rest/src/test/java/org/apache/camel/quarkus/component/rest/it/RestTest.java index 9bdd587..21be9cc 100644 --- a/integration-tests/rest/src/test/java/org/apache/camel/quarkus/component/rest/it/RestTest.java +++ b/integration-tests/rest/src/test/java/org/apache/camel/quarkus/component/rest/it/RestTest.java @@ -119,7 +119,29 @@ class RestTest { RestAssured.given() .contentType(ContentType.JSON) .body(person) - .post("/rest/pojo/binding") + .post("/rest/pojo/binding/json") + .then() + .statusCode(200) + .body(equalTo(result)); + } + + @Test + public void xmlBinding() { + Person person = new Person(); + person.setFirstName("John"); + person.setLastName("Doe"); + person.setAge(64); + + String result = String.format( + "Name: %s %s, Age: %d", + person.getFirstName(), + person.getLastName(), + person.getAge()); + + RestAssured.given() + .contentType(ContentType.XML) + .body(person) + .post("/rest/pojo/binding/xml") .then() .statusCode(200) .body(equalTo(result)); diff --git a/tooling/scripts/test-categories.yaml b/tooling/scripts/test-categories.yaml index 49099ca..f618fab 100644 --- a/tooling/scripts/test-categories.yaml +++ b/tooling/scripts/test-categories.yaml @@ -110,7 +110,6 @@ group-07: - olingo4 - optaplanner - pg-replication-slot - - rest-binding-mode-xml - stax - weather group-08: