Updated Branches:
  refs/heads/master e42b0b9e5 -> dc281f360

Added unit test about using custom type converters in camel-test-blueprint


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

Branch: refs/heads/master
Commit: a5b3296216b44c7cd08263b066b374a86c2b2b0f
Parents: e42b0b9
Author: Claus Ibsen <davscl...@apache.org>
Authored: Thu Jul 11 11:43:16 2013 +0200
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Thu Jul 11 18:04:38 2013 +0200

----------------------------------------------------------------------
 .../org/apache/camel/test/blueprint/Foo.java    | 39 +++++++++++++++++
 .../converter/CustomConverterTest.java          | 44 ++++++++++++++++++++
 .../test/blueprint/converter/MyConverter.java   | 34 +++++++++++++++
 .../services/org/apache/camel/TypeConverter     | 18 ++++++++
 .../src/test/resources/log4j.properties         |  1 +
 .../blueprint/converter/CustomConverterTest.xml | 34 +++++++++++++++
 6 files changed, 170 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/a5b32962/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/Foo.java
----------------------------------------------------------------------
diff --git 
a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/Foo.java
 
b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/Foo.java
new file mode 100644
index 0000000..b6782d9
--- /dev/null
+++ 
b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/Foo.java
@@ -0,0 +1,39 @@
+/**
+ * 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.test.blueprint;
+
+public class Foo {
+
+    private String first;
+    private String last;
+
+    public String getFirst() {
+        return first;
+    }
+
+    public void setFirst(String first) {
+        this.first = first;
+    }
+
+    public String getLast() {
+        return last;
+    }
+
+    public void setLast(String last) {
+        this.last = last;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/a5b32962/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/converter/CustomConverterTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/converter/CustomConverterTest.java
 
b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/converter/CustomConverterTest.java
new file mode 100644
index 0000000..1c1ce64
--- /dev/null
+++ 
b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/converter/CustomConverterTest.java
@@ -0,0 +1,44 @@
+/**
+ * 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.test.blueprint.converter;
+
+import org.apache.camel.test.blueprint.CamelBlueprintTestSupport;
+import org.apache.camel.test.blueprint.Foo;
+import org.junit.Test;
+
+public class CustomConverterTest extends CamelBlueprintTestSupport {
+
+    @Override
+    protected String getBlueprintDescriptor() {
+        return 
"org/apache/camel/test/blueprint/converter/CustomConverterTest.xml";
+    }
+
+    @Test
+    public void testCustomConverter() throws Exception {
+        getMockEndpoint("mock:result").expectedMessageCount(1);
+        
getMockEndpoint("mock:result").message(0).body().isInstanceOf(Foo.class);
+
+        template.sendBody("direct:start", "John,Doe");
+
+        assertMockEndpointsSatisfied();
+
+        Foo foo = 
getMockEndpoint("mock:result").getReceivedExchanges().get(0).getIn().getBody(Foo.class);
+        assertEquals("John", foo.getFirst());
+        assertEquals("Doe", foo.getLast());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/a5b32962/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/converter/MyConverter.java
----------------------------------------------------------------------
diff --git 
a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/converter/MyConverter.java
 
b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/converter/MyConverter.java
new file mode 100644
index 0000000..58131cc
--- /dev/null
+++ 
b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/converter/MyConverter.java
@@ -0,0 +1,34 @@
+/**
+ * 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.test.blueprint.converter;
+
+import org.apache.camel.Converter;
+import org.apache.camel.test.blueprint.Foo;
+
+@Converter
+public class MyConverter {
+
+    @Converter
+    public static Foo convertToFoo(String data) {
+        String[] s = data.split(",");
+        Foo foo = new Foo();
+        foo.setFirst(s[0]);
+        foo.setLast(s[1]);
+        return foo;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/a5b32962/components/camel-test-blueprint/src/test/resources/META-INF/services/org/apache/camel/TypeConverter
----------------------------------------------------------------------
diff --git 
a/components/camel-test-blueprint/src/test/resources/META-INF/services/org/apache/camel/TypeConverter
 
b/components/camel-test-blueprint/src/test/resources/META-INF/services/org/apache/camel/TypeConverter
new file mode 100644
index 0000000..2b0f5e5
--- /dev/null
+++ 
b/components/camel-test-blueprint/src/test/resources/META-INF/services/org/apache/camel/TypeConverter
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+org.apache.camel.test.blueprint.converter.MyConverter
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/a5b32962/components/camel-test-blueprint/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git 
a/components/camel-test-blueprint/src/test/resources/log4j.properties 
b/components/camel-test-blueprint/src/test/resources/log4j.properties
index f090d64..8d8dd6b 100644
--- a/components/camel-test-blueprint/src/test/resources/log4j.properties
+++ b/components/camel-test-blueprint/src/test/resources/log4j.properties
@@ -23,6 +23,7 @@ log4j.rootLogger=INFO, file
 #log4j.logger.de.kalpatec.pojosr=DEBUG
 #log4j.logger.org.apache.camel.test.blueprint=DEBUG
 #log4j.logger.org.apache.camel=DEBUG
+#log4j.logger.org.apache.camel.impl.osgi.Activator=DEBUG
 #log4j.logger.org.apache.camel.blueprint=TRACE
 #log4j.logger.org.apache.camel.core.osgi=TRACE
 #log4j.logger.org.apache.aries.blueprint.container=DEBUG

http://git-wip-us.apache.org/repos/asf/camel/blob/a5b32962/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/converter/CustomConverterTest.xml
----------------------------------------------------------------------
diff --git 
a/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/converter/CustomConverterTest.xml
 
b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/converter/CustomConverterTest.xml
new file mode 100644
index 0000000..3b6f43b
--- /dev/null
+++ 
b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/converter/CustomConverterTest.xml
@@ -0,0 +1,34 @@
+<?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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0";
+           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+           xsi:schemaLocation="
+             http://www.osgi.org/xmlns/blueprint/v1.0.0 
http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd";>
+
+  <camelContext xmlns="http://camel.apache.org/schema/blueprint";>
+
+    <route>
+      <from uri="direct:start"/>
+      <convertBodyTo type="org.apache.camel.test.blueprint.Foo"/>
+      <to uri="mock:result"/>
+    </route>
+
+  </camelContext>
+
+</blueprint>
+

Reply via email to