Repository: camel Updated Branches: refs/heads/master 897a77a90 -> 30ed3f5d0
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/30ed3f5d Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/30ed3f5d Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/30ed3f5d Branch: refs/heads/master Commit: 30ed3f5d059c14e488d1060c56ae564492b199e8 Parents: 897a77a Author: Claus Ibsen <[email protected]> Authored: Mon Dec 1 11:02:24 2014 +0100 Committer: Claus Ibsen <[email protected]> Committed: Mon Dec 1 11:02:24 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/30ed3f5d/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/30ed3f5d/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(); + } + }; + } +}
