You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2016/06/14 08:32:28 UTC

[2/2] camel git commit: Improved Camel-jaxb ObjectFactory property test

Improved Camel-jaxb ObjectFactory property test


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/b70b906e
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/b70b906e
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/b70b906e

Branch: refs/heads/master
Commit: b70b906e5bbdfeb99a702c5d4ab519371a2c0f49
Parents: a400355
Author: Andrea Cosentino <an...@gmail.com>
Authored: Tue Jun 14 10:25:22 2016 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Tue Jun 14 10:32:10 2016 +0200

----------------------------------------------------------------------
 .../jaxb/CamelJaxbFallbackConverterTest.java    | 12 ----
 ...kTypeConverterObjectFactoryDisabledTest.java | 60 ++++++++++++++++++++
 ...ckTypeConverterObjectFactoryEnabledTest.java | 52 +++++++++++++++++
 3 files changed, 112 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/b70b906e/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/CamelJaxbFallbackConverterTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/CamelJaxbFallbackConverterTest.java b/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/CamelJaxbFallbackConverterTest.java
index 2d31403..c6b9379 100644
--- a/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/CamelJaxbFallbackConverterTest.java
+++ b/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/CamelJaxbFallbackConverterTest.java
@@ -22,8 +22,6 @@ import java.io.InputStream;
 import org.apache.camel.Exchange;
 import org.apache.camel.TypeConversionException;
 import org.apache.camel.TypeConverter;
-import org.apache.camel.converter.jaxb.FallbackTypeConverter;
-import org.apache.camel.converter.jaxb.message.Message;
 import org.apache.camel.example.Bar;
 import org.apache.camel.example.Foo;
 import org.apache.camel.foo.bar.PersonType;
@@ -118,14 +116,4 @@ public class CamelJaxbFallbackConverterTest extends CamelTestSupport {
         value = converter.convertTo(String.class, exchange, person);
         assertTrue("Should not filter the non-xml chars", value.indexOf("<lastName>BAR\uD8FF</lastName>") > 0);
     }
-
-    @Test
-    public void testNoXmlRootElementAnnotation() throws Exception {
-        Message in = new Message("Hello World");
-        TypeConverter converter = context.getTypeConverter();
-        String marshalled = converter.convertTo(String.class, in);
-        Message out = converter.convertTo(Message.class, marshalled);
-        assertNotEquals(in, out);
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/b70b906e/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/FallbackTypeConverterObjectFactoryDisabledTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/FallbackTypeConverterObjectFactoryDisabledTest.java b/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/FallbackTypeConverterObjectFactoryDisabledTest.java
new file mode 100644
index 0000000..8b69c09
--- /dev/null
+++ b/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/FallbackTypeConverterObjectFactoryDisabledTest.java
@@ -0,0 +1,60 @@
+/**
+ * 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.jaxb;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.camel.CamelExecutionException;
+import org.apache.camel.Exchange;
+import org.apache.camel.InvalidPayloadException;
+import org.apache.camel.NoTypeConversionAvailableException;
+import org.apache.camel.Processor;
+import org.apache.camel.TypeConversionException;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.converter.jaxb.FallbackTypeConverter;
+import org.apache.camel.converter.jaxb.message.Message;
+import org.apache.camel.test.junit4.CamelTestSupport;
+
+import org.junit.Test;
+
+public class FallbackTypeConverterObjectFactoryDisabledTest extends CamelTestSupport {
+    
+    @Test(expected=CamelExecutionException.class)
+    public void testObjectFactoryFalse() throws Exception {
+        Message in = new Message("Hello World");
+        getMockEndpoint("mock:a").expectedBodiesReceived(in);
+
+        template.sendBody("direct:a", in);
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+    	context.getProperties().put(FallbackTypeConverter.OBJECT_FACTORY, "false");
+        return new RouteBuilder(context) {
+
+            @Override
+            public void configure() throws Exception {
+                from("direct:a").convertBodyTo(String.class).to("direct:b");
+                from("direct:b").convertBodyTo(Message.class).to("mock:a");
+            }
+
+        };
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/b70b906e/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/FallbackTypeConverterObjectFactoryEnabledTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/FallbackTypeConverterObjectFactoryEnabledTest.java b/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/FallbackTypeConverterObjectFactoryEnabledTest.java
new file mode 100644
index 0000000..be51571
--- /dev/null
+++ b/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/FallbackTypeConverterObjectFactoryEnabledTest.java
@@ -0,0 +1,52 @@
+/**
+ * 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.jaxb;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.converter.jaxb.FallbackTypeConverter;
+import org.apache.camel.converter.jaxb.message.Message;
+import org.apache.camel.test.junit4.CamelTestSupport;
+
+import org.junit.Test;
+
+public class FallbackTypeConverterObjectFactoryEnabledTest extends CamelTestSupport {
+    
+    @Test
+    public void testObjectFactoryTrue() throws Exception {
+        Message in = new Message("Hello World");
+        getMockEndpoint("mock:a").expectedBodiesReceived(in);
+
+        template.sendBody("direct:a", in);
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+    	context.getProperties().put(FallbackTypeConverter.OBJECT_FACTORY, "true");
+        return new RouteBuilder(context) {
+
+            @Override
+            public void configure() throws Exception {
+                from("direct:a").convertBodyTo(String.class).to("direct:b");
+                from("direct:b").convertBodyTo(Message.class).to("mock:a");
+            }
+
+        };
+    }
+
+}
\ No newline at end of file