Repository: camel
Updated Branches:
  refs/heads/master ce8aac572 -> f4b7333c3


Add GPathResult converter tests


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

Branch: refs/heads/master
Commit: bc7a50cf9c80bce0b2e58201bb657789330c0b4e
Parents: 75b2c0a
Author: Dominik Adam Przybysz <alien11...@gmail.com>
Authored: Sun Aug 17 20:55:33 2014 +0200
Committer: Dominik Adam Przybysz <alien11...@gmail.com>
Committed: Sun Aug 17 21:07:44 2014 +0200

----------------------------------------------------------------------
 .../groovy/converter/GPathResultConverter.java  |  8 ++++
 .../services/org/apache/camel/TypeConverter     |  3 +-
 .../converter/GPathResultConverterTest.groovy   | 48 ++++++++++++++++++++
 3 files changed, 58 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/bc7a50cf/components/camel-groovy/src/main/java/org/apache/camel/groovy/converter/GPathResultConverter.java
----------------------------------------------------------------------
diff --git 
a/components/camel-groovy/src/main/java/org/apache/camel/groovy/converter/GPathResultConverter.java
 
b/components/camel-groovy/src/main/java/org/apache/camel/groovy/converter/GPathResultConverter.java
new file mode 100644
index 0000000..12802e3
--- /dev/null
+++ 
b/components/camel-groovy/src/main/java/org/apache/camel/groovy/converter/GPathResultConverter.java
@@ -0,0 +1,8 @@
+package org.apache.camel.groovy.converter;
+
+import org.apache.camel.Converter;
+
+@Converter
+public class GPathResultConverter {
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/bc7a50cf/components/camel-groovy/src/main/resources/META-INF/services/org/apache/camel/TypeConverter
----------------------------------------------------------------------
diff --git 
a/components/camel-groovy/src/main/resources/META-INF/services/org/apache/camel/TypeConverter
 
b/components/camel-groovy/src/main/resources/META-INF/services/org/apache/camel/TypeConverter
index 62a0595..8a0e315 100644
--- 
a/components/camel-groovy/src/main/resources/META-INF/services/org/apache/camel/TypeConverter
+++ 
b/components/camel-groovy/src/main/resources/META-INF/services/org/apache/camel/TypeConverter
@@ -14,4 +14,5 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
-org.apache.camel.groovy.converter.TypeConverter
\ No newline at end of file
+org.apache.camel.groovy.converter.TypeConverter
+org.apache.camel.groovy.converter.GPathResultConverter
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/bc7a50cf/components/camel-groovy/src/test/groovy/org/apache/camel/groovy/converter/GPathResultConverterTest.groovy
----------------------------------------------------------------------
diff --git 
a/components/camel-groovy/src/test/groovy/org/apache/camel/groovy/converter/GPathResultConverterTest.groovy
 
b/components/camel-groovy/src/test/groovy/org/apache/camel/groovy/converter/GPathResultConverterTest.groovy
new file mode 100644
index 0000000..22daa5e
--- /dev/null
+++ 
b/components/camel-groovy/src/test/groovy/org/apache/camel/groovy/converter/GPathResultConverterTest.groovy
@@ -0,0 +1,48 @@
+package org.apache.camel.groovy.converter
+
+import groovy.util.slurpersupport.GPathResult
+import org.apache.camel.CamelContext
+import org.apache.camel.Exchange
+import org.apache.camel.StringSource
+import org.apache.camel.impl.DefaultCamelContext
+import org.apache.camel.impl.DefaultExchange
+import org.junit.Test
+import org.w3c.dom.Node
+
+import static org.junit.Assert.assertEquals
+
+public class GPathResultConverterTest {
+    String xml = "<test><elem1>This is test</elem1></test>"
+    CamelContext context = new DefaultCamelContext()
+
+    @Test
+    void "should convert string to GPathResult"() {
+        Exchange exchange = new DefaultExchange(context)
+        exchange.in.setBody(xml, String)
+        GPathResult result = exchange.in.getBody(GPathResult)
+        checkGPathResult(result)
+    }
+
+    @Test
+    void "should convert string source to GPathResult"() {
+        StringSource input = new StringSource(xml)
+        Exchange exchange = new DefaultExchange(context)
+        exchange.in.setBody(input, StringSource)
+        GPathResult result = exchange.in.getBody(GPathResult)
+        checkGPathResult(result)
+    }
+
+    @Test
+    void "should convert node to GPathResult"() {
+        Node node = new XmlParser().parseText(xml)
+        Exchange exchange = new DefaultExchange(context)
+        exchange.in.setBody(node, Node)
+        GPathResult result = exchange.in.getBody(GPathResult)
+        checkGPathResult(result)
+    }
+
+    private void checkGPathResult(GPathResult gPathResult) {
+        assertEquals(gPathResult.name(), "test")
+        assertEquals(gPathResult.elem1.text(), "This is test")
+    }
+}
\ No newline at end of file

Reply via email to