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-spring-boot.git
The following commit(s) were added to refs/heads/main by this push:
new f16b7e3 [CAMEL-17804]add tests in camel-jacksonxml-starter (#470)
f16b7e3 is described below
commit f16b7e34202476ec46c4143f6c8963232f75b7be
Author: Freeman(Yue) Fang <[email protected]>
AuthorDate: Wed Mar 16 12:15:17 2022 -0400
[CAMEL-17804]add tests in camel-jacksonxml-starter (#470)
(cherry picked from commit 81e868a80a3415b5b30ee3a80d05891a3ff4ea24)
---
.../springboot/JacksonConcurrentTest.java | 125 +++++++++++++++
.../springboot/JacksonConversionsSimpleTest.java | 103 ++++++++++++
.../springboot/JacksonConversionsTest.java | 112 +++++++++++++
.../springboot/JacksonIncludeDefaultTest.java | 98 ++++++++++++
.../springboot/JacksonIncludeNotNulllTest.java | 103 ++++++++++++
.../springboot/JacksonJAXBAnnotationTest.java | 117 ++++++++++++++
.../springboot/JacksonJsonDataFormatTest.java | 76 +++++++++
.../springboot/JacksonMarshalAllowJMSTypeTest.java | 106 +++++++++++++
.../JacksonMarshalContentTypeHeaderTest.java | 133 ++++++++++++++++
.../springboot/JacksonMarshalDateTimezoneTest.java | 110 +++++++++++++
.../jacksonxml/springboot/JacksonMarshalTest.java | 167 +++++++++++++++++++
.../JacksonMarshalUnmarshalListTest.java | 136 ++++++++++++++++
...onMarshalUnmarshalTypeHeaderNotAllowedTest.java | 100 ++++++++++++
.../JacksonMarshalUnmarshalTypeHeaderTest.java | 110 +++++++++++++
.../springboot/JacksonMarshalViewTest.java | 131 +++++++++++++++
.../springboot/JacksonModuleRefTest.java | 80 ++++++++++
.../jacksonxml/springboot/JacksonModuleTest.java | 107 +++++++++++++
.../springboot/JacksonObjectListSplitTest.java | 111 +++++++++++++
.../springboot/ListJacksonUnmarshalDTest.java | 71 +++++++++
.../component/jacksonxml/springboot/MyModule.java | 45 ++++++
.../springboot/SpringJacksonEnableFeatureTest.java | 82 ++++++++++
.../SpringJacksonMarshalUnmarshalListTest.java | 113 +++++++++++++
.../springboot/SpringJacksonXmlDataFormatTest.java | 176 +++++++++++++++++++++
.../jacksonxml/springboot/TestJAXBPojo.java | 50 ++++++
.../jacksonxml/springboot/TestOtherPojo.java | 40 +++++
.../component/jacksonxml/springboot/TestPojo.java | 45 ++++++
.../jacksonxml/springboot/TestPojoView.java | 85 ++++++++++
.../component/jacksonxml/springboot/Views.java | 28 ++++
.../routes/SpringJacksonEnableFeatureTest.xml | 29 ++++
.../SpringJacksonMarshalUnmarshalListTest.xml | 27 ++++
.../routes/SpringJacksonXmlDataFormatTest.xml | 61 +++++++
31 files changed, 2877 insertions(+)
diff --git
a/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonConcurrentTest.java
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonConcurrentTest.java
new file mode 100644
index 0000000..000d6a9
--- /dev/null
+++
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonConcurrentTest.java
@@ -0,0 +1,125 @@
+/*
+ * 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.component.jacksonxml.springboot;
+
+
+import static org.apache.camel.test.junit5.TestSupport.body;
+
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+import org.junit.jupiter.api.Test;
+
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.annotation.DirtiesContext.ClassMode;
+
+
+
+@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ JacksonConcurrentTest.class,
+ JacksonConcurrentTest.TestConfiguration.class
+ }
+)
+
+public class JacksonConcurrentTest {
+
+
+ @Autowired
+ private CamelContext context;
+
+ @Autowired
+ @Produce("direct:start")
+ ProducerTemplate template;
+
+ @EndpointInject("mock:result")
+ MockEndpoint mock;
+
+ @Test
+ public void testNoConcurrentProducers() throws Exception {
+ doSendMessages(1, 1);
+ }
+
+ @Test
+ public void testConcurrentProducers() throws Exception {
+ doSendMessages(10, 5);
+ }
+
+ private void doSendMessages(int files, int poolSize) throws Exception {
+ mock.expectedMessageCount(files);
+ mock.assertNoDuplicates(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);
+
+ template.sendBody("direct:start", pojo);
+ return null;
+ }
+ });
+ }
+ MockEndpoint.assertIsSatisfied(context);
+ executor.shutdownNow();
+ }
+
+ @Configuration
+ public class TestConfiguration {
+
+
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+
from("direct:start").marshal().jacksonXml().to("log:marshalled").to("direct:marshalled");
+
+
from("direct:marshalled").unmarshal().jacksonXml(TestPojo.class).to("mock:result");
+ }
+ };
+ }
+
+
+ }
+
+
+
+
+}
diff --git
a/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonConversionsSimpleTest.java
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonConversionsSimpleTest.java
new file mode 100644
index 0000000..bbe6c45
--- /dev/null
+++
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonConversionsSimpleTest.java
@@ -0,0 +1,103 @@
+/*
+ * 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.component.jacksonxml.springboot;
+
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.jacksonxml.JacksonXMLConstants;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.spring.boot.CamelContextConfiguration;
+import org.apache.camel.support.DefaultExchange;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.annotation.DirtiesContext.ClassMode;
+
+
+
+@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ JacksonConversionsSimpleTest.class,
+ }
+)
+
+public class JacksonConversionsSimpleTest {
+
+
+ @Autowired
+ private CamelContext context;
+
+
+ @Bean
+ CamelContextConfiguration contextConfiguration() {
+ return new CamelContextConfiguration() {
+ @Override
+ public void beforeApplicationStart(CamelContext context) {
+
context.getGlobalOptions().put(JacksonXMLConstants.ENABLE_TYPE_CONVERTER,
"true");
+ }
+ @Override
+ public void afterApplicationStart(CamelContext camelContext) {
+ //do nothing here
+ }
+
+ };
+ }
+
+ @Test
+ public void shouldNotConvertMapToString() {
+ Exchange exchange = new DefaultExchange(context);
+
+ 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);
+ }
+
+ @Test
+ public void shouldNotConvertMapToNumber() {
+ Exchange exchange = new DefaultExchange(context);
+
+ Object convertedObject =
context.getTypeConverter().convertTo(Long.class, exchange, new HashMap<String,
String>());
+ assertNull(convertedObject);
+ }
+
+ @Test
+ public void shouldNotConvertMapToPrimitive() {
+ Exchange exchange = new DefaultExchange(context);
+ Object convertedObject =
context.getTypeConverter().convertTo(long.class, exchange, new HashMap<String,
String>());
+
+ assertNull(convertedObject);
+ }
+
+
+}
diff --git
a/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonConversionsTest.java
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonConversionsTest.java
new file mode 100644
index 0000000..9e51f59
--- /dev/null
+++
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonConversionsTest.java
@@ -0,0 +1,112 @@
+/*
+ * 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.component.jacksonxml.springboot;
+
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.jacksonxml.JacksonXMLConstants;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.spring.boot.CamelContextConfiguration;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.annotation.DirtiesContext.ClassMode;
+
+
+
+@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ JacksonConversionsTest.class,
+ JacksonConversionsTest.TestConfiguration.class
+ }
+)
+
+public class JacksonConversionsTest {
+
+
+
+ @Autowired
+ ProducerTemplate template;
+
+
+ @Bean
+ CamelContextConfiguration contextConfiguration() {
+ return new CamelContextConfiguration() {
+ @Override
+ public void beforeApplicationStart(CamelContext context) {
+
context.getGlobalOptions().put(JacksonXMLConstants.ENABLE_TYPE_CONVERTER,
"true");
+ }
+ @Override
+ public void afterApplicationStart(CamelContext camelContext) {
+ //do nothing here
+ }
+
+ };
+ }
+
+ @Test
+ public void shouldConvertMapToPojo() {
+ String name = "someName";
+ Map<String, String> pojoAsMap = new HashMap<>();
+ pojoAsMap.put("name", name);
+
+ TestPojo testPojo = (TestPojo) template.requestBody("direct:test",
pojoAsMap);
+
+ assertEquals(name, testPojo.getName());
+ }
+
+
+ @Configuration
+ public class TestConfiguration {
+
+
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+
+ from("direct:test").convertBodyTo(TestPojo.class);
+ }
+ };
+ }
+
+
+ }
+
+
+
+
+}
diff --git
a/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonIncludeDefaultTest.java
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonIncludeDefaultTest.java
new file mode 100644
index 0000000..8af7eba
--- /dev/null
+++
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonIncludeDefaultTest.java
@@ -0,0 +1,98 @@
+/*
+ * 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.component.jacksonxml.springboot;
+
+
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.jacksonxml.JacksonXMLDataFormat;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+import org.junit.jupiter.api.Test;
+
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.annotation.DirtiesContext.ClassMode;
+
+
+
+@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ JacksonIncludeDefaultTest.class,
+ JacksonIncludeDefaultTest.TestConfiguration.class
+ }
+)
+
+public class JacksonIncludeDefaultTest {
+
+ @Autowired
+ @Produce("direct:start")
+ ProducerTemplate template;
+
+ @EndpointInject("mock:marshal")
+ MockEndpoint mock;
+
+ @Test
+ public void testMmarshalPojo() throws Exception {
+
+ mock.expectedMessageCount(1);
+
mock.message(0).body(String.class).isEqualTo("<TestOtherPojo><name>Camel</name><country/></TestOtherPojo>");
+
+ TestOtherPojo pojo = new TestOtherPojo();
+ pojo.setName("Camel");
+
+ template.sendBody("direct:marshal", pojo);
+
+ mock.assertIsSatisfied();
+ }
+
+ @Configuration
+ public class TestConfiguration {
+
+
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ JacksonXMLDataFormat format = new JacksonXMLDataFormat();
+
+ from("direct:marshal").marshal(format).to("mock:marshal");
+ }
+ };
+ }
+
+
+ }
+
+
+
+
+}
diff --git
a/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonIncludeNotNulllTest.java
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonIncludeNotNulllTest.java
new file mode 100644
index 0000000..faaf841
--- /dev/null
+++
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonIncludeNotNulllTest.java
@@ -0,0 +1,103 @@
+/*
+ * 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.component.jacksonxml.springboot;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.jacksonxml.JacksonXMLDataFormat;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+import org.junit.jupiter.api.Test;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.annotation.DirtiesContext.ClassMode;
+
+
+
+@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ JacksonIncludeNotNulllTest.class,
+ JacksonIncludeNotNulllTest.TestConfiguration.class
+ }
+)
+
+public class JacksonIncludeNotNulllTest {
+
+
+ @Autowired
+ private CamelContext camelContext;
+
+ @Autowired
+ @Produce("direct:start")
+ ProducerTemplate template;
+
+ @EndpointInject("mock:marshal")
+ MockEndpoint mock;
+
+ @Test
+ public void testMmarshalPojo() throws Exception {
+
+ mock.expectedMessageCount(1);
+
mock.message(0).body(String.class).isEqualTo("<TestOtherPojo><name>Camel</name></TestOtherPojo>");
+
+ TestOtherPojo pojo = new TestOtherPojo();
+ pojo.setName("Camel");
+
+ template.sendBody("direct:marshal", pojo);
+
+ MockEndpoint.assertIsSatisfied(camelContext);
+ }
+
+
+
+ @Configuration
+ public class TestConfiguration {
+
+
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ JacksonXMLDataFormat format = new JacksonXMLDataFormat();
+ format.setInclude("NON_NULL");
+
+ from("direct:marshal").marshal(format).to("mock:marshal");
+ }
+ };
+ }
+
+
+ }
+
+
+
+
+}
diff --git
a/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonJAXBAnnotationTest.java
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonJAXBAnnotationTest.java
new file mode 100644
index 0000000..e833031
--- /dev/null
+++
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonJAXBAnnotationTest.java
@@ -0,0 +1,117 @@
+/*
+ * 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.component.jacksonxml.springboot;
+
+
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.jacksonxml.JacksonXMLDataFormat;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.annotation.DirtiesContext.ClassMode;
+
+
+
+@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ JacksonJAXBAnnotationTest.class,
+ JacksonJAXBAnnotationTest.TestConfiguration.class
+ }
+)
+
+public class JacksonJAXBAnnotationTest {
+
+
+ @Autowired
+ private CamelContext context;
+
+ @Autowired
+ @Produce("direct:start")
+ ProducerTemplate template;
+
+ @EndpointInject("mock:reversePojo")
+ MockEndpoint mock;
+
+ @Test
+ public void testMarshalJAXBObject() throws Exception {
+ TestJAXBPojo in = new TestJAXBPojo();
+ in.setName("Camel");
+
+ mock.expectedMessageCount(1);
+ mock.message(0).body().isInstanceOf(TestJAXBPojo.class);
+ mock.message(0).body().isEqualTo(in);
+
+ Object marshalled = template.requestBody("direct:inPojo", in);
+ String marshalledAsString =
context.getTypeConverter().convertTo(String.class, marshalled);
+ assertEquals("<XMLPojo><PojoName>Camel</PojoName></XMLPojo>",
marshalledAsString);
+
+ template.sendBody("direct:backPojo", marshalled);
+
+ mock.assertIsSatisfied();
+ }
+
+
+ @Configuration
+ public class TestConfiguration {
+
+
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+
+ JacksonXMLDataFormat format = new JacksonXMLDataFormat();
+
+ from("direct:in").marshal(format);
+ from("direct:back").unmarshal(format).to("mock:reverse");
+
+ JacksonXMLDataFormat formatPojo = new
JacksonXMLDataFormat(TestJAXBPojo.class);
+
+ from("direct:inPojo").marshal(formatPojo);
+
from("direct:backPojo").unmarshal(formatPojo).to("mock:reversePojo");
+
+ }
+ };
+ }
+
+
+ }
+
+
+
+
+}
diff --git
a/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonJsonDataFormatTest.java
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonJsonDataFormatTest.java
new file mode 100644
index 0000000..523ebc2
--- /dev/null
+++
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonJsonDataFormatTest.java
@@ -0,0 +1,76 @@
+/*
+ * 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.component.jacksonxml.springboot;
+
+
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.annotation.DirtiesContext.ClassMode;
+
+
+
+@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ JacksonJsonDataFormatTest.class,
+ JacksonJsonDataFormatTest.TestConfiguration.class
+ }
+)
+
+public class JacksonJsonDataFormatTest extends JacksonMarshalTest {
+
+
+
+ @Configuration
+ public class TestConfiguration {
+
+
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:in").marshal().jacksonXml();
+
from("direct:back").unmarshal().jacksonXml().to("mock:reverse");
+
+ from("direct:inPretty").marshal().jacksonXml(true);
+
from("direct:backPretty").unmarshal().jacksonXml().to("mock:reverse");
+
+ from("direct:inPojo").marshal().jacksonXml();
+
from("direct:backPojo").unmarshal().jacksonXml(TestPojo.class).to("mock:reversePojo");
+ }
+ };
+ }
+
+
+ }
+
+
+
+
+}
diff --git
a/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonMarshalAllowJMSTypeTest.java
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonMarshalAllowJMSTypeTest.java
new file mode 100644
index 0000000..7715a4f
--- /dev/null
+++
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonMarshalAllowJMSTypeTest.java
@@ -0,0 +1,106 @@
+/*
+ * 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.component.jacksonxml.springboot;
+
+
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.jacksonxml.JacksonXMLDataFormat;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.annotation.DirtiesContext.ClassMode;
+
+
+
+@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ JacksonMarshalAllowJMSTypeTest.class,
+ JacksonMarshalAllowJMSTypeTest.TestConfiguration.class
+ }
+)
+
+public class JacksonMarshalAllowJMSTypeTest {
+
+
+
+ @Autowired
+ @Produce("direct:start")
+ ProducerTemplate template;
+
+ @EndpointInject("mock:reversePojo")
+ MockEndpoint mock;
+
+ @Test
+ public void testUnmarshalPojo() throws Exception {
+
+ mock.expectedMessageCount(1);
+ mock.message(0).body().isInstanceOf(TestPojo.class);
+
+ String json = "<pojo name=\"Camel\"/>";
+ template.sendBodyAndHeader("direct:backPojo", json, "JMSType",
TestPojo.class.getName());
+
+ mock.assertIsSatisfied();
+
+ TestPojo pojo =
mock.getReceivedExchanges().get(0).getIn().getBody(TestPojo.class);
+ assertNotNull(pojo);
+ assertEquals("Camel", pojo.getName());
+ }
+
+
+ @Configuration
+ public class TestConfiguration {
+
+
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ JacksonXMLDataFormat format = new JacksonXMLDataFormat();
+ format.setAllowJmsType(true);
+
+
from("direct:backPojo").unmarshal(format).to("mock:reversePojo");
+ }
+ };
+ }
+
+
+ }
+
+
+
+
+}
diff --git
a/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonMarshalContentTypeHeaderTest.java
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonMarshalContentTypeHeaderTest.java
new file mode 100644
index 0000000..d73a962
--- /dev/null
+++
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonMarshalContentTypeHeaderTest.java
@@ -0,0 +1,133 @@
+/*
+ * 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.component.jacksonxml.springboot;
+
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Exchange;
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.jacksonxml.JacksonXMLDataFormat;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+import org.junit.jupiter.api.Test;
+
+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;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.annotation.DirtiesContext.ClassMode;
+
+
+
+@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ JacksonMarshalContentTypeHeaderTest.class,
+ JacksonMarshalContentTypeHeaderTest.TestConfiguration.class
+ }
+)
+
+public class JacksonMarshalContentTypeHeaderTest {
+
+ @Autowired
+ @Produce("direct:start")
+ ProducerTemplate template;
+
+ @EndpointInject("mock:reversePojo")
+ MockEndpoint mock;
+
+ @Test
+ public void testYes() throws Exception {
+ final Map<String, Object> in = new HashMap<>();
+ in.put("name", "Camel");
+
+ Exchange out = template.request("direct:yes", exchange ->
exchange.getIn().setBody(in));
+
+ assertNotNull(out);
+ assertTrue(out.hasOut());
+ assertEquals("application/xml",
out.getMessage().getHeader(Exchange.CONTENT_TYPE));
+ }
+
+ @Test
+ public void testYes2() throws Exception {
+ final Map<String, Object> in = new HashMap<>();
+ in.put("name", "Camel");
+
+ Exchange out = template.request("direct:yes2", exchange ->
exchange.getIn().setBody(in));
+
+ assertNotNull(out);
+ assertTrue(out.hasOut());
+ assertEquals("application/xml",
out.getMessage().getHeader(Exchange.CONTENT_TYPE));
+ }
+
+ @Test
+ public void testNo() throws Exception {
+ final Map<String, Object> in = new HashMap<>();
+ in.put("name", "Camel");
+
+ Exchange out = template.request("direct:no", exchange ->
exchange.getIn().setBody(in));
+
+ assertNotNull(out);
+ assertTrue(out.hasOut());
+ assertNull(out.getMessage().getHeader(Exchange.CONTENT_TYPE));
+ }
+
+
+ @Configuration
+ public class TestConfiguration {
+
+
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ JacksonXMLDataFormat format = new JacksonXMLDataFormat();
+ from("direct:yes").marshal(format);
+
+ from("direct:yes2").marshal().jacksonXml();
+
+ JacksonXMLDataFormat formatNoHeader = new
JacksonXMLDataFormat();
+ formatNoHeader.setContentTypeHeader(false);
+ from("direct:no").marshal(formatNoHeader);
+ }
+ };
+ }
+
+
+ }
+
+
+
+
+}
diff --git
a/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonMarshalDateTimezoneTest.java
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonMarshalDateTimezoneTest.java
new file mode 100644
index 0000000..cddbdb8
--- /dev/null
+++
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonMarshalDateTimezoneTest.java
@@ -0,0 +1,110 @@
+/*
+ * 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.component.jacksonxml.springboot;
+
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+import java.util.TimeZone;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.jacksonxml.JacksonXMLDataFormat;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.annotation.DirtiesContext.ClassMode;
+
+
+
+@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ JacksonMarshalDateTimezoneTest.class,
+ JacksonMarshalDateTimezoneTest.TestConfiguration.class
+ }
+)
+
+public class JacksonMarshalDateTimezoneTest {
+
+
+ @Autowired
+ private CamelContext camelContext;
+
+ @Autowired
+ @Produce("direct:start")
+ ProducerTemplate template;
+
+ @EndpointInject("mock:result")
+ MockEndpoint mock;
+
+ @Test
+ public void testMarshalDate() throws Exception {
+ TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
+ GregorianCalendar in = new GregorianCalendar(2017, Calendar.APRIL, 25,
17, 0, 10);
+
+
+ Object marshalled = template.requestBody("direct:in", in.getTime());
+ String marshalledAsString =
camelContext.getTypeConverter().convertTo(String.class, marshalled);
+ assertEquals("<Date>1493139610000</Date>", marshalledAsString);
+
+ mock.expectedMessageCount(1);
+
+ mock.assertIsSatisfied();
+ }
+
+
+ @Configuration
+ public class TestConfiguration {
+
+
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ JacksonXMLDataFormat format = new JacksonXMLDataFormat();
+ TimeZone timeZone =
TimeZone.getTimeZone("Africa/Ouagadougou");
+ format.setTimezone(timeZone);
+
+ from("direct:in").marshal(format).to("mock:result");
+ }
+ };
+ }
+
+
+ }
+
+
+
+
+}
diff --git
a/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonMarshalTest.java
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonMarshalTest.java
new file mode 100644
index 0000000..a834258
--- /dev/null
+++
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonMarshalTest.java
@@ -0,0 +1,167 @@
+/*
+ * 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.component.jacksonxml.springboot;
+
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.jacksonxml.JacksonXMLDataFormat;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.annotation.DirtiesContext.ClassMode;
+
+
+
+@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ JacksonMarshalTest.class,
+ JacksonMarshalTest.TestConfiguration.class
+ }
+)
+
+public class JacksonMarshalTest {
+
+ private static final String LS = System.lineSeparator();
+
+ @Autowired
+ private CamelContext context;
+
+ @Autowired
+ @Produce("direct:start")
+ ProducerTemplate template;
+
+ @EndpointInject("mock:reverse")
+ MockEndpoint mock;
+
+ @EndpointInject("mock:reversePojo")
+ MockEndpoint mockPojo;
+
+ @Test
+ public void testMarshalAndUnmarshalMap() throws Exception {
+ Map<String, Object> in = new HashMap<>();
+ in.put("name", "Camel");
+
+
+ mock.expectedMessageCount(1);
+ mock.message(0).body().isInstanceOf(Map.class);
+ mock.message(0).body().isEqualTo(in);
+
+ Object marshalled = template.requestBody("direct:in", in);
+ String marshalledAsString =
context.getTypeConverter().convertTo(String.class, marshalled);
+ assertEquals("<HashMap><name>Camel</name></HashMap>",
marshalledAsString);
+
+ template.sendBody("direct:back", marshalled);
+
+ mock.assertIsSatisfied();
+ }
+
+ @Test
+ public void testMarshalAndUnmarshalMapWithPrettyPrint() throws Exception {
+ Map<String, Object> in = new HashMap<>();
+ in.put("name", "Camel");
+
+
+ mock.expectedMessageCount(1);
+ mock.message(0).body().isInstanceOf(Map.class);
+ mock.message(0).body().isEqualTo(in);
+
+ Object marshalled = template.requestBody("direct:inPretty", in);
+ String marshalledAsString =
context.getTypeConverter().convertTo(String.class, marshalled);
+ String expected = "<HashMap>" + LS + " <name>Camel</name>" + LS +
"</HashMap>" + LS;
+ assertEquals(expected, marshalledAsString);
+
+ template.sendBody("direct:backPretty", marshalled);
+
+ mock.assertIsSatisfied();
+ }
+
+ @Test
+ public void testMarshalAndUnmarshalPojo() throws Exception {
+ TestPojo in = new TestPojo();
+ in.setName("Camel");
+
+
+ mockPojo.expectedMessageCount(1);
+ mockPojo.message(0).body().isInstanceOf(TestPojo.class);
+ mockPojo.message(0).body().isEqualTo(in);
+
+ Object marshalled = template.requestBody("direct:inPojo", in);
+ String marshalledAsString =
context.getTypeConverter().convertTo(String.class, marshalled);
+ assertEquals("<TestPojo><name>Camel</name></TestPojo>",
marshalledAsString);
+
+ template.sendBody("direct:backPojo", marshalled);
+
+ mockPojo.assertIsSatisfied();
+ }
+
+ @Configuration
+ public class TestConfiguration {
+
+
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ JacksonXMLDataFormat format = new JacksonXMLDataFormat();
+
+ from("direct:in").marshal(format);
+ from("direct:back").unmarshal(format).to("mock:reverse");
+
+ JacksonXMLDataFormat prettyPrintDataFormat = new
JacksonXMLDataFormat();
+ prettyPrintDataFormat.setPrettyPrint(true);
+
+ from("direct:inPretty").marshal(prettyPrintDataFormat);
+
from("direct:backPretty").unmarshal(prettyPrintDataFormat).to("mock:reverse");
+
+ JacksonXMLDataFormat formatPojo = new
JacksonXMLDataFormat(TestPojo.class);
+
+ from("direct:inPojo").marshal(formatPojo);
+
from("direct:backPojo").unmarshal(formatPojo).to("mock:reversePojo");
+ }
+ };
+ }
+
+
+ }
+
+
+
+
+}
diff --git
a/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonMarshalUnmarshalListTest.java
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonMarshalUnmarshalListTest.java
new file mode 100644
index 0000000..21dac75
--- /dev/null
+++
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonMarshalUnmarshalListTest.java
@@ -0,0 +1,136 @@
+/*
+ * 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.component.jacksonxml.springboot;
+
+
+import java.util.List;
+
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.jacksonxml.JacksonXMLDataFormat;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.annotation.DirtiesContext.ClassMode;
+
+
+
+@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ JacksonMarshalUnmarshalListTest.class,
+ JacksonMarshalUnmarshalListTest.TestConfiguration.class
+ }
+)
+
+public class JacksonMarshalUnmarshalListTest {
+
+
+ @Autowired
+ private CamelContext context;
+
+ @Autowired
+ @Produce("direct:start")
+ ProducerTemplate template;
+
+ @EndpointInject("mock:reversePojo")
+ MockEndpoint mock;
+
+ @Test
+ public void testUnmarshalListPojo() throws Exception {
+
+ mock.expectedMessageCount(1);
+ mock.message(0).body().isInstanceOf(List.class);
+
+ String json = "<list><pojo name=\"Camel\"/><pojo
name=\"World\"/></list>";
+ template.sendBody("direct:backPojo", json);
+
+ MockEndpoint.assertIsSatisfied(context);
+
+ 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());
+ }
+
+ @Test
+ public void testUnmarshalListPojoOneElement() throws Exception {
+
+ mock.expectedMessageCount(1);
+ mock.message(0).body().isInstanceOf(List.class);
+
+ String json = "<list><pojo name=\"Camel\"/></list>";
+ template.sendBody("direct:backPojo", json);
+
+ MockEndpoint.assertIsSatisfied(context);
+
+ List list =
mock.getReceivedExchanges().get(0).getIn().getBody(List.class);
+ assertNotNull(list);
+ assertEquals(1, list.size());
+
+ TestPojo pojo = (TestPojo) list.get(0);
+ assertEquals("Camel", pojo.getName());
+ }
+
+
+ @Configuration
+ public class TestConfiguration {
+
+
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ JacksonXMLDataFormat format = new
JacksonXMLDataFormat(TestPojo.class);
+ format.useList();
+
+
from("direct:backPojo").unmarshal(format).to("mock:reversePojo");
+
+ }
+ };
+ }
+
+
+ }
+
+
+
+
+}
diff --git
a/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonMarshalUnmarshalTypeHeaderNotAllowedTest.java
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonMarshalUnmarshalTypeHeaderNotAllowedTest.java
new file mode 100644
index 0000000..7d12119
--- /dev/null
+++
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonMarshalUnmarshalTypeHeaderNotAllowedTest.java
@@ -0,0 +1,100 @@
+/*
+ * 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.component.jacksonxml.springboot;
+
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.ProducerTemplate;
+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.mock.MockEndpoint;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+import org.junit.jupiter.api.Test;
+
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.annotation.DirtiesContext.ClassMode;
+
+
+
+@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ JacksonMarshalUnmarshalTypeHeaderNotAllowedTest.class,
+ JacksonMarshalUnmarshalTypeHeaderNotAllowedTest.TestConfiguration.class
+ }
+)
+
+public class JacksonMarshalUnmarshalTypeHeaderNotAllowedTest {
+
+
+ @Autowired
+ private CamelContext camelContext;
+
+ @Autowired
+ ProducerTemplate template;
+
+ @EndpointInject("mock:reversePojo")
+ MockEndpoint mock;
+
+ @Test
+ public void testUnmarshalPojo() throws Exception {
+
+ mock.expectedMessageCount(1);
+
+ String xml = "<pojo name=\"Camel\"/>";
+ template.sendBodyAndHeader("direct:backPojo", xml,
JacksonXMLConstants.UNMARSHAL_TYPE, TestPojo.class.getName());
+
+ MockEndpoint.assertIsSatisfied(camelContext);
+ }
+
+
+ @Configuration
+ public class TestConfiguration {
+
+
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ JacksonXMLDataFormat format = new JacksonXMLDataFormat();
+
+
from("direct:backPojo").unmarshal(format).to("mock:reversePojo");
+
+ }
+ };
+ }
+
+
+ }
+
+
+
+
+}
diff --git
a/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonMarshalUnmarshalTypeHeaderTest.java
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonMarshalUnmarshalTypeHeaderTest.java
new file mode 100644
index 0000000..45708cc
--- /dev/null
+++
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonMarshalUnmarshalTypeHeaderTest.java
@@ -0,0 +1,110 @@
+/*
+ * 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.component.jacksonxml.springboot;
+
+
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+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.mock.MockEndpoint;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.annotation.DirtiesContext.ClassMode;
+
+
+
+@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ JacksonMarshalUnmarshalTypeHeaderTest.class,
+ JacksonMarshalUnmarshalTypeHeaderTest.TestConfiguration.class
+ }
+)
+
+public class JacksonMarshalUnmarshalTypeHeaderTest {
+
+
+
+ @Autowired
+ @Produce("direct:start")
+ ProducerTemplate template;
+
+ @EndpointInject("mock:reversePojo")
+ MockEndpoint mock;
+
+ @Test
+ public void testUnmarshalPojo() throws Exception {
+
+ mock.expectedMessageCount(1);
+ mock.message(0).body().isInstanceOf(TestPojo.class);
+
+ String json = "<pojo name=\"Camel\"/>";
+ template.sendBodyAndHeader("direct:backPojo", json,
JacksonXMLConstants.UNMARSHAL_TYPE, TestPojo.class.getName());
+
+
+ mock.assertIsSatisfied();
+
+ TestPojo pojo =
mock.getReceivedExchanges().get(0).getIn().getBody(TestPojo.class);
+ assertNotNull(pojo);
+ assertEquals("Camel", pojo.getName());
+ }
+
+
+
+ @Configuration
+ public class TestConfiguration {
+
+
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ JacksonXMLDataFormat format = new JacksonXMLDataFormat();
+ format.setAllowUnmarshallType(true);
+
+
from("direct:backPojo").unmarshal(format).to("mock:reversePojo");
+
+ }
+ };
+ }
+
+
+ }
+
+
+
+
+}
diff --git
a/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonMarshalViewTest.java
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonMarshalViewTest.java
new file mode 100644
index 0000000..1ee5776
--- /dev/null
+++
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonMarshalViewTest.java
@@ -0,0 +1,131 @@
+/*
+ * 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.component.jacksonxml.springboot;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.annotation.DirtiesContext.ClassMode;
+
+
+
+@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ JacksonMarshalViewTest.class,
+ JacksonMarshalViewTest.TestConfiguration.class
+ }
+)
+
+public class JacksonMarshalViewTest {
+
+
+ @Autowired
+ private CamelContext context;
+
+ @Autowired
+ @Produce("direct:start")
+ ProducerTemplate template;
+
+ @EndpointInject("mock:reversePojoWeightView")
+ MockEndpoint mockWeight;
+
+ @EndpointInject("mock:reversePojoAgeView")
+ MockEndpoint mockAge;
+ @Test
+ public void testMarshalAndUnmarshalPojoWithView() throws Exception {
+
+ TestPojoView in = new TestPojoView();
+
+ mockAge.expectedMessageCount(1);
+ mockAge.message(0).body().isInstanceOf(TestPojoView.class);
+ mockAge.message(0).body().isEqualTo(in);
+
+ Object marshalled = template.requestBody("direct:inPojoAgeView", in);
+ String marshalledAsString =
context.getTypeConverter().convertTo(String.class, marshalled);
+
assertEquals("<TestPojoView><age>30</age><height>190</height></TestPojoView>",
marshalledAsString);
+
+ template.sendBody("direct:backPojoAgeView", marshalled);
+
+ mockAge.assertIsSatisfied();
+ }
+
+ @Test
+ public void testMarshalAndUnmarshalPojoWithAnotherView() throws Exception {
+
+ TestPojoView in = new TestPojoView();
+
+ mockWeight.expectedMessageCount(1);
+ mockWeight.message(0).body().isInstanceOf(TestPojoView.class);
+ mockWeight.message(0).body().isEqualTo(in);
+
+ Object marshalled = template.requestBody("direct:inPojoWeightView",
in);
+ String marshalledAsString =
context.getTypeConverter().convertTo(String.class, marshalled);
+
assertEquals("<TestPojoView><height>190</height><weight>70</weight></TestPojoView>",
marshalledAsString);
+
+ template.sendBody("direct:backPojoWeightView", marshalled);
+
+ mockWeight.assertIsSatisfied();
+ }
+
+
+ @Configuration
+ public class TestConfiguration {
+
+
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+
+ // START SNIPPET: format
+
from("direct:inPojoAgeView").marshal().jacksonXml(TestPojoView.class,
Views.Age.class);
+ // END SNIPPET: format
+
from("direct:backPojoAgeView").unmarshal().jacksonXml(TestPojoView.class).to("mock:reversePojoAgeView");
+
+
from("direct:inPojoWeightView").marshal().jacksonXml(TestPojoView.class,
Views.Weight.class);
+
from("direct:backPojoWeightView").unmarshal().jacksonXml(TestPojoView.class).to("mock:reversePojoWeightView");
+ }
+ };
+ }
+
+
+ }
+
+
+
+
+}
diff --git
a/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonModuleRefTest.java
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonModuleRefTest.java
new file mode 100644
index 0000000..04f4c3c
--- /dev/null
+++
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonModuleRefTest.java
@@ -0,0 +1,80 @@
+/*
+ * 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.component.jacksonxml.springboot;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.jacksonxml.JacksonXMLDataFormat;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+
+
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.annotation.DirtiesContext.ClassMode;
+
+
+
+@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ JacksonModuleRefTest.class,
+ JacksonModuleRefTest.TestConfiguration.class
+ }
+)
+
+public class JacksonModuleRefTest extends JacksonModuleTest {
+
+
+
+
+ @Bean(name = "myJacksonModule")
+ MyModule getMyModule() {
+ return new MyModule();
+ }
+
+
+ @Configuration
+ public class TestConfiguration {
+
+
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ JacksonXMLDataFormat format = new JacksonXMLDataFormat();
+ format.setInclude("NON_NULL");
+ format.setModuleRefs("myJacksonModule");
+
+ from("direct:marshal").marshal(format).to("mock:marshal");
+ }
+ };
+ }
+
+
+ }
+
+
+
+
+}
diff --git
a/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonModuleTest.java
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonModuleTest.java
new file mode 100644
index 0000000..7113a66
--- /dev/null
+++
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonModuleTest.java
@@ -0,0 +1,107 @@
+/*
+ * 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.component.jacksonxml.springboot;
+
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.jacksonxml.JacksonXMLDataFormat;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+import org.junit.jupiter.api.Test;
+
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.annotation.DirtiesContext.ClassMode;
+
+
+
+@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ JacksonModuleTest.class,
+ JacksonModuleTest.TestConfiguration.class
+ }
+)
+
+public class JacksonModuleTest {
+
+
+ @Autowired
+ private CamelContext camelContext;
+
+ @Autowired
+ @Produce("direct:start")
+ ProducerTemplate template;
+
+ @EndpointInject("mock:marshal")
+ MockEndpoint mock;
+
+ @Test
+ public void testCustomModule() throws Exception {
+
+ 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");
+
+ template.sendBody("direct:marshal", pojo);
+
+ MockEndpoint.assertIsSatisfied(camelContext);
+ }
+
+
+ @Configuration
+ public class TestConfiguration {
+
+
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ JacksonXMLDataFormat format = new JacksonXMLDataFormat();
+ format.setInclude("NON_NULL");
+
format.setModuleClassNames("org.apache.camel.component.jacksonxml.springboot.MyModule");
+
+ from("direct:marshal").marshal(format).to("mock:marshal");
+ }
+ };
+ }
+
+
+ }
+
+
+
+
+}
diff --git
a/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonObjectListSplitTest.java
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonObjectListSplitTest.java
new file mode 100644
index 0000000..580aedd
--- /dev/null
+++
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/JacksonObjectListSplitTest.java
@@ -0,0 +1,111 @@
+/*
+ * 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.component.jacksonxml.springboot;
+
+
+import static org.apache.camel.test.junit5.TestSupport.body;
+
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.jacksonxml.JacksonXMLDataFormat;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+import org.junit.jupiter.api.Test;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.annotation.DirtiesContext.ClassMode;
+
+
+
+@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ JacksonObjectListSplitTest.class,
+ JacksonObjectListSplitTest.TestConfiguration.class
+ }
+)
+
+public class JacksonObjectListSplitTest {
+
+
+ @Autowired
+ ProducerTemplate template;
+
+ @EndpointInject("mock:result")
+ MockEndpoint mock;
+
+ @Test
+ public void testJackson() throws InterruptedException {
+ mock.expectedMessageCount(2);
+ mock.expectedMessagesMatches(body().isInstanceOf(DummyObject.class));
+
+ template.sendBody("direct:start", "<list><pojo dummy=\"value1\"/><pojo
dummy=\"value2\"/></list>");
+
+ mock.assertIsSatisfied();
+ }
+
+
+ @Configuration
+ public class TestConfiguration {
+
+
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ // you can specify the pojo class type for unmarshal the
jason file
+ JacksonXMLDataFormat format = new
JacksonXMLDataFormat(DummyObject.class);
+ format.useList();
+
from("direct:start").unmarshal(format).split(body()).to("mock:result");
+ }
+ };
+ }
+
+
+ }
+
+ public static class DummyObject {
+
+ private String dummy;
+
+ public DummyObject() {
+ }
+
+ public String getDummy() {
+ return dummy;
+ }
+
+ public void setDummy(String dummy) {
+ this.dummy = dummy;
+ }
+ }
+
+
+
+}
diff --git
a/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/ListJacksonUnmarshalDTest.java
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/ListJacksonUnmarshalDTest.java
new file mode 100644
index 0000000..f767f83
--- /dev/null
+++
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/ListJacksonUnmarshalDTest.java
@@ -0,0 +1,71 @@
+/*
+ * 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.component.jacksonxml.springboot;
+
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.jacksonxml.ListJacksonXMLDataFormat;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.annotation.DirtiesContext.ClassMode;
+
+
+
+@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ ListJacksonUnmarshalDTest.class,
+ ListJacksonUnmarshalDTest.TestConfiguration.class
+ }
+)
+
+public class ListJacksonUnmarshalDTest extends JacksonMarshalUnmarshalListTest
{
+
+
+
+
+
+ @Configuration
+ public class TestConfiguration {
+
+
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+
+ from("direct:backPojo").unmarshal(new
ListJacksonXMLDataFormat(TestPojo.class)).to("mock:reversePojo");
+ }
+ };
+ }
+
+
+ }
+
+
+
+
+}
diff --git
a/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/MyModule.java
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/MyModule.java
new file mode 100644
index 0000000..53ffac8
--- /dev/null
+++
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/MyModule.java
@@ -0,0 +1,45 @@
+/*
+ * 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.component.jacksonxml.springboot;
+
+import com.fasterxml.jackson.core.Version;
+import com.fasterxml.jackson.databind.Module;
+import com.fasterxml.jackson.databind.PropertyNamingStrategy;
+
+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/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/SpringJacksonEnableFeatureTest.java
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/SpringJacksonEnableFeatureTest.java
new file mode 100644
index 0000000..0c4764f
--- /dev/null
+++
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/SpringJacksonEnableFeatureTest.java
@@ -0,0 +1,82 @@
+/*
+ * 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.component.jacksonxml.springboot;
+
+
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.jacksonxml.JacksonXMLDataFormat;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.annotation.DirtiesContext.ClassMode;
+
+
+
+@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ SpringJacksonEnableFeatureTest.class,
+ },
+ properties = {
+
"camel.springboot.routes-include-pattern=file:src/test/resources/routes/SpringJacksonEnableFeatureTest.xml"}
+)
+
+public class SpringJacksonEnableFeatureTest {
+
+
+ @Autowired
+ private CamelContext context;
+
+ @Autowired
+ @Produce("direct:start")
+ ProducerTemplate template;
+
+
+
+ @Test
+ public void testMarshal() throws Exception {
+ TestPojoView in = new TestPojoView();
+
+ Object marshalled = template.requestBody("direct:in", 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);
+ }
+
+ @Bean(name = "jack")
+ JacksonXMLDataFormat getViewJsonDataFormat() {
+ JacksonXMLDataFormat xmlDataformat = new JacksonXMLDataFormat();
+
+
xmlDataformat.setUnmarshalTypeName("org.apache.camel.component.jacksonxml.springboot.TestPojo");
+ xmlDataformat.setEnableFeatures("WRAP_ROOT_VALUE");
+ return xmlDataformat;
+ }
+
+}
diff --git
a/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/SpringJacksonMarshalUnmarshalListTest.java
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/SpringJacksonMarshalUnmarshalListTest.java
new file mode 100644
index 0000000..cf15970
--- /dev/null
+++
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/SpringJacksonMarshalUnmarshalListTest.java
@@ -0,0 +1,113 @@
+/*
+ * 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.component.jacksonxml.springboot;
+
+
+import java.util.List;
+
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.jacksonxml.JacksonXMLDataFormat;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.annotation.DirtiesContext.ClassMode;
+
+
+
+@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ SpringJacksonMarshalUnmarshalListTest.class,
+ },
+ properties = {
+
"camel.springboot.routes-include-pattern=file:src/test/resources/routes/SpringJacksonMarshalUnmarshalListTest.xml"}
+)
+
+public class SpringJacksonMarshalUnmarshalListTest {
+
+ @Autowired
+ @Produce("direct:start")
+ ProducerTemplate template;
+
+ @EndpointInject("mock:reversePojo")
+ MockEndpoint mock;
+
+ @Test
+ public void testUnmarshalListPojo() throws Exception {
+ mock.expectedMessageCount(1);
+ mock.message(0).body().isInstanceOf(List.class);
+
+ String xml = "<list><pojo name=\"Camel\"/><pojo
name=\"World\"/></list>";
+ template.sendBody("direct:backPojo", xml);
+
+ 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());
+ }
+
+ @Test
+ public void testUnmarshalListPojoOneElement() throws Exception {
+
+ mock.expectedMessageCount(1);
+ mock.message(0).body().isInstanceOf(List.class);
+
+ String xml = "<list><pojo name=\"Camel\"/></list>";
+ template.sendBody("direct:backPojo", xml);
+
+ mock.assertIsSatisfied();
+
+ List list =
mock.getReceivedExchanges().get(0).getIn().getBody(List.class);
+ assertNotNull(list);
+ assertEquals(1, list.size());
+
+ TestPojo pojo = (TestPojo) list.get(0);
+ assertEquals("Camel", pojo.getName());
+ }
+
+ @Bean(name = "pojo")
+ JacksonXMLDataFormat getPojoJsonDataFormat() {
+ JacksonXMLDataFormat xmlDataformat = new JacksonXMLDataFormat();
+ xmlDataformat.setUseList(true);
+
xmlDataformat.setUnmarshalTypeName("org.apache.camel.component.jacksonxml.springboot.TestPojo");
+ return xmlDataformat;
+ }
+
+
+
+}
diff --git
a/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/SpringJacksonXmlDataFormatTest.java
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/SpringJacksonXmlDataFormatTest.java
new file mode 100644
index 0000000..0ad374f
--- /dev/null
+++
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/SpringJacksonXmlDataFormatTest.java
@@ -0,0 +1,176 @@
+/*
+ * 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.component.jacksonxml.springboot;
+
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.jacksonxml.JacksonXMLDataFormat;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.annotation.DirtiesContext.ClassMode;
+
+
+
+@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ SpringJacksonXmlDataFormatTest.class,
+ },
+ properties = {
+
"camel.springboot.routes-include-pattern=file:src/test/resources/routes/SpringJacksonXmlDataFormatTest.xml"}
+)
+
+public class SpringJacksonXmlDataFormatTest {
+
+ private static final String LS = System.lineSeparator();
+
+ @Autowired
+ private CamelContext context;
+
+ @Autowired
+ @Produce("direct:start")
+ ProducerTemplate template;
+
+ @EndpointInject("mock:reversePojo")
+ MockEndpoint mockPojo;
+
+ @EndpointInject("mock:reverse")
+ MockEndpoint mock;
+
+ @EndpointInject("mock:reverseAgeView")
+ MockEndpoint mockAge;
+
+ @Test
+ public void testMarshalAndUnmarshalMap() throws Exception {
+ Map<String, Object> in = new HashMap<>();
+ in.put("name", "Camel");
+
+ mock.expectedMessageCount(1);
+ mock.message(0).body().isInstanceOf(Map.class);
+ mock.message(0).body().isEqualTo(in);
+
+ Object marshalled = template.requestBody("direct:in", in);
+ String marshalledAsString =
context.getTypeConverter().convertTo(String.class, marshalled);
+ assertEquals("<HashMap><name>Camel</name></HashMap>",
marshalledAsString);
+
+ template.sendBody("direct:back", marshalled);
+
+ mock.assertIsSatisfied();
+ }
+
+ @Test
+ public void testMarshalAndUnmarshalMapWithPrettyPrint() throws Exception {
+ Map<String, Object> in = new HashMap<>();
+ in.put("name", "Camel");
+
+ mock.expectedMessageCount(1);
+ mock.message(0).body().isInstanceOf(Map.class);
+ mock.message(0).body().isEqualTo(in);
+
+ Object marshalled = template.requestBody("direct:inPretty", in);
+ String marshalledAsString =
context.getTypeConverter().convertTo(String.class, marshalled);
+ String expected = "<HashMap>" + LS + " <name>Camel</name>" + LS +
"</HashMap>" + LS;
+ assertEquals(expected, marshalledAsString);
+
+ template.sendBody("direct:back", marshalled);
+
+ mock.assertIsSatisfied();
+ }
+
+ @Test
+ public void testMarshalAndUnmarshalPojo() throws Exception {
+ TestPojo in = new TestPojo();
+ in.setName("Camel");
+
+
+ mockPojo.expectedMessageCount(1);
+ mockPojo.message(0).body().isInstanceOf(TestPojo.class);
+ mockPojo.message(0).body().isEqualTo(in);
+
+ Object marshalled = template.requestBody("direct:inPojo", in);
+ String marshalledAsString =
context.getTypeConverter().convertTo(String.class, marshalled);
+ assertEquals("<TestPojo><name>Camel</name></TestPojo>",
marshalledAsString);
+
+ template.sendBody("direct:backPojo", marshalled);
+
+ mock.assertIsSatisfied();
+ }
+
+ @Test
+ public void testMarshalAndUnmarshalAgeView() throws Exception {
+ TestPojoView in = new TestPojoView();
+
+
+ mockAge.expectedMessageCount(1);
+ mockAge.message(0).body().isInstanceOf(TestPojoView.class);
+ mockAge.message(0).body().isEqualTo(in);
+
+ Object marshalled = template.requestBody("direct:inAgeView", in);
+ String marshalledAsString =
context.getTypeConverter().convertTo(String.class, marshalled);
+
assertEquals("<TestPojoView><age>30</age><height>190</height></TestPojoView>",
marshalledAsString);
+
+ template.sendBody("direct:backAgeView", marshalled);
+
+ mock.assertIsSatisfied();
+ }
+
+ @Bean(name = "jack")
+ JacksonXMLDataFormat getXmlDataFormat() {
+ return new JacksonXMLDataFormat();
+ }
+
+ @Bean(name = "pretty")
+ JacksonXMLDataFormat getPrettyXmlDataFormat() {
+ JacksonXMLDataFormat xmlDataformat = new JacksonXMLDataFormat();
+ xmlDataformat.setPrettyPrint(true);
+ return xmlDataformat;
+ }
+
+ @Bean(name = "pojo")
+ JacksonXMLDataFormat getPojoXmlDataFormat() {
+ JacksonXMLDataFormat xmlDataformat = new JacksonXMLDataFormat();
+
xmlDataformat.setUnmarshalTypeName("org.apache.camel.component.jacksonxml.springboot.TestPojo");
+ return xmlDataformat;
+ }
+
+ @Bean(name = "view")
+ JacksonXMLDataFormat getViewXmlDataFormat() {
+ JacksonXMLDataFormat xmlDataformat = new JacksonXMLDataFormat();
+
xmlDataformat.setUnmarshalTypeName("org.apache.camel.component.jacksonxml.springboot.TestPojoView");
+
xmlDataformat.setJsonView(org.apache.camel.component.jacksonxml.springboot.Views.Age.class);
+ return xmlDataformat;
+ }
+}
diff --git
a/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/TestJAXBPojo.java
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/TestJAXBPojo.java
new file mode 100644
index 0000000..9c158cf
--- /dev/null
+++
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/TestJAXBPojo.java
@@ -0,0 +1,50 @@
+/*
+ * 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.component.jacksonxml.springboot;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@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/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/TestOtherPojo.java
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/TestOtherPojo.java
new file mode 100644
index 0000000..0eea606
--- /dev/null
+++
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/TestOtherPojo.java
@@ -0,0 +1,40 @@
+/*
+ * 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.component.jacksonxml.springboot;
+
+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/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/TestPojo.java
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/TestPojo.java
new file mode 100644
index 0000000..6db0adb
--- /dev/null
+++
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/TestPojo.java
@@ -0,0 +1,45 @@
+/*
+ * 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.component.jacksonxml.springboot;
+
+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/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/TestPojoView.java
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/TestPojoView.java
new file mode 100644
index 0000000..6a36ede
--- /dev/null
+++
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/TestPojoView.java
@@ -0,0 +1,85 @@
+/*
+ * 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.component.jacksonxml.springboot;
+
+import com.fasterxml.jackson.annotation.JsonView;
+
+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/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/Views.java
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/Views.java
new file mode 100644
index 0000000..d379136
--- /dev/null
+++
b/components-starter/camel-jacksonxml-starter/src/test/java/org/apache/camel/component/jacksonxml/springboot/Views.java
@@ -0,0 +1,28 @@
+/*
+ * 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.component.jacksonxml.springboot;
+
+//START SNIPPET: marker
+public class Views {
+
+ static class Age {
+ }
+
+ static class Weight {
+ }
+}
+//END SNIPPET: marker
diff --git
a/components-starter/camel-jacksonxml-starter/src/test/resources/routes/SpringJacksonEnableFeatureTest.xml
b/components-starter/camel-jacksonxml-starter/src/test/resources/routes/SpringJacksonEnableFeatureTest.xml
new file mode 100644
index 0000000..bc4b850
--- /dev/null
+++
b/components-starter/camel-jacksonxml-starter/src/test/resources/routes/SpringJacksonEnableFeatureTest.xml
@@ -0,0 +1,29 @@
+<?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.
+
+-->
+
+ <routes id="camel" xmlns="http://camel.apache.org/schema/spring">
+
+ <route>
+ <from uri="direct:in"/>
+ <marshal><custom ref="jack"/></marshal>
+ </route>
+
+ </routes>
+
diff --git
a/components-starter/camel-jacksonxml-starter/src/test/resources/routes/SpringJacksonMarshalUnmarshalListTest.xml
b/components-starter/camel-jacksonxml-starter/src/test/resources/routes/SpringJacksonMarshalUnmarshalListTest.xml
new file mode 100644
index 0000000..f89b350
--- /dev/null
+++
b/components-starter/camel-jacksonxml-starter/src/test/resources/routes/SpringJacksonMarshalUnmarshalListTest.xml
@@ -0,0 +1,27 @@
+<?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.
+
+-->
+ <routes id="camel" xmlns="http://camel.apache.org/schema/spring">
+ <route>
+ <from uri="direct:backPojo"/>
+ <unmarshal><custom ref="pojo"/></unmarshal>
+ <to uri="mock:reversePojo"/>
+ </route>
+
+ </routes>
diff --git
a/components-starter/camel-jacksonxml-starter/src/test/resources/routes/SpringJacksonXmlDataFormatTest.xml
b/components-starter/camel-jacksonxml-starter/src/test/resources/routes/SpringJacksonXmlDataFormatTest.xml
new file mode 100644
index 0000000..2adb12a
--- /dev/null
+++
b/components-starter/camel-jacksonxml-starter/src/test/resources/routes/SpringJacksonXmlDataFormatTest.xml
@@ -0,0 +1,61 @@
+<?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.
+
+-->
+
+ <routes id="camel" xmlns="http://camel.apache.org/schema/spring">
+
+ <route>
+ <from uri="direct:in"/>
+ <marshal><custom ref="jack"/></marshal>
+ </route>
+
+ <route>
+ <from uri="direct:inPretty"/>
+ <marshal><custom ref="pretty"/></marshal>
+ </route>
+
+ <route>
+ <from uri="direct:back"/>
+ <unmarshal><custom ref="jack"/></unmarshal>
+ <to uri="mock:reverse"/>
+ </route>
+
+ <route>
+ <from uri="direct:inPojo"/>
+ <marshal><custom ref="pojo"/></marshal>
+ </route>
+
+ <route>
+ <from uri="direct:backPojo"/>
+ <unmarshal><custom ref="pojo"/></unmarshal>
+ <to uri="mock:reversePojo"/>
+ </route>
+
+ <route>
+ <from uri="direct:inAgeView"/>
+ <marshal><custom ref="view"/></marshal>
+ </route>
+
+ <route>
+ <from uri="direct:backAgeView"/>
+ <unmarshal><custom ref="view"/></unmarshal>
+ <to uri="mock:reverseAgeView"/>
+ </route>
+
+ </routes>