camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/2] git commit: CAMEL-6593: Dump predicate/expression built from java dsl with builders to use toString when being dumped in route model xml.
Date Fri, 23 Aug 2013 07:51:44 GMT
Updated Branches:
  refs/heads/camel-2.11.x 27a5f833b -> ec91c200f
  refs/heads/master 050eef88e -> 7f8a295af


CAMEL-6593: Dump predicate/expression built from java dsl with builders to use toString when
being dumped in route model xml.


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

Branch: refs/heads/master
Commit: 7f8a295af00eca09ccbcd326d172d028caa24043
Parents: 050eef8
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Fri Aug 23 09:39:18 2013 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Fri Aug 23 09:39:18 2013 +0200

----------------------------------------------------------------------
 .../org/apache/camel/model/ExpressionNode.java  |  9 ++++++++
 .../model/language/ExpressionDefinition.java    | 23 +++++++++-----------
 .../DumpModelAsXmlChoiceFilterRouteTest.java    | 17 +++++++++++++++
 3 files changed, 36 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/7f8a295a/camel-core/src/main/java/org/apache/camel/model/ExpressionNode.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/ExpressionNode.java b/camel-core/src/main/java/org/apache/camel/model/ExpressionNode.java
index 41f97ce..ef64c2d 100644
--- a/camel-core/src/main/java/org/apache/camel/model/ExpressionNode.java
+++ b/camel-core/src/main/java/org/apache/camel/model/ExpressionNode.java
@@ -143,5 +143,14 @@ public class ExpressionNode extends ProcessorDefinition<ExpressionNode>
{
                 expression = clause.getExpressionType();
             }
         }
+
+        if (expression != null && expression.getExpression() == null) {
+            // use toString from predicate or expression so we have some information to show
in the route model
+            if (expression.getPredicate() != null) {
+                expression.setExpression(expression.getPredicate().toString());
+            } else if (expression.getExpressionValue() != null) {
+                expression.setExpression(expression.getExpressionValue().toString());
+            }
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/7f8a295a/camel-core/src/main/java/org/apache/camel/model/language/ExpressionDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/language/ExpressionDefinition.java
b/camel-core/src/main/java/org/apache/camel/model/language/ExpressionDefinition.java
index b423afa..52b0d1c 100644
--- a/camel-core/src/main/java/org/apache/camel/model/language/ExpressionDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/language/ExpressionDefinition.java
@@ -243,20 +243,17 @@ public class ExpressionDefinition implements Expression, Predicate {
      * Returns some descriptive text to describe this node
      */
     public String getLabel() {
-        String language = getExpression();
-        if (ObjectHelper.isEmpty(language)) {
-            Predicate predicate = getPredicate();
-            if (predicate != null) {
-                return predicate.toString();
-            }
-            Expression expressionValue = getExpressionValue();
-            if (expressionValue != null) {
-                return expressionValue.toString();
-            }
-        } else {
-            return language;
+        Predicate predicate = getPredicate();
+        if (predicate != null) {
+            return predicate.toString();
         }
-        return "";
+        Expression expressionValue = getExpressionValue();
+        if (expressionValue != null) {
+            return expressionValue.toString();
+        }
+
+        String exp = getExpression();
+        return exp != null ? exp : "";
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/camel/blob/7f8a295a/camel-core/src/test/java/org/apache/camel/util/DumpModelAsXmlChoiceFilterRouteTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/util/DumpModelAsXmlChoiceFilterRouteTest.java
b/camel-core/src/test/java/org/apache/camel/util/DumpModelAsXmlChoiceFilterRouteTest.java
index 6fe96b9..317bc71 100644
--- a/camel-core/src/test/java/org/apache/camel/util/DumpModelAsXmlChoiceFilterRouteTest.java
+++ b/camel-core/src/test/java/org/apache/camel/util/DumpModelAsXmlChoiceFilterRouteTest.java
@@ -35,6 +35,15 @@ public class DumpModelAsXmlChoiceFilterRouteTest extends ContextTestSupport
{
         assertTrue(xml.contains("<simple>${body} contains Camel</simple>"));
     }
 
+    public void testDumpModelAsXmAl() throws Exception {
+        String xml = ModelHelper.dumpModelAsXml(context.getRouteDefinition("a"));
+        assertNotNull(xml);
+        log.info(xml);
+
+        assertTrue(xml.contains("<constant>bar</constant>"));
+        assertTrue(xml.contains("<expressionDefinition>header{test} is not null</expressionDefinition>"));
+    }
+
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
@@ -54,6 +63,14 @@ public class DumpModelAsXmlChoiceFilterRouteTest extends ContextTestSupport
{
                             .to("mock:other")
                     .end()
                     .to("mock:result");
+
+                from("seda:a").routeId("a")
+                    .setProperty("foo").constant("bar")
+                    .choice()
+                        .when(header("test").isNotNull()).log("not null")
+                        .when(xpath("/foo/bar")).log("xpath")
+                    .end()
+                    .to("mock:a");
             }
         };
     }


Mime
View raw message