camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject camel git commit: CAMEL-8098: Route model using body expression should be representable in the xml model
Date Mon, 01 Dec 2014 10:59:17 GMT
Repository: camel
Updated Branches:
  refs/heads/camel-2.14.x 7e51e5b4e -> e04a4fe60


CAMEL-8098: Route model using body expression should be representable in the xml model


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

Branch: refs/heads/camel-2.14.x
Commit: e04a4fe60b6db71e64ed26328b9a64b4e8d34196
Parents: 7e51e5b
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Mon Dec 1 11:02:24 2014 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Mon Dec 1 11:59:00 2014 +0100

----------------------------------------------------------------------
 .../camel/builder/ExpressionClauseSupport.java  |  3 +-
 .../util/DumpModelAsXmlSplitBodyRouteTest.java  | 68 ++++++++++++++++++++
 2 files changed, 70 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/e04a4fe6/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java
b/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java
index 5fdc737..7fff673 100644
--- a/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java
+++ b/camel-core/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java
@@ -114,7 +114,8 @@ public class ExpressionClauseSupport<T> {
      * An expression of an inbound message body
      */
     public T body() {
-        return expression(ExpressionBuilder.bodyExpression());
+        // reuse simple as this allows the model to represent this as a known JAXB type
+        return expression(new SimpleExpression("body"));
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/camel/blob/e04a4fe6/camel-core/src/test/java/org/apache/camel/util/DumpModelAsXmlSplitBodyRouteTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/util/DumpModelAsXmlSplitBodyRouteTest.java
b/camel-core/src/test/java/org/apache/camel/util/DumpModelAsXmlSplitBodyRouteTest.java
new file mode 100644
index 0000000..c095ed9
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/util/DumpModelAsXmlSplitBodyRouteTest.java
@@ -0,0 +1,68 @@
+/**
+ * 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.util;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.converter.jaxp.XmlConverter;
+import org.apache.camel.model.ModelHelper;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+/**
+ *
+ */
+public class DumpModelAsXmlSplitBodyRouteTest extends ContextTestSupport {
+
+    public void testDumpModelAsXml() throws Exception {
+        String xml = ModelHelper.dumpModelAsXml(context.getRouteDefinition("myRoute"));
+        assertNotNull(xml);
+        log.info(xml);
+
+        Document doc = new XmlConverter().toDOMDocument(xml);
+        NodeList nodes = doc.getElementsByTagName("simple");
+        assertEquals(1, nodes.getLength());
+        Element node = (Element)nodes.item(0);
+        assertNotNull("Node <simple> expected to be instanceof Element", node);
+        assertEquals("body", node.getTextContent());
+
+        nodes = doc.getElementsByTagName("split");
+        assertEquals(1, nodes.getLength());
+
+        nodes = doc.getElementsByTagName("to");
+        assertEquals(1, nodes.getLength());
+        node = (Element)nodes.item(0);
+        assertNotNull("Node <to> expected to be instanceof Element", node);
+        assertEquals("mock:sub", node.getAttribute("uri"));
+        assertEquals("myMock", node.getAttribute("id"));
+        assertEquals("true", node.getAttribute("customId"));
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start").routeId("myRoute")
+                   .split().body()
+                        .to("mock:sub").id("myMock")
+                    .end();
+            }
+        };
+    }
+}


Mime
View raw message