camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/3] git commit: CAMEL-6422: Add tokenizeXML to java dsl on value builder.
Date Tue, 04 Jun 2013 10:15:10 GMT
Updated Branches:
  refs/heads/camel-2.10.x 8d2e138b9 -> ffd479d70
  refs/heads/camel-2.11.x fffddef38 -> bcb0f0048
  refs/heads/master b22ac5c55 -> 82d0e332a


CAMEL-6422: Add tokenizeXML to java dsl on value builder.


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

Branch: refs/heads/master
Commit: 82d0e332a453ed4d2bc9f05c67aeee19b16c7d24
Parents: b22ac5c
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Tue Jun 4 12:13:45 2013 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Tue Jun 4 12:13:45 2013 +0200

----------------------------------------------------------------------
 .../org/apache/camel/builder/ValueBuilder.java     |   10 ++++++++
 .../language/TokenXMLPairNamespaceSplitTest.java   |   19 +++++++++++++++
 2 files changed, 29 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/82d0e332/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java b/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java
index 496e20c..31c4b96 100644
--- a/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java
+++ b/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java
@@ -177,6 +177,16 @@ public class ValueBuilder implements Expression, Predicate {
         return new ValueBuilder(newExp);
     }
 
+    public ValueBuilder tokenizeXML(String tagName, String inheritNamespaceTagName) {
+        Expression newExp = ExpressionBuilder.tokenizeXMLExpression(tagName, inheritNamespaceTagName);
+        return new ValueBuilder(newExp);
+    }
+
+    public ValueBuilder tokenizePair(String startToken, String endToken, boolean includeTokens)
{
+        Expression newExp = ExpressionBuilder.tokenizePairExpression(startToken, endToken,
includeTokens);
+        return new ValueBuilder(newExp);
+    }
+
     /**
      * Tokenizes the string conversion of this expression using the given
      * regular expression

http://git-wip-us.apache.org/repos/asf/camel/blob/82d0e332/camel-core/src/test/java/org/apache/camel/language/TokenXMLPairNamespaceSplitTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/language/TokenXMLPairNamespaceSplitTest.java
b/camel-core/src/test/java/org/apache/camel/language/TokenXMLPairNamespaceSplitTest.java
index 6914630..dd74896 100644
--- a/camel-core/src/test/java/org/apache/camel/language/TokenXMLPairNamespaceSplitTest.java
+++ b/camel-core/src/test/java/org/apache/camel/language/TokenXMLPairNamespaceSplitTest.java
@@ -29,6 +29,7 @@ public class TokenXMLPairNamespaceSplitTest extends ContextTestSupport {
     @Override
     protected void setUp() throws Exception {
         deleteDirectory("target/pair");
+        deleteDirectory("target/pair2");
         super.setUp();
     }
 
@@ -45,6 +46,19 @@ public class TokenXMLPairNamespaceSplitTest extends ContextTestSupport
{
         assertMockEndpointsSatisfied();
     }
 
+    public void testTokenXMLPair2() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:split");
+        mock.expectedMessageCount(3);
+        mock.message(0).body().isEqualTo("<order id=\"1\" xmlns=\"http:acme.com\">Camel
in Action</order>");
+        mock.message(1).body().isEqualTo("<order id=\"2\" xmlns=\"http:acme.com\">ActiveMQ
in Action</order>");
+        mock.message(2).body().isEqualTo("<order id=\"3\" xmlns=\"http:acme.com\">DSL
in Action</order>");
+
+        String body = createBody();
+        template.sendBodyAndHeader("file:target/pair2", body, Exchange.FILE_NAME, "orders.xml");
+
+        assertMockEndpointsSatisfied();
+    }
+
     protected String createBody() {
         StringBuilder sb = new StringBuilder("<?xml version=\"1.0\"?>\n");
         sb.append("<orders xmlns=\"http:acme.com\">\n");
@@ -66,6 +80,11 @@ public class TokenXMLPairNamespaceSplitTest extends ContextTestSupport
{
                     .split().tokenizeXML("order", "orders")
                         .to("mock:split");
                 // END SNIPPET: e1
+
+                from("file:target/pair2")
+                    // split the order child tags, and inherit namespaces from the orders
root tag
+                    .split(body().tokenizeXML("order", "orders"))
+                        .to("mock:split");
             }
         };
     }


Mime
View raw message