Return-Path: X-Original-To: apmail-camel-commits-archive@www.apache.org Delivered-To: apmail-camel-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2B8381146D for ; Fri, 5 Sep 2014 06:42:26 +0000 (UTC) Received: (qmail 6604 invoked by uid 500); 5 Sep 2014 06:42:25 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 6533 invoked by uid 500); 5 Sep 2014 06:42:25 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 6513 invoked by uid 99); 5 Sep 2014 06:42:25 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Sep 2014 06:42:25 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 5ACE4A09953; Fri, 5 Sep 2014 06:42:25 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: davsclaus@apache.org To: commits@camel.apache.org Date: Fri, 05 Sep 2014 06:42:25 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [1/6] git commit: Add GPathResult converter tests 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 Authored: Sun Aug 17 20:55:33 2014 +0200 Committer: Dominik Adam Przybysz 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 = "This is 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