This is an automated email from the ASF dual-hosted git repository.
ffang 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 5f94515 #2633 jacksonxml: add test coverage (#2635)
5f94515 is described below
commit 5f945157e4a0dd15d9a3e28e5bd8b1945638480e
Author: Freeman(Yue) Fang <[email protected]>
AuthorDate: Fri May 21 10:29:53 2021 -0400
#2633 jacksonxml: add test coverage (#2635)
* #2633 jacksonxml: add test coverage
* address feedback
---
integration-tests/dataformats-json/pom.xml | 20 +
.../jackson/xml/JacksonXmlResource.java | 595 +++++++++++++++++++++
.../dataformats/jackson/xml/JacksonXmlRoute.java | 130 +++++
.../dataformats/json/JsonDataformatsResource.java | 3 +-
.../component/dataformats/json/model/MyModule.java | 47 ++
.../dataformats/json/model/TestJAXBPojo.java | 53 ++
.../dataformats/json/model/TestOtherPojo.java | 43 ++
.../component/dataformats/json/model/TestPojo.java | 48 ++
.../dataformats/json/model/TestPojoView.java | 87 +++
.../component/dataformats/json/model/Views.java | 31 ++
.../src/main/resources/routes/jackson-routes.xml | 55 +-
.../dataformats/jackson/xml/JacksonXmlIT.java | 24 +
.../dataformats/jackson/xml/JacksonXmlTest.java | 234 ++++++++
.../dataformats/json/JsonComponentsTest.java | 2 +
14 files changed, 1370 insertions(+), 2 deletions(-)
diff --git a/integration-tests/dataformats-json/pom.xml
b/integration-tests/dataformats-json/pom.xml
index 068ff72..ecec71d 100644
--- a/integration-tests/dataformats-json/pom.xml
+++ b/integration-tests/dataformats-json/pom.xml
@@ -70,6 +70,10 @@
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-jacksonxml</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-mock</artifactId>
+ </dependency>
<dependency>
<groupId>io.quarkus</groupId>
@@ -83,6 +87,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jsonb</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ </dependency>
<!-- test dependencies -->
<dependency>
@@ -95,6 +103,18 @@
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.awaitility</groupId>
+ <artifactId>awaitility</artifactId>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest-core</artifactId>
+ </exclusion>
+ </exclusions>
+ </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>
diff --git
a/integration-tests/dataformats-json/src/main/java/org/apache/camel/quarkus/component/dataformats/jackson/xml/JacksonXmlResource.java
b/integration-tests/dataformats-json/src/main/java/org/apache/camel/quarkus/component/dataformats/jackson/xml/JacksonXmlResource.java
new file mode 100644
index 0000000..5f2a128
--- /dev/null
+++
b/integration-tests/dataformats-json/src/main/java/org/apache/camel/quarkus/component/dataformats/jackson/xml/JacksonXmlResource.java
@@ -0,0 +1,595 @@
+/*
+ * 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.dataformats.jackson.xml;
+
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TimeZone;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ConsumerTemplate;
+import org.apache.camel.Exchange;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.jacksonxml.JacksonXMLConstants;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.quarkus.component.dataformats.json.model.TestJAXBPojo;
+import org.apache.camel.quarkus.component.dataformats.json.model.TestOtherPojo;
+import org.apache.camel.quarkus.component.dataformats.json.model.TestPojo;
+import org.apache.camel.quarkus.component.dataformats.json.model.TestPojoView;
+import org.apache.camel.support.DefaultExchange;
+import org.jboss.logging.Logger;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+@Path("/dataformats-json")
+@ApplicationScoped
+public class JacksonXmlResource {
+
+ private static final Logger LOG =
Logger.getLogger(JacksonXmlResource.class);
+ private static final String LS = System.lineSeparator();
+ @Inject
+ ProducerTemplate producerTemplate;
+ @Inject
+ ConsumerTemplate consumerTemplate;
+ @Inject
+ CamelContext context;
+
+ @Path("jacksonxml/unmarshal-type-header")
+ @POST
+ @Consumes(MediaType.TEXT_XML)
+ @Produces(MediaType.APPLICATION_JSON)
+ public TestPojo jacksonXmlUnmarshalTypeHeader(String body) {
+
+ return producerTemplate
+
.requestBodyAndHeader("direct:jacksonxml-unmarshal-type-header", body,
JacksonXMLConstants.UNMARSHAL_TYPE,
+ TestPojo.class.getName(),
+ TestPojo.class);
+
+ }
+
+ @Path("jacksonxml/unmarshal-list")
+ @GET
+ public void jacksonXmlUnmarshalList(String body) throws Exception {
+
+ MockEndpoint mock =
context.getEndpoint("mock:jacksonxml-unmarshal-list-reversePojo",
MockEndpoint.class);
+ mock.expectedMessageCount(1);
+ mock.message(0).body().isInstanceOf(List.class);
+
+ String json = "<list><pojo name=\"Camel\"/><pojo
name=\"World\"/></list>";
+ producerTemplate.sendBody("direct:jacksonxml-unmarshal-list", json);
+
+ mock.assertIsSatisfied();
+
+ List list =
mock.getReceivedExchanges().get(0).getIn().getBody(List.class);
+ assertNotNull(list);
+ assertEquals(2, list.size());
+
+ TestPojo pojo = (TestPojo) list.get(0);
+ assertEquals("Camel", pojo.getName());
+ pojo = (TestPojo) list.get(1);
+ assertEquals("World", pojo.getName());
+
+ mock.expectedMessageCount(2);
+ mock.message(1).body().isInstanceOf(List.class);
+
+ json = "<list><pojo name=\"Camel\"/></list>";
+ producerTemplate.sendBody("direct:jacksonxml-unmarshal-list", json);
+
+ mock.assertIsSatisfied();
+
+ list = mock.getReceivedExchanges().get(1).getIn().getBody(List.class);
+ assertNotNull(list);
+ assertEquals(1, list.size());
+
+ pojo = (TestPojo) list.get(0);
+ assertEquals("Camel", pojo.getName());
+
+ }
+
+ @SuppressWarnings("rawtypes")
+ @Path("jacksonxml/unmarshal-listsplit")
+ @POST
+ @Consumes(MediaType.TEXT_XML)
+ @Produces(MediaType.APPLICATION_JSON)
+ public List jacksonXmlUnmarshalListSplit(String body) {
+
+ return producerTemplate
+ .requestBody("direct:jacksonxml-unmarshal-listsplit", body,
List.class);
+
+ }
+
+ @Path("jacksonxml/marshal-includedefault")
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public String jacksonXmlMarshalIncludeDefalut() throws Exception {
+ TestOtherPojo pojo = new TestOtherPojo();
+ pojo.setName("Camel");
+ return
producerTemplate.requestBody("direct:jacksonxml-marshal-includedefault",
+ pojo,
+ String.class);
+ }
+
+ @Path("jacksonxml/marshal-contenttype-header")
+ @GET
+ public void jacksonXmlMarshalContentTypeHeader() throws Exception {
+ final Map<String, Object> in = new HashMap<>();
+ in.put("name", "Camel");
+
+ Exchange out =
producerTemplate.request("direct:jacksonxml-marshal-ct-yes", exchange ->
exchange.getIn().setBody(in));
+
+ assertNotNull(out);
+ assertTrue(out.hasOut());
+ assertEquals("application/xml",
out.getMessage().getHeader(Exchange.CONTENT_TYPE));
+ out = producerTemplate.request("direct:jacksonxml-marshal-ct-yes2",
exchange -> exchange.getIn().setBody(in));
+
+ assertNotNull(out);
+ assertTrue(out.hasOut());
+ assertEquals("application/xml",
out.getMessage().getHeader(Exchange.CONTENT_TYPE));
+
+ out = producerTemplate.request("direct:jacksonxml-marshal-ct-no",
exchange -> exchange.getIn().setBody(in));
+
+ assertNotNull(out);
+ assertTrue(out.hasOut());
+ assertNull(out.getMessage().getHeader(Exchange.CONTENT_TYPE));
+ }
+
+ @Path("jacksonxml/marshal-general")
+ @GET
+ public void jacksonXmlMarshalGeneral() throws Exception {
+ Map<String, Object> in = new HashMap<>();
+ in.put("name", "Camel");
+
+ MockEndpoint mock = context.getEndpoint("mock:reverse",
MockEndpoint.class);
+ mock.expectedMessageCount(1);
+ mock.message(0).body().isInstanceOf(Map.class);
+ mock.message(0).body().isEqualTo(in);
+
+ Object marshalled =
producerTemplate.requestBody("direct:jacksonxml-marshal-in", in);
+ String marshalledAsString =
context.getTypeConverter().convertTo(String.class, marshalled);
+ assertEquals("<HashMap><name>Camel</name></HashMap>",
marshalledAsString);
+
+ producerTemplate.sendBody("direct:jacksonxml-marshal-back",
marshalled);
+
+ mock.assertIsSatisfied();
+
+ mock.expectedMessageCount(2);
+ mock.message(1).body().isInstanceOf(Map.class);
+ mock.message(1).body().isEqualTo(in);
+ marshalled =
producerTemplate.requestBody("direct:jacksonxml-marshal-inPretty", in);
+ marshalledAsString =
context.getTypeConverter().convertTo(String.class, marshalled);
+ String expected = "<HashMap>" + LS + " <name>Camel</name>" + LS +
"</HashMap>" + LS;
+ assertEquals(expected, marshalledAsString);
+
+ producerTemplate.sendBody("direct:jacksonxml-marshal-backPretty",
marshalled);
+
+ mock.assertIsSatisfied();
+
+ TestPojo pojo = new TestPojo();
+ pojo.setName("Camel");
+
+ mock = context.getEndpoint("mock:reversePojo", MockEndpoint.class);
+ mock.expectedMessageCount(1);
+ mock.message(0).body().isInstanceOf(TestPojo.class);
+ mock.message(0).body().isEqualTo(pojo);
+
+ marshalled =
producerTemplate.requestBody("direct:jacksonxml-marshal-inPojo", pojo);
+ marshalledAsString =
context.getTypeConverter().convertTo(String.class, marshalled);
+ assertEquals("<TestPojo><name>Camel</name></TestPojo>",
marshalledAsString);
+
+ producerTemplate.sendBody("direct:jacksonxml-marshal-backPojo",
marshalled);
+
+ mock.assertIsSatisfied();
+ }
+
+ @Path("jacksonxml/marshal-allowjmstype")
+ @GET
+ public void jacksonXmlMarshalAllowJmsType() throws Exception {
+ MockEndpoint mock =
context.getEndpoint("mock:allowjmstype-reversePojo", MockEndpoint.class);
+ mock.expectedMessageCount(1);
+ //mock.message(0).body().isInstanceOf(TestPojo.class);
+
+ String json = "<pojo name=\"Camel\"/>";
+
producerTemplate.sendBodyAndHeader("direct:jacksonxml-marshal-allowjmstype-backPojo",
json, "JMSType",
+ TestPojo.class.getName());
+
+ mock.assertIsSatisfied();
+
+ TestPojo pojo =
mock.getReceivedExchanges().get(0).getIn().getBody(TestPojo.class);
+ assertNotNull(pojo);
+ assertEquals("Camel", pojo.getName());
+ }
+
+ @Path("jacksonxml/marshal-module")
+ @GET
+ public void jacksonXmlMarshalModule() throws Exception {
+ MockEndpoint mock =
context.getEndpoint("mock:jacksonxml-marshal-module", MockEndpoint.class);
+ mock.expectedMessageCount(1);
+ mock.message(0).body(String.class)
+
.isEqualTo("<TestOtherPojo><my-name>Camel</my-name><my-country>Denmark</my-country></TestOtherPojo>");
+
+ TestOtherPojo pojo = new TestOtherPojo();
+ pojo.setName("Camel");
+ pojo.setCountry("Denmark");
+
+ producerTemplate.sendBody("direct:jacksonxml-marshal-module", pojo);
+
+ mock.assertIsSatisfied();
+ }
+
+ @Path("jacksonxml/unmarshal-springlist")
+ @GET
+ public void jacksonXmlUnmarshalSpringList() throws Exception {
+ MockEndpoint mock =
context.getEndpoint("mock:jacksonxml-unmarshal-spring-list-reversePojo",
MockEndpoint.class);
+ mock.expectedMessageCount(1);
+ mock.message(0).body().isInstanceOf(List.class);
+
+ String json = "<list><pojo name=\"Camel\"/><pojo
name=\"World\"/></list>";
+
producerTemplate.sendBody("direct:jacksonxml-unmarshal-spring-list-backPojo",
json);
+
+ mock.assertIsSatisfied();
+
+ List list =
mock.getReceivedExchanges().get(0).getIn().getBody(List.class);
+ assertNotNull(list);
+ assertEquals(2, list.size());
+
+ TestPojo pojo = (TestPojo) list.get(0);
+ assertEquals("Camel", pojo.getName());
+ pojo = (TestPojo) list.get(1);
+ assertEquals("World", pojo.getName());
+
+ mock.expectedMessageCount(2);
+ mock.message(1).body().isInstanceOf(List.class);
+
+ json = "<list><pojo name=\"Camel\"/></list>";
+
producerTemplate.sendBody("direct:jacksonxml-unmarshal-spring-list-backPojo",
json);
+
+ mock.assertIsSatisfied();
+
+ list = mock.getReceivedExchanges().get(1).getIn().getBody(List.class);
+ assertNotNull(list);
+ assertEquals(1, list.size());
+
+ pojo = (TestPojo) list.get(0);
+ assertEquals("Camel", pojo.getName());
+ }
+
+ @Path("jacksonxml/marshal-spring-enablefeature")
+ @GET
+ public void jacksonXmlMarshalSpringEnableFeature() throws Exception {
+ TestPojoView in = new TestPojoView();
+
+ Object marshalled =
producerTemplate.requestBody("direct:jacksonxml-marshal-spring-enablefeature",
in);
+ String marshalledAsString =
context.getTypeConverter().convertTo(String.class, marshalled);
+ // we enable the wrap root type feature so we should have TestPojoView
+
assertEquals("<TestPojoView><age>30</age><height>190</height><weight>70</weight></TestPojoView>",
marshalledAsString);
+ }
+
+ @Path("jacksonxml/marshal-concurrent")
+ @GET
+ public void jacksonXmlMarshalConcurrent() throws Exception {
+ doSendMessages(10, 5);
+ }
+
+ @Path("jacksonxml/marshal-conversion")
+ @GET
+ public void jacksonXmlMarshalConversion() throws Exception {
+ synchronized (context) {
+ String original =
context.getGlobalOptions().get(JacksonXMLConstants.ENABLE_TYPE_CONVERTER);
+ try {
+
context.getGlobalOptions().put(JacksonXMLConstants.ENABLE_TYPE_CONVERTER,
"true");
+ String name = "someName";
+ Map<String, String> pojoAsMap = new HashMap<>();
+ pojoAsMap.put("name", name);
+
+ TestPojo testPojo = (TestPojo) producerTemplate
+ .requestBody("direct:jacksonxml-marshal-conversion",
pojoAsMap);
+
+ assertEquals(name, testPojo.getName());
+ } finally {
+
context.getGlobalOptions().put(JacksonXMLConstants.ENABLE_TYPE_CONVERTER,
original);
+ }
+ }
+ }
+
+ @Path("jacksonxml/unmarshal-listjackson")
+ @GET
+ public void jacksonXmlUnmarshalListJackon() throws Exception {
+ MockEndpoint mock =
context.getEndpoint("mock:jacksonxml-unmarshal-listjackson",
MockEndpoint.class);
+ mock.expectedMessageCount(1);
+ mock.message(0).body().isInstanceOf(List.class);
+
+ String json = "<list><pojo name=\"Camel\"/><pojo
name=\"World\"/></list>";
+ producerTemplate.sendBody("direct:jacksonxml-unmarshal-listjackson",
json);
+
+ mock.assertIsSatisfied();
+
+ List list =
mock.getReceivedExchanges().get(0).getIn().getBody(List.class);
+ assertNotNull(list);
+ assertEquals(2, list.size());
+
+ TestPojo pojo = (TestPojo) list.get(0);
+ assertEquals("Camel", pojo.getName());
+ pojo = (TestPojo) list.get(1);
+ assertEquals("World", pojo.getName());
+
+ mock.expectedMessageCount(2);
+ mock.message(1).body().isInstanceOf(List.class);
+
+ json = "<list><pojo name=\"Camel\"/></list>";
+ producerTemplate.sendBody("direct:jacksonxml-unmarshal-listjackson",
json);
+
+ mock.assertIsSatisfied();
+
+ list = mock.getReceivedExchanges().get(1).getIn().getBody(List.class);
+ assertNotNull(list);
+ assertEquals(1, list.size());
+
+ pojo = (TestPojo) list.get(0);
+ assertEquals("Camel", pojo.getName());
+ }
+
+ @Path("jacksonxml/springjackson")
+ @GET
+ public void jacksonXmlSpringJackson() throws Exception {
+ Map<String, Object> in = new HashMap<>();
+ in.put("name", "Camel");
+
+ MockEndpoint mock = context.getEndpoint("mock:jacksonxml-xml-reverse",
MockEndpoint.class);
+ mock.expectedMessageCount(1);
+ mock.message(0).body().isInstanceOf(Map.class);
+ mock.message(0).body().isEqualTo(in);
+
+ Object marshalled =
producerTemplate.requestBody("direct:jacksonxml-xml-in", in);
+ String marshalledAsString =
context.getTypeConverter().convertTo(String.class, marshalled);
+ assertEquals("<HashMap><name>Camel</name></HashMap>",
marshalledAsString);
+
+ producerTemplate.sendBody("direct:jacksonxml-xml-back", marshalled);
+
+ mock.assertIsSatisfied();
+
+ mock.expectedMessageCount(2);
+ mock.message(1).body().isInstanceOf(Map.class);
+ mock.message(1).body().isEqualTo(in);
+
+ marshalled =
producerTemplate.requestBody("direct:jacksonxml-xml-inPretty", in);
+ marshalledAsString =
context.getTypeConverter().convertTo(String.class, marshalled);
+ String expected = "<HashMap>" + LS + " <name>Camel</name>" + LS +
"</HashMap>" + LS;
+ assertEquals(expected, marshalledAsString);
+
+ producerTemplate.sendBody("direct:jacksonxml-xml-back", marshalled);
+
+ mock.assertIsSatisfied();
+
+ mock = context.getEndpoint("mock:jacksonxml-xml-reversePojo",
MockEndpoint.class);
+ TestPojo pojo = new TestPojo();
+ pojo.setName("Camel");
+
+ mock.expectedMessageCount(1);
+ mock.message(0).body().isInstanceOf(TestPojo.class);
+ mock.message(0).body().isEqualTo(pojo);
+
+ marshalled =
producerTemplate.requestBody("direct:jacksonxml-xml-inPojo", pojo);
+ marshalledAsString =
context.getTypeConverter().convertTo(String.class, marshalled);
+ assertEquals("<TestPojo><name>Camel</name></TestPojo>",
marshalledAsString);
+
+ producerTemplate.sendBody("direct:jacksonxml-xml-backPojo",
marshalled);
+
+ mock.assertIsSatisfied();
+
+ TestPojoView view = new TestPojoView();
+
+ mock = context.getEndpoint("mock:jacksonxml-xml-reverseAgeView",
MockEndpoint.class);
+ mock.expectedMessageCount(1);
+ mock.message(0).body().isInstanceOf(TestPojoView.class);
+ mock.message(0).body().isEqualTo(view);
+
+ marshalled =
producerTemplate.requestBody("direct:jacksonxml-xml-inAgeView", view);
+ marshalledAsString =
context.getTypeConverter().convertTo(String.class, marshalled);
+ /*JsonView doesn't work correctly in native mode, need to investigate
more*/
+
//assertEquals("<TestPojoView><age>30</age><height>190</height></TestPojoView>",
marshalledAsString);
+
+ producerTemplate.sendBody("direct:jacksonxml-xml-backAgeView",
marshalled);
+
+ mock.assertIsSatisfied();
+ }
+
+ @Path("jacksonxml/jackson-conversion")
+ @GET
+ public void jacksonXmlJacksonConversion() throws Exception {
+ synchronized (context) {
+ String original =
context.getGlobalOptions().get(JacksonXMLConstants.ENABLE_TYPE_CONVERTER);
+ try {
+ Exchange exchange = new DefaultExchange(context);
+
context.getGlobalOptions().put(JacksonXMLConstants.ENABLE_TYPE_CONVERTER,
"true");
+ Map<String, String> body = new HashMap<>();
+ Object convertedObject =
context.getTypeConverter().convertTo(String.class, exchange, body);
+ // will do a toString which is an empty map
+ assertEquals(body.toString(), convertedObject);
+
+ convertedObject =
context.getTypeConverter().convertTo(Long.class, exchange,
+ new HashMap<String, String>());
+ assertNull(convertedObject);
+
+ convertedObject =
context.getTypeConverter().convertTo(long.class, exchange,
+ new HashMap<String, String>());
+ assertNull(convertedObject);
+ } finally {
+
context.getGlobalOptions().put(JacksonXMLConstants.ENABLE_TYPE_CONVERTER,
original);
+ }
+ }
+ }
+
+ @Path("jacksonxml/jaxb-annotation")
+ @GET
+ public void jacksonXmlJaxbAnnotation() throws Exception {
+ TestJAXBPojo in = new TestJAXBPojo();
+ in.setName("Camel");
+
+ MockEndpoint mock =
context.getEndpoint("mock:jacksonxml-jaxbannotation-reversePojo",
MockEndpoint.class);
+ mock.expectedMessageCount(1);
+ mock.message(0).body().isInstanceOf(TestJAXBPojo.class);
+ mock.message(0).body().isEqualTo(in);
+
+ Object marshalled =
producerTemplate.requestBody("direct:jacksonxml-jaxbannotation-inPojo", in);
+ String marshalledAsString =
context.getTypeConverter().convertTo(String.class, marshalled);
+ assertEquals("<XMLPojo><PojoName>Camel</PojoName></XMLPojo>",
marshalledAsString);
+
+ producerTemplate.sendBody("direct:jacksonxml-jaxbannotation-backPojo",
marshalled);
+
+ mock.assertIsSatisfied();
+ }
+
+ @Path("jacksonxml/jsonview")
+ @GET
+ public void jacksonXmlJsonview() throws Exception {
+ TestPojoView in = new TestPojoView();
+
+ MockEndpoint mock =
context.getEndpoint("mock:jacksonxml-jsonview-reversePojoAgeView",
MockEndpoint.class);
+ mock.expectedMessageCount(1);
+ mock.message(0).body().isInstanceOf(TestPojoView.class);
+ mock.message(0).body().isEqualTo(in);
+
+ Object marshalled =
producerTemplate.requestBody("direct:jacksonxml-jsonview-inPojoAgeView", in);
+ String marshalledAsString =
context.getTypeConverter().convertTo(String.class, marshalled);
+ /*JsonView doesn't work correctly in native mode, need to investigate
more*/
+
//assertEquals("<TestPojoView><age>30</age><height>190</height></TestPojoView>",
marshalledAsString);
+
+
producerTemplate.sendBody("direct:jacksonxml-jsonview-backPojoAgeView",
marshalled);
+
+ mock.assertIsSatisfied();
+
+ mock =
context.getEndpoint("mock:jacksonxml-jsonview-reversePojoWeightView",
MockEndpoint.class);
+ mock.expectedMessageCount(1);
+ mock.message(0).body().isInstanceOf(TestPojoView.class);
+ mock.message(0).body().isEqualTo(in);
+
+ marshalled =
producerTemplate.requestBody("direct:jacksonxml-jsonview-inPojoWeightView", in);
+ marshalledAsString =
context.getTypeConverter().convertTo(String.class, marshalled);
+
+ /*JsonView doesn't work correctly in native mode, need to investigate
more*/
+
//assertEquals("<TestPojoView><height>190</height><weight>70</weight></TestPojoView>",
marshalledAsString);
+
+
producerTemplate.sendBody("direct:jacksonxml-jsonview-backPojoWeightView",
marshalled);
+
+ mock.assertIsSatisfied();
+ }
+
+ @Path("jacksonxml/moduleref")
+ @GET
+ public void jacksonXmlModuleRef() throws Exception {
+ MockEndpoint mock =
context.getEndpoint("mock:jacksonxml-moduleref-marshal", MockEndpoint.class);
+ mock.expectedMessageCount(1);
+ mock.message(0).body(String.class)
+
.isEqualTo("<TestOtherPojo><my-name>Camel</my-name><my-country>Denmark</my-country></TestOtherPojo>");
+
+ TestOtherPojo pojo = new TestOtherPojo();
+ pojo.setName("Camel");
+ pojo.setCountry("Denmark");
+
+ producerTemplate.sendBody("direct:jacksonxml-moduleref-marshal", pojo);
+
+ mock.assertIsSatisfied();
+ }
+
+ @Path("jacksonxml/include-no-null")
+ @GET
+ public void jacksonXmlIncludeNoNull() throws Exception {
+ MockEndpoint mock =
context.getEndpoint("mock:jacksonxml-include-non-null-marshal",
MockEndpoint.class);
+ mock.expectedMessageCount(1);
+
mock.message(0).body(String.class).isEqualTo("<TestOtherPojo><name>Camel</name></TestOtherPojo>");
+
+ TestOtherPojo pojo = new TestOtherPojo();
+ pojo.setName("Camel");
+
+
producerTemplate.sendBody("direct:jacksonxml-include-non-null-marshal", pojo);
+
+ mock.assertIsSatisfied();
+ }
+
+ @Path("jacksonxml/typeheader-not-allowed")
+ @GET
+ public void jacksonXmlTypeHeaderNotAllowed() throws Exception {
+ MockEndpoint mock =
context.getEndpoint("mock:jacksonxml-typeheader-not-allowed-reversePojo",
MockEndpoint.class);
+ mock.expectedMessageCount(1);
+
+ String json = "<pojo name=\"Camel\"/>";
+
producerTemplate.sendBodyAndHeader("direct:jacksonxml-typeheader-not-allowed-backPojo",
json,
+ JacksonXMLConstants.UNMARSHAL_TYPE, TestPojo.class.getName());
+
+ mock.assertIsSatisfied();
+
+ }
+
+ @Path("jacksonxml/datetimezone")
+ @GET
+ public void jacksonXmlDatetimezone() throws Exception {
+ MockEndpoint mock =
context.getEndpoint("mock:jacksonxml-datatimezone-result", MockEndpoint.class);
+ TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
+ GregorianCalendar in = new GregorianCalendar(2017, Calendar.APRIL, 25,
17, 0, 10);
+
+ Object marshalled =
producerTemplate.requestBody("direct:jacksonxml-datatimezone-in", in.getTime());
+ String marshalledAsString =
context.getTypeConverter().convertTo(String.class, marshalled);
+ assertEquals("<Date>1493139610000</Date>", marshalledAsString);
+
+ mock.expectedMessageCount(1);
+
+ mock.assertIsSatisfied();
+
+ }
+
+ private void doSendMessages(int files, int poolSize) throws Exception {
+ MockEndpoint mock =
context.getEndpoint("mock:jacksonxml-marshal-concurrent-result",
MockEndpoint.class);
+ mock.expectedMessageCount(files);
+ mock.assertNoDuplicates(org.apache.camel.builder.Builder.body());
+
+ ExecutorService executor = Executors.newFixedThreadPool(poolSize);
+ for (int i = 0; i < files; i++) {
+ final int index = i;
+ executor.submit(new Callable<Object>() {
+ public Object call() throws Exception {
+ TestPojo pojo = new TestPojo();
+ pojo.setName("Hi " + index);
+
+
producerTemplate.sendBody("direct:jacksonxml-marshal-concurrent-start", pojo);
+ return null;
+ }
+ });
+ }
+
+ mock.assertIsSatisfied();
+ executor.shutdownNow();
+ }
+
+}
diff --git
a/integration-tests/dataformats-json/src/main/java/org/apache/camel/quarkus/component/dataformats/jackson/xml/JacksonXmlRoute.java
b/integration-tests/dataformats-json/src/main/java/org/apache/camel/quarkus/component/dataformats/jackson/xml/JacksonXmlRoute.java
new file mode 100644
index 0000000..cbcac13
--- /dev/null
+++
b/integration-tests/dataformats-json/src/main/java/org/apache/camel/quarkus/component/dataformats/jackson/xml/JacksonXmlRoute.java
@@ -0,0 +1,130 @@
+/*
+ * 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.dataformats.jackson.xml;
+
+import java.util.TimeZone;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.jacksonxml.JacksonXMLConstants;
+import org.apache.camel.component.jacksonxml.JacksonXMLDataFormat;
+import org.apache.camel.component.jacksonxml.ListJacksonXMLDataFormat;
+import org.apache.camel.quarkus.component.dataformats.json.model.DummyObject;
+import org.apache.camel.quarkus.component.dataformats.json.model.MyModule;
+import org.apache.camel.quarkus.component.dataformats.json.model.TestJAXBPojo;
+import org.apache.camel.quarkus.component.dataformats.json.model.TestPojo;
+import org.apache.camel.quarkus.component.dataformats.json.model.TestPojoView;
+import org.apache.camel.quarkus.component.dataformats.json.model.Views;
+
+public class JacksonXmlRoute extends RouteBuilder {
+
+ @Override
+ public void configure() throws Exception {
+ JacksonXMLDataFormat unmarshalTypeHeaderFormat = new
JacksonXMLDataFormat();
+ unmarshalTypeHeaderFormat.setAllowUnmarshallType(true);
+
from("direct:jacksonxml-unmarshal-type-header").unmarshal(unmarshalTypeHeaderFormat);
+
+ JacksonXMLDataFormat listFormat = new
JacksonXMLDataFormat(TestPojo.class);
+ listFormat.useList();
+
from("direct:jacksonxml-unmarshal-list").unmarshal(listFormat).to("mock:jacksonxml-unmarshal-list-reversePojo");
+
+ JacksonXMLDataFormat listSplitFormat = new
JacksonXMLDataFormat(DummyObject.class);
+ listSplitFormat.useList();
+
from("direct:jacksonxml-unmarshal-listsplit").unmarshal(listSplitFormat).split(body()).to("mock:listsplit-result");
+
+ JacksonXMLDataFormat format = new JacksonXMLDataFormat();
+
from("direct:jacksonxml-marshal-includedefault").marshal(format).to("mock:marshal-includedefalut");
+
+ JacksonXMLDataFormat marshalContentTypeformat = new
JacksonXMLDataFormat();
+
from("direct:jacksonxml-marshal-ct-yes").marshal(marshalContentTypeformat);
+ from("direct:jacksonxml-marshal-ct-yes2").marshal().jacksonxml();
+ JacksonXMLDataFormat marshalContentTypeFormatNoHeader = new
JacksonXMLDataFormat();
+ marshalContentTypeFormatNoHeader.setContentTypeHeader(false);
+
from("direct:jacksonxml-marshal-ct-no").marshal(marshalContentTypeFormatNoHeader);
+
+ JacksonXMLDataFormat jacksonMarshalFormat = new JacksonXMLDataFormat();
+ from("direct:jacksonxml-marshal-in").marshal(jacksonMarshalFormat);
+
from("direct:jacksonxml-marshal-back").unmarshal(jacksonMarshalFormat).to("mock:reverse");
+ JacksonXMLDataFormat prettyPrintDataFormat = new
JacksonXMLDataFormat();
+ prettyPrintDataFormat.setPrettyPrint(true);
+
from("direct:jacksonxml-marshal-inPretty").marshal(prettyPrintDataFormat);
+
from("direct:jacksonxml-marshal-backPretty").unmarshal(prettyPrintDataFormat).to("mock:reverse");
+ JacksonXMLDataFormat formatPojo = new
JacksonXMLDataFormat(TestPojo.class);
+ from("direct:jacksonxml-marshal-inPojo").marshal(formatPojo);
+
from("direct:jacksonxml-marshal-backPojo").unmarshal(formatPojo).to("mock:reversePojo");
+
+ JacksonXMLDataFormat jacksonXmlMarshalAllowJmsTypeformat = new
JacksonXMLDataFormat();
+ jacksonXmlMarshalAllowJmsTypeformat.setAllowJmsType(true);
+
from("direct:jacksonxml-marshal-allowjmstype-backPojo").unmarshal(jacksonXmlMarshalAllowJmsTypeformat)
+ .to("mock:allowjmstype-reversePojo");
+
+ JacksonXMLDataFormat jacksonXmlMarshalModuleformat = new
JacksonXMLDataFormat();
+ jacksonXmlMarshalModuleformat.setInclude("NON_NULL");
+
jacksonXmlMarshalModuleformat.setModuleClassNames("org.apache.camel.quarkus.component.dataformats.json.model.MyModule");
+
from("direct:jacksonxml-marshal-module").marshal(jacksonXmlMarshalModuleformat).to("mock:jacksonxml-marshal-module");
+
+
from("direct:jacksonxml-marshal-concurrent-start").marshal().jacksonxml().to("log:marshalled")
+ .to("direct:jacksonxml-marshal-concurrent-marshalled");
+
from("direct:jacksonxml-marshal-concurrent-marshalled").unmarshal().jacksonxml(TestPojo.class)
+ .to("mock:jacksonxml-marshal-concurrent-result");
+
this.getContext().getGlobalOptions().put(JacksonXMLConstants.ENABLE_TYPE_CONVERTER,
"true");
+
from("direct:jacksonxml-marshal-conversion").convertBodyTo(TestPojo.class);
+
+ from("direct:jacksonxml-unmarshal-listjackson").unmarshal(new
ListJacksonXMLDataFormat(TestPojo.class))
+ .to("mock:jacksonxml-unmarshal-listjackson");
+
+ JacksonXMLDataFormat jacksonXmlJaxbAnnotationFormat = new
JacksonXMLDataFormat();
+
from("direct:jacksonxml-jaxbannotation-in").marshal(jacksonXmlJaxbAnnotationFormat);
+
from("direct:jacksonxml-jaxbannotation-back").unmarshal(jacksonXmlJaxbAnnotationFormat)
+ .to("mock:jacksonxml-jaxbannotation-reverse");
+ JacksonXMLDataFormat jacksonXmlJaxbAnnotationformatPojo = new
JacksonXMLDataFormat(TestJAXBPojo.class);
+
from("direct:jacksonxml-jaxbannotation-inPojo").marshal(jacksonXmlJaxbAnnotationformatPojo);
+
from("direct:jacksonxml-jaxbannotation-backPojo").unmarshal(jacksonXmlJaxbAnnotationformatPojo)
+ .to("mock:jacksonxml-jaxbannotation-reversePojo");
+
+
from("direct:jacksonxml-jsonview-inPojoAgeView").marshal().jacksonxml(TestPojoView.class,
Views.Age.class);
+
from("direct:jacksonxml-jsonview-backPojoAgeView").unmarshal().jacksonxml(TestPojoView.class)
+ .to("mock:jacksonxml-jsonview-reversePojoAgeView");
+
from("direct:jacksonxml-jsonview-inPojoWeightView").marshal().jacksonxml(TestPojoView.class,
Views.Weight.class);
+
from("direct:jacksonxml-jsonview-backPojoWeightView").unmarshal().jacksonxml(TestPojoView.class)
+ .to("mock:jacksonxml-jsonview-reversePojoWeightView");
+
+ this.getContext().getRegistry().bind("myJacksonModule", new
MyModule());
+ JacksonXMLDataFormat jacksonXmlModuleRef = new JacksonXMLDataFormat();
+ jacksonXmlModuleRef.setInclude("NON_NULL");
+ jacksonXmlModuleRef.setModuleRefs("myJacksonModule");
+
from("direct:jacksonxml-moduleref-marshal").marshal(jacksonXmlModuleRef).to("mock:jacksonxml-moduleref-marshal");
+
+ JacksonXMLDataFormat jacksomXmlIncludeNotNullFormat = new
JacksonXMLDataFormat();
+ jacksomXmlIncludeNotNullFormat.setInclude("NON_NULL");
+
from("direct:jacksonxml-include-non-null-marshal").marshal(jacksomXmlIncludeNotNullFormat)
+ .to("mock:jacksonxml-include-non-null-marshal");
+
+ JacksonXMLDataFormat jacksonXmlTypeHeaderNotAllowedFormat = new
JacksonXMLDataFormat();
+
from("direct:jacksonxml-typeheader-not-allowed-backPojo").unmarshal(jacksonXmlTypeHeaderNotAllowedFormat)
+ .to("mock:jacksonxml-typeheader-not-allowed-reversePojo");
+
+ JacksonXMLDataFormat jacksonXmlDateTimezoneFormat = new
JacksonXMLDataFormat();
+ TimeZone timeZone = TimeZone.getTimeZone("Africa/Ouagadougou");
+ jacksonXmlDateTimezoneFormat.setTimezone(timeZone);
+
+
from("direct:jacksonxml-datatimezone-in").marshal(jacksonXmlDateTimezoneFormat)
+ .to("mock:jacksonxml-datatimezone-result");
+
+ }
+
+}
diff --git
a/integration-tests/dataformats-json/src/main/java/org/apache/camel/quarkus/component/dataformats/json/JsonDataformatsResource.java
b/integration-tests/dataformats-json/src/main/java/org/apache/camel/quarkus/component/dataformats/json/JsonDataformatsResource.java
index 35a7778..6f51cd8 100644
---
a/integration-tests/dataformats-json/src/main/java/org/apache/camel/quarkus/component/dataformats/json/JsonDataformatsResource.java
+++
b/integration-tests/dataformats-json/src/main/java/org/apache/camel/quarkus/component/dataformats/json/JsonDataformatsResource.java
@@ -38,7 +38,6 @@ import org.jboss.logging.Logger;
public class JsonDataformatsResource {
private static final Logger LOG =
Logger.getLogger(JsonDataformatsResource.class);
-
@Inject
ProducerTemplate producerTemplate;
@Inject
@@ -114,6 +113,7 @@ public class JsonDataformatsResource {
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.TEXT_XML)
public String jacksonXmlMarshal(PojoA pojo) {
+
return producerTemplate.requestBody("direct:jacksonxml-marshal", pojo,
String.class);
}
@@ -122,6 +122,7 @@ public class JsonDataformatsResource {
@Consumes(MediaType.TEXT_XML)
@Produces(MediaType.APPLICATION_JSON)
public PojoA jacksonXmlMarshal(String body) {
+
return producerTemplate.requestBody("direct:jacksonxml-unmarshal",
body, PojoA.class);
}
diff --git
a/integration-tests/dataformats-json/src/main/java/org/apache/camel/quarkus/component/dataformats/json/model/MyModule.java
b/integration-tests/dataformats-json/src/main/java/org/apache/camel/quarkus/component/dataformats/json/model/MyModule.java
new file mode 100644
index 0000000..aeb42d2
--- /dev/null
+++
b/integration-tests/dataformats-json/src/main/java/org/apache/camel/quarkus/component/dataformats/json/model/MyModule.java
@@ -0,0 +1,47 @@
+/*
+ * 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.dataformats.json.model;
+
+import com.fasterxml.jackson.core.Version;
+import com.fasterxml.jackson.databind.Module;
+import com.fasterxml.jackson.databind.PropertyNamingStrategy;
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection
+public class MyModule extends Module {
+
+ @Override
+ public String getModuleName() {
+ return "MyModule";
+ }
+
+ @Override
+ public Version version() {
+ return Version.unknownVersion();
+ }
+
+ @Override
+ public void setupModule(SetupContext context) {
+ context.setNamingStrategy(new
PropertyNamingStrategy.PropertyNamingStrategyBase() {
+ @Override
+ public String translate(String propertyName) {
+ return "my-" + propertyName;
+ }
+ });
+ }
+
+}
diff --git
a/integration-tests/dataformats-json/src/main/java/org/apache/camel/quarkus/component/dataformats/json/model/TestJAXBPojo.java
b/integration-tests/dataformats-json/src/main/java/org/apache/camel/quarkus/component/dataformats/json/model/TestJAXBPojo.java
new file mode 100644
index 0000000..bc75a70
--- /dev/null
+++
b/integration-tests/dataformats-json/src/main/java/org/apache/camel/quarkus/component/dataformats/json/model/TestJAXBPojo.java
@@ -0,0 +1,53 @@
+/*
+ * 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.dataformats.json.model;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection
+@XmlRootElement(name = "XMLPojo")
+public class TestJAXBPojo {
+
+ @XmlElement(name = "PojoName")
+ private String name;
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return this.name.equals(((TestJAXBPojo) obj).getName());
+ }
+
+ @Override
+ public int hashCode() {
+ return name != null ? name.hashCode() : 0;
+ }
+
+ @Override
+ public String toString() {
+ return "TestJAXBPojo[" + name + "]";
+ }
+}
diff --git
a/integration-tests/dataformats-json/src/main/java/org/apache/camel/quarkus/component/dataformats/json/model/TestOtherPojo.java
b/integration-tests/dataformats-json/src/main/java/org/apache/camel/quarkus/component/dataformats/json/model/TestOtherPojo.java
new file mode 100644
index 0000000..24e1fd0
--- /dev/null
+++
b/integration-tests/dataformats-json/src/main/java/org/apache/camel/quarkus/component/dataformats/json/model/TestOtherPojo.java
@@ -0,0 +1,43 @@
+/*
+ * 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.dataformats.json.model;
+
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection
+public class TestOtherPojo {
+
+ private String name;
+ private String country;
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getCountry() {
+ return country;
+ }
+
+ public void setCountry(String country) {
+ this.country = country;
+ }
+
+}
diff --git
a/integration-tests/dataformats-json/src/main/java/org/apache/camel/quarkus/component/dataformats/json/model/TestPojo.java
b/integration-tests/dataformats-json/src/main/java/org/apache/camel/quarkus/component/dataformats/json/model/TestPojo.java
new file mode 100644
index 0000000..5d2b8b7
--- /dev/null
+++
b/integration-tests/dataformats-json/src/main/java/org/apache/camel/quarkus/component/dataformats/json/model/TestPojo.java
@@ -0,0 +1,48 @@
+/*
+ * 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.dataformats.json.model;
+
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection
+public class TestPojo {
+
+ private String name;
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return this.name.equals(((TestPojo) obj).getName());
+ }
+
+ @Override
+ public int hashCode() {
+ return name != null ? name.hashCode() : 0;
+ }
+
+ @Override
+ public String toString() {
+ return "TestPojo[" + name + "]";
+ }
+}
diff --git
a/integration-tests/dataformats-json/src/main/java/org/apache/camel/quarkus/component/dataformats/json/model/TestPojoView.java
b/integration-tests/dataformats-json/src/main/java/org/apache/camel/quarkus/component/dataformats/json/model/TestPojoView.java
new file mode 100644
index 0000000..aefdd53
--- /dev/null
+++
b/integration-tests/dataformats-json/src/main/java/org/apache/camel/quarkus/component/dataformats/json/model/TestPojoView.java
@@ -0,0 +1,87 @@
+/*
+ * 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.dataformats.json.model;
+
+import com.fasterxml.jackson.annotation.JsonView;
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection
+public class TestPojoView {
+
+ //START SNIPPET: jsonview
+ @JsonView(Views.Age.class)
+ private int age = 30;
+
+ private int height = 190;
+
+ @JsonView(Views.Weight.class)
+ private int weight = 70;
+ //END SNIPPET: jsonview
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+
+ public int getHeight() {
+ return height;
+ }
+
+ public void setHeight(int height) {
+ this.height = height;
+ }
+
+ public int getWeight() {
+ return weight;
+ }
+
+ public void setWeight(int weight) {
+ this.weight = weight;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ TestPojoView that = (TestPojoView) o;
+
+ if (age != that.age) {
+ return false;
+ }
+ if (height != that.height) {
+ return false;
+ }
+ return weight == that.weight;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = age;
+ result = 31 * result + height;
+ result = 31 * result + weight;
+ return result;
+ }
+
+}
diff --git
a/integration-tests/dataformats-json/src/main/java/org/apache/camel/quarkus/component/dataformats/json/model/Views.java
b/integration-tests/dataformats-json/src/main/java/org/apache/camel/quarkus/component/dataformats/json/model/Views.java
new file mode 100644
index 0000000..d308eb3
--- /dev/null
+++
b/integration-tests/dataformats-json/src/main/java/org/apache/camel/quarkus/component/dataformats/json/model/Views.java
@@ -0,0 +1,31 @@
+/*
+ * 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.dataformats.json.model;
+
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection
+//START SNIPPET: marker
+public class Views {
+
+ public static class Age {
+ }
+
+ public static class Weight {
+ }
+}
+//END SNIPPET: marker
diff --git
a/integration-tests/dataformats-json/src/main/resources/routes/jackson-routes.xml
b/integration-tests/dataformats-json/src/main/resources/routes/jackson-routes.xml
index 09f49fa..dbb22e2 100644
---
a/integration-tests/dataformats-json/src/main/resources/routes/jackson-routes.xml
+++
b/integration-tests/dataformats-json/src/main/resources/routes/jackson-routes.xml
@@ -40,4 +40,57 @@
</unmarshal>
</route>
-</routes>
\ No newline at end of file
+ <route>
+ <from uri="direct:jacksonxml-unmarshal-spring-list-backPojo"/>
+ <unmarshal><jacksonxml useList="true"
unmarshalTypeName="org.apache.camel.quarkus.component.dataformats.json.model.TestPojo"/></unmarshal>
+ <to uri="mock:jacksonxml-unmarshal-spring-list-reversePojo"/>
+ </route>
+
+ <route>
+ <from uri="direct:jacksonxml-marshal-spring-enablefeature"/>
+ <marshal>
+ <jacksonxml
unmarshalTypeName="org.apache.camel.quarkus.component.dataformats.json.model.TestPojo"
+ enableFeatures="WRAP_ROOT_VALUE"/>
+ </marshal>
+ </route>
+
+ <route>
+ <from uri="direct:jacksonxml-xml-in"/>
+ <marshal><jacksonxml/></marshal>
+ </route>
+
+ <route>
+ <from uri="direct:jacksonxml-xml-inPretty"/>
+ <marshal><jacksonxml prettyPrint="true"/></marshal>
+ </route>
+
+ <route>
+ <from uri="direct:jacksonxml-xml-back"/>
+ <unmarshal><jacksonxml/></unmarshal>
+ <to uri="mock:jacksonxml-xml-reverse"/>
+ </route>
+
+ <route>
+ <from uri="direct:jacksonxml-xml-inPojo"/>
+ <marshal><jacksonxml
unmarshalTypeName="org.apache.camel.quarkus.component.dataformats.json.model.TestPojo"/></marshal>
+ </route>
+
+ <route>
+ <from uri="direct:jacksonxml-xml-backPojo"/>
+ <unmarshal><jacksonxml
unmarshalTypeName="org.apache.camel.quarkus.component.dataformats.json.model.TestPojo"/></unmarshal>
+ <to uri="mock:jacksonxml-xml-reversePojo"/>
+ </route>
+
+ <route>
+ <from uri="direct:jacksonxml-xml-inAgeView"/>
+ <marshal><jacksonxml
unmarshalTypeName="org.apache.camel.quarkus.component.dataformats.json.model.TestPojoView"
jsonViewTypeName="org.apache.camel.quarkus.component.dataformats.json.model.Views$Age"/></marshal>
+ </route>
+
+ <route>
+ <from uri="direct:jacksonxml-xml-backAgeView"/>
+ <unmarshal><jacksonxml
unmarshalTypeName="org.apache.camel.quarkus.component.dataformats.json.model.TestPojoView"
jsonViewTypeName="org.apache.camel.quarkus.component.dataformats.json.model.Views$Age"/></unmarshal>
+ <to uri="mock:jacksonxml-xml-reverseAgeView"/>
+ </route>
+</routes>
+
+
diff --git
a/integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/jackson/xml/JacksonXmlIT.java
b/integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/jackson/xml/JacksonXmlIT.java
new file mode 100644
index 0000000..acb7589
--- /dev/null
+++
b/integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/jackson/xml/JacksonXmlIT.java
@@ -0,0 +1,24 @@
+/*
+ * 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.dataformats.jackson.xml;
+
+import io.quarkus.test.junit.NativeImageTest;
+
+@NativeImageTest
+public class JacksonXmlIT extends JacksonXmlTest {
+
+}
diff --git
a/integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/jackson/xml/JacksonXmlTest.java
b/integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/jackson/xml/JacksonXmlTest.java
new file mode 100644
index 0000000..6f2b31e
--- /dev/null
+++
b/integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/jackson/xml/JacksonXmlTest.java
@@ -0,0 +1,234 @@
+/*
+ * 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.dataformats.jackson.xml;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import javax.json.bind.JsonbBuilder;
+
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+import org.apache.camel.quarkus.component.dataformats.json.model.DummyObject;
+import org.apache.camel.quarkus.component.dataformats.json.model.TestPojo;
+import org.junit.jupiter.api.Test;
+
+import static org.awaitility.Awaitility.await;
+import static org.hamcrest.Matchers.equalTo;
+
+@QuarkusTest
+public class JacksonXmlTest {
+ @Test
+ void jacksonXmlUnmarshalTypeHeader() {
+ final String testPojoXml = "<pojo name=\"Camel\"/>";
+ TestPojo testPojo = new TestPojo();
+ testPojo.setName("Camel");
+ final String testPojoJson = JsonbBuilder.create().toJson(testPojo);
+ RestAssured.given()
+ .contentType("text/xml")
+ .body(testPojoXml)
+ .post("/dataformats-json/jacksonxml/unmarshal-type-header")
+ .then()
+ .statusCode(200)
+ .body(equalTo(testPojoJson));
+ }
+
+ @Test
+ void jacksonXmlUnmarshalList() {
+ RestAssured.get("/dataformats-json/jacksonxml/unmarshal-list")
+ .then()
+ .statusCode(204);
+ }
+
+ @Test
+ void jacksonXmlUnmarshalListSplit() {
+ String json = "<list><pojo dummyString=\"value1\"/><pojo
dummyString=\"value2\"/></list>";
+ DummyObject testPojo = new DummyObject();
+ testPojo.setDummyString("value1");
+ DummyObject testPojo1 = new DummyObject();
+ testPojo1.setDummyString("value2");
+ List<DummyObject> list = new ArrayList<DummyObject>();
+ list.add(testPojo);
+ list.add(testPojo1);
+ String listJson = JsonbBuilder.create().toJson(list);
+ RestAssured.given()
+ .contentType("text/xml")
+ .body(json)
+ .post("/dataformats-json/jacksonxml/unmarshal-listsplit")
+ .then()
+ .statusCode(200)
+ .body(equalTo(listJson));
+ await().atMost(10, TimeUnit.SECONDS).until(() -> {
+ List<DummyObject> records = RestAssured.given()
+ .contentType("text/xml")
+ .body(json)
+ .post("/dataformats-json/jacksonxml/unmarshal-listsplit")
+ .then()
+ .statusCode(200)
+ .extract().as(List.class);
+
+ return records.size() == 2;
+ });
+
+ }
+
+ @Test
+ void jacksonXmlMarshalIncludeDefault() {
+ RestAssured.get("/dataformats-json/jacksonxml/marshal-includedefault")
+ .then()
+ .statusCode(200)
+
.body(equalTo("<TestOtherPojo><name>Camel</name><country/></TestOtherPojo>"));
+ }
+
+ @Test
+ void jacksonXmlMarshalContentTypeHeader() {
+
RestAssured.get("/dataformats-json/jacksonxml/marshal-contenttype-header")
+ .then()
+ .statusCode(204);
+
+ }
+
+ @Test
+ void jacksonXmlMarshalGeneral() {
+ RestAssured.get("/dataformats-json/jacksonxml/marshal-general")
+ .then()
+ .statusCode(204);
+
+ }
+
+ @Test
+ void jacksonXmlMarshalAllowJmsType() {
+ RestAssured.get("/dataformats-json/jacksonxml/marshal-allowjmstype")
+ .then()
+ .statusCode(204);
+
+ }
+
+ @Test
+ void jacksonXmlMarshalModule() {
+ RestAssured.get("/dataformats-json/jacksonxml/marshal-module")
+ .then()
+ .statusCode(204);
+
+ }
+
+ @Test
+ void jacksonXmlUnmarshalSpringList() {
+ RestAssured.get("/dataformats-json/jacksonxml/unmarshal-springlist")
+ .then()
+ .statusCode(204);
+
+ }
+
+ @Test
+ void jacksonXmlMarshalSpringEnableFeature() {
+
RestAssured.get("/dataformats-json/jacksonxml/marshal-spring-enablefeature")
+ .then()
+ .statusCode(204);
+
+ }
+
+ @Test
+ void jacksonXmlMarshalConcurrent() {
+ RestAssured.get("/dataformats-json/jacksonxml/marshal-concurrent")
+ .then()
+ .statusCode(204);
+
+ }
+
+ @Test
+ void jacksonXmlMarshalConversion() {
+ RestAssured.get("/dataformats-json/jacksonxml/marshal-conversion")
+ .then()
+ .statusCode(204);
+
+ }
+
+ @Test
+ void jacksonXmlUnmarshalListJackson() {
+ RestAssured.get("/dataformats-json/jacksonxml/unmarshal-listjackson")
+ .then()
+ .statusCode(204);
+
+ }
+
+ @Test
+ void jacksonXmlSpringJackson() {
+ RestAssured.get("/dataformats-json/jacksonxml/springjackson")
+ .then()
+ .statusCode(204);
+
+ }
+
+ @Test
+ void jacksonXmlJacksonConversion() {
+ RestAssured.get("/dataformats-json/jacksonxml/jackson-conversion")
+ .then()
+ .statusCode(204);
+
+ }
+
+ @Test
+ void jacksonXmlJaxbAnnotation() {
+ RestAssured.get("/dataformats-json/jacksonxml/jaxb-annotation")
+ .then()
+ .statusCode(204);
+
+ }
+
+ @Test
+ void jacksonXmlJsonView() {
+ RestAssured.get("/dataformats-json/jacksonxml/jsonview")
+ .then()
+ .statusCode(204);
+
+ }
+
+ @Test
+ void jacksonXmlModuleRef() {
+ RestAssured.get("/dataformats-json/jacksonxml/moduleref")
+ .then()
+ .statusCode(204);
+
+ }
+
+ @Test
+ void jacksonXmlIncludeNoNull() {
+ RestAssured.get("/dataformats-json/jacksonxml/include-no-null")
+ .then()
+ .statusCode(204);
+
+ }
+
+ @Test
+ void jacksonXmlTypeHeaderNotAllowed() {
+ RestAssured.get("/dataformats-json/jacksonxml/typeheader-not-allowed")
+ .then()
+ .statusCode(204);
+
+ }
+
+ @Test
+ void jacksonXmlDateTimezone() {
+ RestAssured.get("/dataformats-json/jacksonxml/datetimezone")
+ .then()
+ .statusCode(204);
+
+ }
+
+}
diff --git
a/integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/json/JsonComponentsTest.java
b/integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/json/JsonComponentsTest.java
index 8404431..a0676bc 100644
---
a/integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/json/JsonComponentsTest.java
+++
b/integration-tests/dataformats-json/src/test/java/org/apache/camel/quarkus/component/dataformats/json/JsonComponentsTest.java
@@ -121,5 +121,7 @@ public class JsonComponentsTest {
.then()
.statusCode(200)
.body(equalTo(json));
+
}
+
}