svn commit: r803128 [1/2] - in /camel/trunk: camel-core/src/main/java/org/apache/camel/model/ camel-core/src/main/java/org/apache/camel/processor/loadbalancer/ components/camel-web/src/main/java/org/apache/camel/web/util/ components/camel-web/src/test/...

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r803128 [1/2] - in /camel/trunk: camel-core/src/main/java/org/apache/camel/model/ camel-core/src/main/java/org/apache/camel/processor/loadbalancer/ components/camel-web/src/main/java/org/apache/camel/web/util/ components/camel-web/src/test/...

janstey-3
Author: janstey
Date: Tue Aug 11 13:59:36 2009
New Revision: 803128

URL: http://svn.apache.org/viewvc?rev=803128&view=rev
Log:
CAMEL-1392 - latest update to the Groovy renderer from Xueqiang

Added:
    camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/ConvertBodyDefinitionRenderer.java
    camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/LoadBalanceDefinitionRenderer.java
    camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/ProcessorDefinitionRenderer.java
    camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/ResequenceDefinitionRenderer.java
    camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/RoutingSlipDefinitionRenderer.java
    camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/ThrottleDefinitionRenderer.java
    camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/AOPDSLTest.java
    camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/InterceptDSLTest.java
    camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/InterceptFromDSLTest.java
    camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/InterceptSendToEndpointDSLTest.java
    camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/MulticastDSLTest.java
    camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/OnCompletionDSLTest.java
    camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/PredicateRendererTest.java
    camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/PredicateRendererTestSupport.java
    camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/ResequenceDSLTest.java
    camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/RollbackDSLTest.java
    camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/SplitDSLTest.java
    camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/StopDSLTest.java
    camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/StreamCachingDSLTest.java
    camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/TracingDSLTest.java
    camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/util/
    camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/util/UriCharachersEncoderTest.java
    camel/trunk/components/camel-web/src/test/resources/routes.txt
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/InterceptSendToEndpointDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/RollbackDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/loadbalancer/StickyLoadBalancer.java
    camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/AggregateDefinitionRenderer.java
    camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/ChoiceDefinitionRenderer.java
    camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/ExpressionNodeRenderer.java
    camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/ExpressionRenderer.java
    camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/GroovyRenderer.java
    camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/OnCompletionDefinitionRenderer.java
    camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/OnExceptionDefinitionRenderer.java
    camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/OutputDefinitionRenderer.java
    camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/PredicateRenderer.java
    camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/SendDefinitionRenderer.java
    camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/UriCharactersEncoder.java
    camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/ChoiceDSLTest.java
    camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/GroovyRendererTest.java
    camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/GroovyRendererTestSupport.java
    camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/LoadBalanceDSLTest.java
    camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/PipelineDSLTest.java
    camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/SortDSLTest.java
    camel/trunk/components/camel-web/src/test/resources/route.txt
    camel/trunk/components/camel-web/src/test/resources/testedRoutes.txt

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/InterceptSendToEndpointDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/InterceptSendToEndpointDefinition.java?rev=803128&r1=803127&r2=803128&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/InterceptSendToEndpointDefinition.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/InterceptSendToEndpointDefinition.java Tue Aug 11 13:59:36 2009
@@ -66,7 +66,7 @@
 
     @Override
     public String getShortName() {
-        return "interceptEndpoint";
+        return "interceptSendToEndpoint";
     }
 
     @Override

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/RollbackDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RollbackDefinition.java?rev=803128&r1=803127&r2=803128&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/RollbackDefinition.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/RollbackDefinition.java Tue Aug 11 13:59:36 2009
@@ -44,6 +44,10 @@
         this.message = message;
     }
 
+    public String getMessage() {
+        return message;
+    }
+    
     @Override
     public String getShortName() {
         return "rollback";

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/loadbalancer/StickyLoadBalancer.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/loadbalancer/StickyLoadBalancer.java?rev=803128&r1=803127&r2=803128&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/loadbalancer/StickyLoadBalancer.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/loadbalancer/StickyLoadBalancer.java Tue Aug 11 13:59:36 2009
@@ -52,6 +52,10 @@
         this.correlationExpression = correlationExpression;
         this.loadBalancer = loadBalancer;
     }
+    
+    public Expression getCorrelationExpression() {
+        return correlationExpression;
+    }
 
     protected synchronized Processor chooseProcessor(List<Processor> processors, Exchange exchange) {
         Object value = correlationExpression.evaluate(exchange, Object.class);

Modified: camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/AggregateDefinitionRenderer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/AggregateDefinitionRenderer.java?rev=803128&r1=803127&r2=803128&view=diff
==============================================================================
--- camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/AggregateDefinitionRenderer.java (original)
+++ camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/AggregateDefinitionRenderer.java Tue Aug 11 13:59:36 2009
@@ -22,7 +22,7 @@
 import org.apache.camel.model.ProcessorDefinition;
 
 /**
- *
+ *
  */
 public class AggregateDefinitionRenderer {
 

Modified: camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/ChoiceDefinitionRenderer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/ChoiceDefinitionRenderer.java?rev=803128&r1=803127&r2=803128&view=diff
==============================================================================
--- camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/ChoiceDefinitionRenderer.java (original)
+++ camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/ChoiceDefinitionRenderer.java Tue Aug 11 13:59:36 2009
@@ -17,14 +17,26 @@
 
 package org.apache.camel.web.util;
 
+import org.apache.camel.model.ChoiceDefinition;
+import org.apache.camel.model.OtherwiseDefinition;
 import org.apache.camel.model.ProcessorDefinition;
+import org.apache.camel.model.WhenDefinition;
 
 /**
- *
+ *
  */
 public class ChoiceDefinitionRenderer {
 
     public static void render(StringBuilder buffer, ProcessorDefinition processor) {
-
+        ChoiceDefinition choice = (ChoiceDefinition)processor;
+        buffer.append(".").append(choice.getShortName()).append("()");
+        for (WhenDefinition when : choice.getWhenClauses()) {
+            ProcessorDefinitionRenderer.render(buffer, when);
+        }
+        OtherwiseDefinition other = choice.getOtherwise();
+        if (other != null) {
+            ProcessorDefinitionRenderer.render(buffer, other);
+        }
+        buffer.append(".end()");
     }
 }

Added: camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/ConvertBodyDefinitionRenderer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/ConvertBodyDefinitionRenderer.java?rev=803128&view=auto
==============================================================================
--- camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/ConvertBodyDefinitionRenderer.java (added)
+++ camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/ConvertBodyDefinitionRenderer.java Tue Aug 11 13:59:36 2009
@@ -0,0 +1,41 @@
+/**
+ * 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.web.util;
+
+import org.apache.camel.model.ConvertBodyDefinition;
+import org.apache.camel.model.ProcessorDefinition;
+
+/**
+ *
+ */
+public class ConvertBodyDefinitionRenderer {
+
+    public static void render(StringBuilder buffer, ProcessorDefinition processor) {
+        ConvertBodyDefinition convertBody = (ConvertBodyDefinition)processor;
+        buffer.append(".").append(convertBody.getShortName()).append("(");
+        if (convertBody.getType().equals("[B")) {
+            buffer.append("byte[].class");
+        } else {
+            buffer.append(convertBody.getType()).append(".class");
+        }
+        if (convertBody.getCharset() != null) {
+            buffer.append(", \"").append(convertBody.getCharset()).append("\"");
+        }
+        buffer.append(")");
+    }
+}

Modified: camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/ExpressionNodeRenderer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/ExpressionNodeRenderer.java?rev=803128&r1=803127&r2=803128&view=diff
==============================================================================
--- camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/ExpressionNodeRenderer.java (original)
+++ camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/ExpressionNodeRenderer.java Tue Aug 11 13:59:36 2009
@@ -36,7 +36,7 @@
 import org.apache.camel.model.language.ExpressionDefinition;
 
 /**
- *
+ *
  */
 public class ExpressionNodeRenderer {
 
@@ -56,7 +56,9 @@
             }
         } else if (expNode instanceof FilterDefinition) {
             if (expression.getPredicate() != null) {
-                PredicateRenderer.renderPredicate(buffer, expression.getPredicate());
+                buffer.append("(");
+                PredicateRenderer.render(buffer, expression.getPredicate());
+                buffer.append(")");
             } else if (expression.getLanguage() != null) {
                 buffer.append("()");
                 ExpressionRenderer.render(buffer, expression);
@@ -65,6 +67,7 @@
                 ExpressionRenderer.render(buffer, expression);
             }
         } else if (expNode instanceof IdempotentConsumerDefinition) {
+            // TODO improve it
         } else if (expNode instanceof LoopDefinition) {
             if (expression instanceof ConstantExpression) {
                 buffer.append("(").append(expression.getExpression()).append(")");
@@ -105,11 +108,18 @@
                 ExpressionRenderer.render(buffer, expression);
             }
         } else if (expNode instanceof SplitDefinition) {
-            String expValue = expression.getExpressionValue().toString();
-            if (!expValue.contains("(")) {
-                buffer.append("().").append(expValue).append("()");
-            } else {
+            if (expression.getExpressionValue() != null) {
+                buffer.append("(");
                 ExpressionRenderer.render(buffer, expression);
+                buffer.append(")");
+            } else if (expression.getExpressionType() != null) {
+                buffer.append("().");
+                ExpressionRenderer.render(buffer, expression);
+            }
+
+            SplitDefinition split = (SplitDefinition)expNode;
+            if (split.isStreaming()) {
+                buffer.append(".streaming()");
             }
         } else if (expNode instanceof TransformDefinition) {
             String expValue = expression.getExpressionValue().toString();
@@ -125,7 +135,9 @@
             }
         } else if (expNode instanceof WhenDefinition) {
             if (expression.getPredicate() != null) {
-                PredicateRenderer.renderPredicate(buffer, expression.getPredicate());
+                buffer.append("(");
+                PredicateRenderer.render(buffer, expression.getPredicate());
+                buffer.append(")");
             }
             if (expression instanceof ExpressionClause) {
                 buffer.append("()");

Modified: camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/ExpressionRenderer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/ExpressionRenderer.java?rev=803128&r1=803127&r2=803128&view=diff
==============================================================================
--- camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/ExpressionRenderer.java (original)
+++ camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/ExpressionRenderer.java Tue Aug 11 13:59:36 2009
@@ -23,7 +23,7 @@
 import org.apache.camel.model.language.XPathExpression;
 
 /**
- *
+ *
  */
 public class ExpressionRenderer {
 
@@ -111,9 +111,14 @@
      */
     public static void renderExpression(StringBuilder buffer, String expression) {
         if (!expression.contains(",")) {
-            // header(foo) -> header("foo")
-            expression = expression.replaceAll("\\(", "(\"").replaceAll("\\)", "\")");
-            buffer.append(expression);
+            if (expression.contains("(")) {
+                // header(foo) -> header("foo")
+                expression = expression.replaceAll("\\(", "(\"").replaceAll("\\)", "\")");
+                buffer.append(expression);
+            } else {
+                // body -> body()
+                buffer.append(expression).append("()");
+            }
         } else if (expression.startsWith("tokenize")) {
             String words[] = expression.split("\\(");
             if (words.length == 2) {
@@ -121,8 +126,17 @@
                 String tokenize = words[1].substring(words[1].indexOf(" ") + 1, words[1].lastIndexOf(")"));
                 words[1] = words[1].substring(0, words[1].indexOf(","));
 
-                buffer.append(words[1]).append("().");
-                buffer.append(words[0]).append("(\"").append(tokenize).append("\")");
+                if (!words[1].contains("[")) {
+                    // body
+                    buffer.append(words[1]).append("()");
+                } else {
+                    // bodyAs[clazz]
+                    String word = words[1].substring(0, words[1].indexOf("As"));
+                    String clazz = words[1].substring(words[1].lastIndexOf(".") + 1, words[1].length() - 1);
+                    buffer.append(word).append("(").append(clazz).append(".class)");
+                }
+
+                buffer.append(".").append(words[0]).append("(\"").append(tokenize).append("\")");
             } else if (words.length == 3) {
                 // tokenize(header(foo), ,) -> header("foo").tokenize(",")
                 String symbolName = words[2].substring(0, words[2].indexOf(")"));

Modified: camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/GroovyRenderer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/GroovyRenderer.java?rev=803128&r1=803127&r2=803128&view=diff
==============================================================================
--- camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/GroovyRenderer.java (original)
+++ camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/GroovyRenderer.java Tue Aug 11 13:59:36 2009
@@ -16,36 +16,14 @@
  */
 package org.apache.camel.web.util;
 
-import java.io.IOException;
 import java.util.List;
 
-import org.apache.camel.Expression;
 import org.apache.camel.builder.DeadLetterChannelBuilder;
 import org.apache.camel.builder.ErrorHandlerBuilderRef;
-import org.apache.camel.model.AggregateDefinition;
-import org.apache.camel.model.ChoiceDefinition;
-import org.apache.camel.model.ConvertBodyDefinition;
-import org.apache.camel.model.ExpressionNode;
 import org.apache.camel.model.FromDefinition;
-import org.apache.camel.model.LoadBalanceDefinition;
-import org.apache.camel.model.OnCompletionDefinition;
-import org.apache.camel.model.OnExceptionDefinition;
-import org.apache.camel.model.OtherwiseDefinition;
-import org.apache.camel.model.OutputDefinition;
 import org.apache.camel.model.ProcessorDefinition;
-import org.apache.camel.model.ResequenceDefinition;
 import org.apache.camel.model.RouteDefinition;
-import org.apache.camel.model.RoutesDefinition;
-import org.apache.camel.model.RoutingSlipDefinition;
 import org.apache.camel.model.SendDefinition;
-import org.apache.camel.model.ThrottleDefinition;
-import org.apache.camel.model.WhenDefinition;
-import org.apache.camel.processor.loadbalancer.FailOverLoadBalancer;
-import org.apache.camel.processor.loadbalancer.LoadBalancer;
-import org.apache.camel.processor.loadbalancer.RandomLoadBalancer;
-import org.apache.camel.processor.loadbalancer.RoundRobinLoadBalancer;
-import org.apache.camel.processor.loadbalancer.StickyLoadBalancer;
-import org.apache.camel.processor.loadbalancer.TopicLoadBalancer;
 
 /**
  * Render routes in Groovy language
@@ -58,8 +36,6 @@
 
     /**
      * render a RouteDefinition
-     *
-     * @throws IOException
      */
     public static void renderRoute(StringBuilder buffer, RouteDefinition route) {
         List<FromDefinition> inputs = route.getInputs();
@@ -78,10 +54,11 @@
         }
 
         // render the global dsl not started with from, like global
-        // onCompletion, onException, intercept
+        // intercept, interceptFrom,interceptSendToEndpoint, onCompletion,
+        // onException
         for (ProcessorDefinition processor : outputs) {
-            if (processor.getParent() == null) {
-                renderProcessor(buffer, processor);
+            if (processor.getParent() == null && !(processor instanceof SendDefinition)) {
+                ProcessorDefinitionRenderer.render(buffer, processor);
                 buffer.append(";");
             }
         }
@@ -96,125 +73,36 @@
         }
         buffer.append(")");
 
+        // render some route configurations
+        if (route.isTrace() != null) {
+            if (route.isTrace()) {
+                buffer.append(".tracing()");
+            } else {
+                buffer.append(".noTracing()");
+            }
+        }
+        if (route.isStreamCache() != null && route.isStreamCache()) {
+            buffer.append(".streamCaching()");
+        }
+
         // render the outputs of the router
         for (ProcessorDefinition processor : outputs) {
-            if (processor.getParent() == route) {
-                renderProcessor(buffer, processor);
+            if (processor.getParent() == route || processor instanceof SendDefinition) {
+                ProcessorDefinitionRenderer.render(buffer, processor);
             }
         }
     }
 
     /**
-     * render a RoutesDefinition
-     */
-    public static void renderRoutes(StringBuilder buffer, RoutesDefinition routes) {
-        // TODO Auto-generated method stub
-
-    }
-
-    /**
-     * render a ProcessorDefiniton
+     * render a set of RouteDefinition
      */
-    private static void renderProcessor(StringBuilder buffer, ProcessorDefinition processor) {
-        if (processor instanceof AggregateDefinition) {
-            AggregateDefinitionRenderer.render(buffer, processor);
-        } else if (processor instanceof ChoiceDefinition) {
-            ChoiceDefinition choice = (ChoiceDefinition)processor;
-            buffer.append(".").append(choice.getShortName()).append("()");
-            for (WhenDefinition when : choice.getWhenClauses()) {
-                renderProcessor(buffer, when);
-            }
-            OtherwiseDefinition other = choice.getOtherwise();
-            if (other != null) {
-                renderProcessor(buffer, other);
-            }
-            buffer.append(".end()");
-            return;
-        } else if (processor instanceof ConvertBodyDefinition) {
-            ConvertBodyDefinition convertBody = (ConvertBodyDefinition)processor;
-            buffer.append(".").append(convertBody.getShortName()).append("(");
-            if (convertBody.getType().equals("[B")) {
-                buffer.append("byte[].class");
-            } else {
-                buffer.append(convertBody.getType()).append(".class");
-            }
-            if (convertBody.getCharset() != null) {
-                buffer.append(", \"").append(convertBody.getCharset()).append("\"");
-            }
-            buffer.append(")");
-        } else if (processor instanceof ExpressionNode) {
-            ExpressionNodeRenderer.render(buffer, processor);
-        } else if (processor instanceof LoadBalanceDefinition) {
-            LoadBalanceDefinition loadB = (LoadBalanceDefinition)processor;
-            // buffer.append(".").append(output.getShortName()).append("()");
-            buffer.append(".").append("loadBalance").append("()");
-
-            LoadBalancer lb = loadB.getLoadBalancerType().getLoadBalancer(null);
-            if (lb instanceof FailOverLoadBalancer) {
-                buffer.append(".failover(");
-                List<Class> exceptions = ((FailOverLoadBalancer)lb).getExceptions();
-                for (Class excep : exceptions) {
-                    buffer.append(excep.getSimpleName()).append(".class");
-                    if (excep != exceptions.get(exceptions.size() - 1)) {
-                        buffer.append(", ");
-                    }
-                }
-                buffer.append(")");
-            } else if (lb instanceof RandomLoadBalancer) {
-                buffer.append(".random()");
-            } else if (lb instanceof RoundRobinLoadBalancer) {
-                buffer.append(".roundRobin()");
-            } else if (lb instanceof StickyLoadBalancer) {
-                buffer.append(".sticky()");
-            } else if (lb instanceof TopicLoadBalancer) {
-                buffer.append(".topic()");
-            }
-
-            List<ProcessorDefinition> branches = loadB.getOutputs();
-            for (ProcessorDefinition branch : branches) {
-                renderProcessor(buffer, branch);
-            }
-            return;
-        } else if (processor instanceof OnCompletionDefinition) {
-            OnCompletionDefinitionRenderer.render(buffer, processor);
-            return;
-        } else if (processor instanceof OnExceptionDefinition) {
-            OnExceptionDefinitionRenderer.render(buffer, processor);
-            return;
-        } else if (processor instanceof OutputDefinition) {
-            OutputDefinitionRenderer.render(buffer, processor);
-        } else if (processor instanceof ResequenceDefinition) {
-            ResequenceDefinition resequence = (ResequenceDefinition)processor;
-            buffer.append(".").append(processor.getShortName()).append("(");
-
-            List<Expression> exps = resequence.getExpressionList();
-            for (Expression exp : exps) {
-                buffer.append(exp.toString()).append("()");
-                if (exp != exps.get(exps.size() - 1)) {
-                    buffer.append(", ");
-                }
-            }
-            buffer.append(")");
-        } else if (processor instanceof RoutingSlipDefinition) {
-            RoutingSlipDefinition routingSlip = (RoutingSlipDefinition)processor;
-            buffer.append(".").append(routingSlip.getShortName()).append("(\"").append(routingSlip.getHeaderName()).append("\", \"").append(routingSlip.getUriDelimiter())
-                .append("\")");
-        } else if (processor instanceof SendDefinition) {
-            SendDefinitionRenderer.render(buffer, processor);
-        } else if (processor instanceof ThrottleDefinition) {
-            ThrottleDefinition throttle = (ThrottleDefinition)processor;
-            buffer.append(".").append(throttle.getShortName()).append("(").append(throttle.getMaximumRequestsPerPeriod()).append(")");
-            if (throttle.getTimePeriodMillis() != 1000) {
-                buffer.append(".timePeriodMillis(").append(throttle.getTimePeriodMillis()).append(")");
+    public static void renderRoutes(StringBuilder buffer, List<RouteDefinition> routes) {
+        for (RouteDefinition route : routes) {
+            renderRoute(buffer, route);
+            if (route != routes.get(routes.size() - 1)) {
+                buffer.append(";");
             }
-        } else {
-            buffer.append(".").append(processor.getShortName()).append("()");
-        }
-
-        List<ProcessorDefinition> outputs = processor.getOutputs();
-
-        for (ProcessorDefinition nextProcessor : outputs) {
-            renderProcessor(buffer, nextProcessor);
         }
     }
+
 }

Added: camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/LoadBalanceDefinitionRenderer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/LoadBalanceDefinitionRenderer.java?rev=803128&view=auto
==============================================================================
--- camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/LoadBalanceDefinitionRenderer.java (added)
+++ camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/LoadBalanceDefinitionRenderer.java Tue Aug 11 13:59:36 2009
@@ -0,0 +1,72 @@
+/**
+ * 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.web.util;
+
+import java.util.List;
+
+import org.apache.camel.model.ChoiceDefinition;
+import org.apache.camel.model.LoadBalanceDefinition;
+import org.apache.camel.model.OtherwiseDefinition;
+import org.apache.camel.model.ProcessorDefinition;
+import org.apache.camel.model.WhenDefinition;
+import org.apache.camel.processor.loadbalancer.FailOverLoadBalancer;
+import org.apache.camel.processor.loadbalancer.LoadBalancer;
+import org.apache.camel.processor.loadbalancer.RandomLoadBalancer;
+import org.apache.camel.processor.loadbalancer.RoundRobinLoadBalancer;
+import org.apache.camel.processor.loadbalancer.StickyLoadBalancer;
+import org.apache.camel.processor.loadbalancer.TopicLoadBalancer;
+
+/**
+ *
+ */
+public class LoadBalanceDefinitionRenderer {
+
+    public static void render(StringBuilder buffer, ProcessorDefinition processor) {
+        LoadBalanceDefinition loadB = (LoadBalanceDefinition)processor;
+        // buffer.append(".").append(output.getShortName()).append("()");
+        buffer.append(".").append("loadBalance").append("()");
+
+        LoadBalancer lb = loadB.getLoadBalancerType().getLoadBalancer(null);
+        if (lb instanceof FailOverLoadBalancer) {
+            buffer.append(".failover(");
+            List<Class> exceptions = ((FailOverLoadBalancer)lb).getExceptions();
+            for (Class excep : exceptions) {
+                buffer.append(excep.getSimpleName()).append(".class");
+                if (excep != exceptions.get(exceptions.size() - 1)) {
+                    buffer.append(", ");
+                }
+            }
+            buffer.append(")");
+        } else if (lb instanceof RandomLoadBalancer) {
+            buffer.append(".random()");
+        } else if (lb instanceof RoundRobinLoadBalancer) {
+            buffer.append(".roundRobin()");
+        } else if (lb instanceof StickyLoadBalancer) {
+            buffer.append(".sticky(");
+            ExpressionRenderer.renderExpression(buffer, ((StickyLoadBalancer)lb).getCorrelationExpression().toString());
+            buffer.append(")");
+        } else if (lb instanceof TopicLoadBalancer) {
+            buffer.append(".topic()");
+        }
+
+        List<ProcessorDefinition> branches = loadB.getOutputs();
+        for (ProcessorDefinition branch : branches) {
+            ProcessorDefinitionRenderer.render(buffer, branch);
+        }
+    }
+}

Modified: camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/OnCompletionDefinitionRenderer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/OnCompletionDefinitionRenderer.java?rev=803128&r1=803127&r2=803128&view=diff
==============================================================================
--- camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/OnCompletionDefinitionRenderer.java (original)
+++ camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/OnCompletionDefinitionRenderer.java Tue Aug 11 13:59:36 2009
@@ -24,7 +24,7 @@
 import org.apache.camel.model.WhenDefinition;
 
 /**
- *
+ *
  */
 public class OnCompletionDefinitionRenderer {
 
@@ -41,7 +41,9 @@
             WhenDefinition when = onComplete.getOnWhen();
             buffer.append(".onWhen");
             if (when.getExpression().getPredicate() != null) {
-                PredicateRenderer.renderPredicate(buffer, when.getExpression().getPredicate());
+                buffer.append("(");
+                PredicateRenderer.render(buffer, when.getExpression().getPredicate());
+                buffer.append(")");
             } else {
                 buffer.append("Unsupported Expression!");
             }
@@ -57,7 +59,6 @@
             SendDefinitionRenderer.render(buffer, branch);
         }
 
-
         // if not a global onCompletion, using end() at the end
         if (notGlobal) {
             buffer.append(".end()");

Modified: camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/OnExceptionDefinitionRenderer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/OnExceptionDefinitionRenderer.java?rev=803128&r1=803127&r2=803128&view=diff
==============================================================================
--- camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/OnExceptionDefinitionRenderer.java (original)
+++ camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/OnExceptionDefinitionRenderer.java Tue Aug 11 13:59:36 2009
@@ -23,7 +23,7 @@
 import org.apache.camel.model.ProcessorDefinition;
 
 /**
- *
+ *
  */
 public class OnExceptionDefinitionRenderer {
 
@@ -45,6 +45,12 @@
         }
         buffer.append(")");
 
+        // render handled() dsl
+        if (onException.getHandledPolicy() != null) {
+            String handled = onException.getHandledPolicy().toString();
+            buffer.append(".handled(").append(handled).append(")");
+        }
+
         List<ProcessorDefinition> branches = onException.getOutputs();
         for (ProcessorDefinition branch : branches) {
             SendDefinitionRenderer.render(buffer, branch);

Modified: camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/OutputDefinitionRenderer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/OutputDefinitionRenderer.java?rev=803128&r1=803127&r2=803128&view=diff
==============================================================================
--- camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/OutputDefinitionRenderer.java (original)
+++ camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/OutputDefinitionRenderer.java Tue Aug 11 13:59:36 2009
@@ -25,6 +25,7 @@
 import org.apache.camel.model.EnrichDefinition;
 import org.apache.camel.model.FinallyDefinition;
 import org.apache.camel.model.InterceptDefinition;
+import org.apache.camel.model.InterceptFromDefinition;
 import org.apache.camel.model.InterceptSendToEndpointDefinition;
 import org.apache.camel.model.MarshalDefinition;
 import org.apache.camel.model.MulticastDefinition;
@@ -46,13 +47,12 @@
 import org.apache.camel.model.UnmarshalDefinition;
 
 /**
- *
+ *
  */
 public class OutputDefinitionRenderer {
 
     public static void render(StringBuilder buffer, ProcessorDefinition processor) {
         OutputDefinition out = (OutputDefinition)processor;
-
         boolean notGlobal = buffer.toString().endsWith(")");
         if (notGlobal) {
             buffer.append(".");
@@ -62,7 +62,6 @@
         if (out instanceof AOPDefinition) {
             buffer.append("()");
             AOPDefinition aop = (AOPDefinition)out;
-
             if (aop.getBeforeUri() != null && aop.getAfterUri() != null) {
                 buffer.append(".around(\"").append(aop.getBeforeUri());
                 buffer.append("\", \"").append(aop.getAfterUri()).append("\")");
@@ -75,32 +74,43 @@
             }
 
         } else if (out instanceof BeanDefinition) {
-
+            // TODO improve it
         } else if (out instanceof EnrichDefinition) {
             String enrich = out.toString();
             String resourceUri = enrich.substring(enrich.indexOf('[') + 1, enrich.indexOf(' '));
             buffer.append("(\"").append(resourceUri).append("\")");
         } else if (out instanceof FinallyDefinition) {
-            
+
         } else if (out instanceof InterceptDefinition) {
+            if (out instanceof InterceptFromDefinition) {
+                InterceptFromDefinition interceptFrom = (InterceptFromDefinition)out;
+                if (interceptFrom.getUri() != null) {
+                    buffer.append("(\"").append(interceptFrom.getUri()).append("\")");
+                    return;
+                }
+            }
             buffer.append("()");
         } else if (out instanceof InterceptSendToEndpointDefinition) {
-
+            InterceptSendToEndpointDefinition interceptSend = (InterceptSendToEndpointDefinition)out;
+            buffer.append("(\"").append(interceptSend.getUri()).append("\")");
+            if (interceptSend.getSkipSendToOriginalEndpoint()) {
+                buffer.append(".skipSendToOriginalEndpoint()");
+            }
         } else if (out instanceof MarshalDefinition) {
             DataFormatDefinition dataFormat = ((MarshalDefinition)out).getDataFormatType();
             buffer.append("().").append(dataFormat.getClass().getAnnotation(XmlRootElement.class).name()).append("()");
         } else if (out instanceof MulticastDefinition) {
-
+            buffer.append("()");
         } else if (out instanceof OtherwiseDefinition) {
             buffer.append("()");
         } else if (out instanceof PipelineDefinition) {
-
+            // transformed into simple ToDefinition
         } else if (out instanceof PolicyDefinition) {
-
+            // TODO improve it
         } else if (out instanceof PollEnrichDefinition) {
-
+            // TODO improve it
         } else if (out instanceof ProcessDefinition) {
-
+            // TODO improve it
         } else if (out instanceof RemoveHeaderDefinition) {
             RemoveHeaderDefinition remove = (RemoveHeaderDefinition)out;
             buffer.append("(\"").append(remove.getHeaderName()).append("\")");
@@ -108,23 +118,22 @@
             RemovePropertyDefinition remove = (RemovePropertyDefinition)out;
             buffer.append("(\"").append(remove.getPropertyName()).append("\")");
         } else if (out instanceof SetExchangePatternDefinition) {
-
+            // TODO improve it
         } else if (out instanceof SortDefinition) {
             SortDefinition sort = (SortDefinition)out;
             buffer.append("(");
             ExpressionRenderer.renderExpression(buffer, sort.getExpression().toString());
             buffer.append(")");
         } else if (out instanceof StopDefinition) {
-
+            buffer.append("()");
         } else if (out instanceof ThreadsDefinition) {
-
+            // TODO improve it
         } else if (out instanceof TransactedDefinition) {
-
+            // TODO improve it
         } else if (out instanceof TryDefinition) {
-
+            // TODO improve it
         } else if (out instanceof UnmarshalDefinition) {
             DataFormatDefinition dataFormat = ((UnmarshalDefinition)out).getDataFormatType();
-            Class clazz = dataFormat.getClass();
             buffer.append("().").append(dataFormat.getClass().getAnnotation(XmlRootElement.class).name()).append("()");
         }
     }

Modified: camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/PredicateRenderer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/PredicateRenderer.java?rev=803128&r1=803127&r2=803128&view=diff
==============================================================================
--- camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/PredicateRenderer.java (original)
+++ camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/PredicateRenderer.java Tue Aug 11 13:59:36 2009
@@ -20,27 +20,160 @@
 import org.apache.camel.Predicate;
 
 /**
- *
+ * render a predicate
  */
 public class PredicateRenderer {
 
-    public static void renderPredicate(StringBuilder buffer, Predicate predicate) {
+    public static void render(StringBuilder buffer, Predicate predicate) {
         String pre = predicate.toString();
-        if (pre.contains("(")) {
-            pre = pre.replaceAll("\\(", "(\"").replaceAll("\\)", "\")");
+        if (pre.startsWith("not (")) {
+            renderNot(buffer, pre);
+        } else if (pre.contains(") and (")) {
+            renderAnd(buffer, pre);
+        } else if (pre.contains(") or (")) {
+            renderOr(buffer, pre);
+        } else if (pre.startsWith("in (")) {
+            renderIn(buffer, pre);
+        } else if (pre.contains(".matches(")) {
+            renderMatches(buffer, pre);
+        } else {
+            render(buffer, pre);
+        }
+    }
+
+    public static void render(StringBuilder buffer, String predicate) {
+        String left = predicate.substring(0, predicate.indexOf(" "));
+        String operation = predicate.substring(predicate.indexOf(" ") + 1, predicate.lastIndexOf(" "));
+        String right = predicate.substring(predicate.lastIndexOf(" ") + 1);
+
+        renderLeft(buffer, left);
+        renderOperation(buffer, operation);
+        renderRight(buffer, right);
+
+    }
 
-            String rightExp = pre.substring(pre.indexOf(" ") + 1);
-            if (rightExp.startsWith("==")) {
-                // replace == with isEqualTo
-                pre = pre.replaceFirst("\\ == ", ".isEqualTo(\"");
-                pre += "\")";
-            } else if (rightExp.startsWith("is not null")) {
-                pre = pre.replaceFirst("\\ is not null", ".isNotNull()");
+    private static void renderAnd(StringBuilder buffer, String predicate) {
+        // (predicate1 and predicate2)
+        buffer.append("and(");
+        String predicate1 = predicate.substring(1, predicate.indexOf(") and ("));
+        String predicate2 = predicate.substring(predicate.indexOf(") and (") + 7, predicate.length() - 1);
+        render(buffer, predicate1);
+        buffer.append(", ");
+        render(buffer, predicate2);
+        buffer.append(")");
+    }
+
+    private static void renderIn(StringBuilder buffer, String predicate) {
+        String predicates[] = predicate.split("in \\(\\[|,\\s+|\\]\\)");
+        if (predicate.contains("convertToEvaluatedType")) {
+            // valueIn
+            String left = predicate.substring(predicate.indexOf("in ([") + 5, predicate.indexOf(" == "));
+            renderLeft(buffer, left);
+            buffer.append(".in(");
+            for (String pre : predicates) {
+                if (pre.equals("")) {
+                    continue;
+                }
+                String value = pre.substring(pre.indexOf(" == ") + 4, pre.indexOf(".convertToEvaluatedType("));
+                buffer.append("\"").append(value).append("\"");
+                if (pre != predicates[predicates.length - 1]) {
+                    buffer.append(", ");
+                }
+            }
+            buffer.append(")");
+        } else {
+            // predicateIn
+            buffer.append("in(");
+            for (String pre : predicates) {
+                if (pre.equals("")) {
+                    continue;
+                }
+                render(buffer, pre);
+                if (pre != predicates[predicates.length - 1]) {
+                    buffer.append(", ");
+                }
             }
-            buffer.append("(").append(pre).append(")");
+            buffer.append(")");
+        }
+    }
+
+    private static void renderLeft(StringBuilder buffer, String left) {
+        if (left.contains("(")) {
+            // header(foo) -> header("foo")
+            buffer.append(left.replaceAll("\\(", "(\"").replaceAll("\\)", "\")"));
+        } else {
+            // body -> body()
+            buffer.append(left).append("()");
+        }
+    }
+
+    private static void renderMatches(StringBuilder buffer, String pre) {
+        // header(foo).matches('pattern')
+        pre = pre.replaceFirst("\\(", "(\"").replaceFirst("\\)", "\")");
+        pre = pre.replaceFirst(".matches\\('", ".regex(\"").replaceFirst("'\\)", "\")");
+        buffer.append(pre);
+    }
+
+    private static void renderNot(StringBuilder buffer, String predicate) {
+        // not(predicate)
+        buffer.append("not(");
+        String notPredicate = predicate.substring(predicate.indexOf("(") + 1, predicate.length() - 1);
+        render(buffer, notPredicate);
+        buffer.append(")");
+    }
+
+    private static void renderOperation(StringBuilder buffer, String operation) {
+        // process the operations
+        if (operation.equals("==")) {
+            buffer.append(".isEqualTo");
+        } else if (operation.equals("!=")) {
+            buffer.append(".isNotEqualTo");
+        } else if (operation.equals("<")) {
+            buffer.append(".isLessThan");
+        } else if (operation.equals("<=")) {
+            buffer.append(".isLessThanOrEqualTo");
+        } else if (operation.equals(">")) {
+            buffer.append(".isGreaterThan");
+        } else if (operation.equals(">=")) {
+            buffer.append(".isGreaterThanOrEqualTo");
+        } else if (operation.equals("contains")) {
+            buffer.append(".contains");
+        } else if (operation.equals("is")) {
+            buffer.append(".isNull()");
+        } else if (operation.equals("is not")) {
+            buffer.append(".isNotNull()");
+        } else if (operation.equals("instanceof")) {
+            buffer.append(".isInstanceOf");
+        } else if (operation.equals("startsWith")) {
+            buffer.append(".startsWith");
+        } else if (operation.equals("endsWith")) {
+            buffer.append(".endsWith");
+        } else if (operation.equals("matches")) {
+            buffer.append(".regex");
+        }
+    }
+
+    private static void renderOr(StringBuilder buffer, String predicate) {
+     // (predicate1 or predicate2)
+        buffer.append("or(");
+        String predicate1 = predicate.substring(1, predicate.indexOf(") or ("));
+        String predicate2 = predicate.substring(predicate.indexOf(") or (") + 6, predicate.length() - 1);
+        render(buffer, predicate1);
+        buffer.append(", ");
+        render(buffer, predicate2);
+        buffer.append(")");
+    }
+
+    private static void renderRight(StringBuilder buffer, String right) {
+        if (right.matches("-?\\d+")) {
+            // number -> number
+            buffer.append("(").append(right).append(")");
+        } else if (right.equals("") || right.equals("null")) {
+            // for isNull() and isNotNull()
+            return;
         } else {
-            String tmp[] = pre.split("\\s+");
-            buffer.append("(").append(tmp[0]).append("().").append(tmp[1]).append("(\"").append(tmp[2]).append("\"))");
+            // string -> "string"
+            buffer.append("(\"").append(right).append("\")");
         }
     }
 

Added: camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/ProcessorDefinitionRenderer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/ProcessorDefinitionRenderer.java?rev=803128&view=auto
==============================================================================
--- camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/ProcessorDefinitionRenderer.java (added)
+++ camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/ProcessorDefinitionRenderer.java Tue Aug 11 13:59:36 2009
@@ -0,0 +1,93 @@
+/**
+ * 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.web.util;
+
+import java.util.List;
+
+import org.apache.camel.Expression;
+import org.apache.camel.model.AggregateDefinition;
+import org.apache.camel.model.ChoiceDefinition;
+import org.apache.camel.model.ConvertBodyDefinition;
+import org.apache.camel.model.ExpressionNode;
+import org.apache.camel.model.LoadBalanceDefinition;
+import org.apache.camel.model.OnCompletionDefinition;
+import org.apache.camel.model.OnExceptionDefinition;
+import org.apache.camel.model.OtherwiseDefinition;
+import org.apache.camel.model.OutputDefinition;
+import org.apache.camel.model.ProcessorDefinition;
+import org.apache.camel.model.ResequenceDefinition;
+import org.apache.camel.model.RollbackDefinition;
+import org.apache.camel.model.RoutingSlipDefinition;
+import org.apache.camel.model.SendDefinition;
+import org.apache.camel.model.ThrottleDefinition;
+import org.apache.camel.model.WhenDefinition;
+import org.apache.camel.processor.loadbalancer.FailOverLoadBalancer;
+import org.apache.camel.processor.loadbalancer.LoadBalancer;
+import org.apache.camel.processor.loadbalancer.RandomLoadBalancer;
+import org.apache.camel.processor.loadbalancer.RoundRobinLoadBalancer;
+import org.apache.camel.processor.loadbalancer.StickyLoadBalancer;
+import org.apache.camel.processor.loadbalancer.TopicLoadBalancer;
+
+/**
+ *
+ */
+public class ProcessorDefinitionRenderer {
+
+    public static void render(StringBuilder buffer, ProcessorDefinition processor) {
+        if (processor instanceof AggregateDefinition) {
+            AggregateDefinitionRenderer.render(buffer, processor);
+        } else if (processor instanceof ChoiceDefinition) {
+            ChoiceDefinitionRenderer.render(buffer, processor);
+            return;
+        } else if (processor instanceof ConvertBodyDefinition) {
+            ConvertBodyDefinitionRenderer.render(buffer, processor);
+        } else if (processor instanceof ExpressionNode) {
+            ExpressionNodeRenderer.render(buffer, processor);
+        } else if (processor instanceof LoadBalanceDefinition) {
+            LoadBalanceDefinitionRenderer.render(buffer, processor);
+            return;
+        } else if (processor instanceof OnCompletionDefinition) {
+            OnCompletionDefinitionRenderer.render(buffer, processor);
+            return;
+        } else if (processor instanceof OnExceptionDefinition) {
+            OnExceptionDefinitionRenderer.render(buffer, processor);
+            return;
+        } else if (processor instanceof OutputDefinition) {
+            OutputDefinitionRenderer.render(buffer, processor);
+        } else if (processor instanceof ResequenceDefinition) {
+            ResequenceDefinitionRenderer.render(buffer, processor);
+        } else if (processor instanceof RollbackDefinition) {
+            RollbackDefinition rollback = (RollbackDefinition)processor;
+            buffer.append(".").append(processor.getShortName()).append("(\"");
+            buffer.append(rollback.getMessage()).append("\")");
+        } else if (processor instanceof RoutingSlipDefinition) {
+            RoutingSlipDefinitionRenderer.render(buffer, processor);
+        } else if (processor instanceof SendDefinition) {
+            SendDefinitionRenderer.render(buffer, processor);
+        } else if (processor instanceof ThrottleDefinition) {
+            ThrottleDefinitionRenderer.render(buffer, processor);
+        } else {
+            buffer.append(".").append(processor.getShortName()).append("()");
+        }
+
+        List<ProcessorDefinition> outputs = processor.getOutputs();
+        for (ProcessorDefinition nextProcessor : outputs) {
+            render(buffer, nextProcessor);
+        }
+    }
+}

Added: camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/ResequenceDefinitionRenderer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/ResequenceDefinitionRenderer.java?rev=803128&view=auto
==============================================================================
--- camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/ResequenceDefinitionRenderer.java (added)
+++ camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/ResequenceDefinitionRenderer.java Tue Aug 11 13:59:36 2009
@@ -0,0 +1,49 @@
+/**
+ * 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.web.util;
+
+import java.util.List;
+
+import org.apache.camel.Expression;
+import org.apache.camel.model.ProcessorDefinition;
+import org.apache.camel.model.ResequenceDefinition;
+
+/**
+ *
+ */
+public class ResequenceDefinitionRenderer {
+
+    public static void render(StringBuilder buffer, ProcessorDefinition processor) {
+        ResequenceDefinition resequence = (ResequenceDefinition)processor;
+        buffer.append(".").append(processor.getShortName()).append("(");
+
+        List<Expression> exps = resequence.getExpressionList();
+        for (Expression exp : exps) {
+            ExpressionRenderer.renderExpression(buffer, exp.toString());
+            if (exp != exps.get(exps.size() - 1)) {
+                buffer.append(", ");
+            }
+        }
+        buffer.append(")");
+
+        if (resequence.getStreamConfig() != null) {
+            // TODO improve stream() support
+            buffer.append(".stream()");
+        }
+    }
+}

Added: camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/RoutingSlipDefinitionRenderer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/RoutingSlipDefinitionRenderer.java?rev=803128&view=auto
==============================================================================
--- camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/RoutingSlipDefinitionRenderer.java (added)
+++ camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/RoutingSlipDefinitionRenderer.java Tue Aug 11 13:59:36 2009
@@ -0,0 +1,33 @@
+/**
+ * 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.web.util;
+
+import org.apache.camel.model.ProcessorDefinition;
+import org.apache.camel.model.RoutingSlipDefinition;
+
+/**
+ *
+ */
+public class RoutingSlipDefinitionRenderer {
+
+    public static void render(StringBuilder buffer, ProcessorDefinition processor) {
+        RoutingSlipDefinition routingSlip = (RoutingSlipDefinition)processor;
+        buffer.append(".").append(routingSlip.getShortName()).append("(\"").append(routingSlip.getHeaderName()).append("\", \"").append(routingSlip.getUriDelimiter())
+            .append("\")");
+    }
+}

Modified: camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/SendDefinitionRenderer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/SendDefinitionRenderer.java?rev=803128&r1=803127&r2=803128&view=diff
==============================================================================
--- camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/SendDefinitionRenderer.java (original)
+++ camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/SendDefinitionRenderer.java Tue Aug 11 13:59:36 2009
@@ -22,7 +22,7 @@
 import org.apache.camel.model.WireTapDefinition;
 
 /**
- *
+ *
  */
 public class SendDefinitionRenderer {
 

Added: camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/ThrottleDefinitionRenderer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/ThrottleDefinitionRenderer.java?rev=803128&view=auto
==============================================================================
--- camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/ThrottleDefinitionRenderer.java (added)
+++ camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/ThrottleDefinitionRenderer.java Tue Aug 11 13:59:36 2009
@@ -0,0 +1,35 @@
+/**
+ * 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.web.util;
+
+import org.apache.camel.model.ProcessorDefinition;
+import org.apache.camel.model.ThrottleDefinition;
+
+/**
+ *
+ */
+public class ThrottleDefinitionRenderer {
+
+    public static void render(StringBuilder buffer, ProcessorDefinition processor) {
+        ThrottleDefinition throttle = (ThrottleDefinition)processor;
+        buffer.append(".").append(throttle.getShortName()).append("(").append(throttle.getMaximumRequestsPerPeriod()).append(")");
+        if (throttle.getTimePeriodMillis() != 1000) {
+            buffer.append(".timePeriodMillis(").append(throttle.getTimePeriodMillis()).append(")");
+        }
+    }
+}

Modified: camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/UriCharactersEncoder.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/UriCharactersEncoder.java?rev=803128&r1=803127&r2=803128&view=diff
==============================================================================
--- camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/UriCharactersEncoder.java (original)
+++ camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/UriCharactersEncoder.java Tue Aug 11 13:59:36 2009
@@ -25,7 +25,7 @@
 import org.apache.commons.logging.LogFactory;
 
 /**
- *
+ *
  */
 public class UriCharactersEncoder {
     private static BitSet unsafeCharacters;

Added: camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/AOPDSLTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/AOPDSLTest.java?rev=803128&view=auto
==============================================================================
--- camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/AOPDSLTest.java (added)
+++ camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/AOPDSLTest.java Tue Aug 11 13:59:36 2009
@@ -0,0 +1,67 @@
+/**
+ * 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.web.groovy;
+
+/**
+ *
+ */
+public class AOPDSLTest extends GroovyRendererTestSupport {
+
+    public void testAOPAfter() throws Exception {
+        String DSL = "from(\"direct:start\").aop().after(\"mock:after\").transform(constant(\"Bye World\")).to(\"mock:result\")";
+        String expectedDSL = DSL;
+
+        assertEquals(expectedDSL, render(DSL));
+    }
+
+    public void _testAOPAfterFinally() throws Exception {
+        String DSL = "from(\"direct:start\").aop().afterFinally(\"mock:after\").choice().when(body().isEqualTo(\"Hello World\")).transform(constant(\"Bye World\")).otherwise().transform(constant(\"Kabom the World\")).throwException(new IllegalArgumentException(\"Damn\")).end().to(\"mock:result\")";
+        String expectedDSL = DSL;
+
+        assertEquals(expectedDSL, render(DSL));
+    }
+
+    public void testAOPAround() throws Exception {
+        String DSL = "from(\"direct:start\").aop().around(\"mock:before\", \"mock:after\").transform(constant(\"Bye World\")).to(\"mock:result\")";
+        String expectedDSL = DSL;
+
+        assertEquals(expectedDSL, render(DSL));
+    }
+
+    public void _testAOPAroundFinally() throws Exception {
+        String DSL = "from(\"direct:start\").aop().aroundFinally(\"mock:before\", \"mock:after\").choice().when(body().isEqualTo(\"Hello World\")).transform(constant(\"Bye World\")).otherwise().transform(constant(\"Kabom the World\")).throwException(new IllegalArgumentException(\"Damn\")).end()to(\"mock:result\")";
+        String expectedDSL = DSL;
+
+        assertEquals(expectedDSL, render(DSL));
+    }
+
+    public void testAOPBefore() throws Exception {
+        String DSL = "from(\"direct:start\").aop().before(\"mock:before\").transform(constant(\"Bye World\")).to(\"mock:result\")";
+        String expectedDSL = DSL;
+
+        assertEquals(expectedDSL, render(DSL));
+    }
+
+    public void testAOPNestedRoute() throws Exception {
+        String DSL = "from(\"direct:start\").to(\"mock:start\").aop().around(\"mock:before\", \"mock:after\").transform(constant(\"Bye\")).to(\"mock:middle\").transform(body().append(\" World\")).end().transform(body().prepend(\"Bye \")).to(\"mock:result\")";
+        String expectedDSL = "from(\"direct:start\").to(\"mock:start\").aop().around(\"mock:before\", \"mock:after\").transform(constant(\"Bye\")).to(\"mock:middle\").transform(body().append(\" World\")).transform(body().prepend(\"Bye \")).to(\"mock:result\")";
+
+        assertEquals(expectedDSL, render(DSL));
+    }
+
+}

Modified: camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/ChoiceDSLTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/ChoiceDSLTest.java?rev=803128&r1=803127&r2=803128&view=diff
==============================================================================
--- camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/ChoiceDSLTest.java (original)
+++ camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/ChoiceDSLTest.java Tue Aug 11 13:59:36 2009
@@ -34,7 +34,7 @@
 
     public void testChoiceWithPredication() throws Exception {
         String DSL = "from(\"direct:start\").choice()" +
-         ".when(header(\"username\").isNotNull()).to(\"mock:god\")" +
+         ".when(header(\"username\").isNull()).to(\"mock:god\")" +
          ".when(header(\"admin\").isEqualTo(\"true\")).to(\"mock:admin\")" +
          ".otherwise().to(\"mock:guest\")" +
          ".end()";
@@ -47,7 +47,9 @@
         String DSL = "from(\"direct:start\").split().body().choice()" +
          ".when().method(\"orderItemHelper\", \"isWidget\").to(\"bean:widgetInventory\", \"seda:aggregate\")" +
          ".otherwise().to(\"bean:gadgetInventory\", \"seda:aggregate\")";
-        String expectedDSL = "from(\"direct:start\").split().body().choice()" +
+        
+        //TODO check this result
+        String expectedDSL = "from(\"direct:start\").split(body()).choice()" +
          ".when().method(\"orderItemHelper\", \"isWidget\").to(\"bean:widgetInventory\").to(\"seda:aggregate\")" +
          ".otherwise().to(\"bean:gadgetInventory\").to(\"seda:aggregate\")" +
          ".end()";

Modified: camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/GroovyRendererTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/GroovyRendererTest.java?rev=803128&r1=803127&r2=803128&view=diff
==============================================================================
--- camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/GroovyRendererTest.java (original)
+++ camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/GroovyRendererTest.java Tue Aug 11 13:59:36 2009
@@ -39,16 +39,13 @@
         }
     }
 
-    public void _testRoutes() throws Exception {
-        FileReader reader = new FileReader("src/test/resources/testedRoutes.txt");
+    public void testRoutes() throws Exception {
+        FileReader reader = new FileReader("src/test/resources/routes.txt");
         BufferedReader br = new BufferedReader(reader);
         String dsl = null;
         while ((dsl = br.readLine()) != null) {
-            if (dsl.startsWith("#")) {
-                continue;
-            }
             System.out.println("dsl: " + dsl);
-            System.out.println("after rendered: \n" + render(dsl));
+            System.out.println("after rendered: \n" + renderRoutes(dsl));
             System.out.println();
         }
     }

Modified: camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/GroovyRendererTestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/GroovyRendererTestSupport.java?rev=803128&r1=803127&r2=803128&view=diff
==============================================================================
--- camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/GroovyRendererTestSupport.java (original)
+++ camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/GroovyRendererTestSupport.java Tue Aug 11 13:59:36 2009
@@ -26,6 +26,7 @@
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.model.RouteDefinition;
+import org.apache.camel.model.RoutesDefinition;
 import org.apache.camel.web.util.GroovyRenderer;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -43,18 +44,11 @@
 
     private CamelContext context;
 
-    public RouteDefinition createRoute(String dsl) throws Exception {
-        if (context != null) {
-            context.stop();
-        }
-        context = new DefaultCamelContext();
-
-        String routeStr = header + dsl + footer;
-        GroovyClassLoader classLoader = new GroovyClassLoader();
-        Class clazz = classLoader.parseClass(routeStr);
-        RouteBuilder builder = (RouteBuilder)clazz.newInstance();
-
-        context.addRoutes(builder);
+    /**
+     * get the first route in camelContext
+     */
+    public RouteDefinition getRoute(String dsl) throws Exception {
+        createAndAddRoute(dsl);
         List<RouteDefinition> list = context.getRouteDefinitions();
         if (!list.isEmpty()) {
             return list.get(0);
@@ -62,8 +56,16 @@
         return null;
     }
 
+    /**
+     * get all routes in camelContext
+     */
+    public List<RouteDefinition> getRoutes(String dsl) throws Exception {
+        createAndAddRoute(dsl);
+        return context.getRouteDefinitions();
+    }
+
     public String render(String dsl) throws Exception {
-        RouteDefinition route = createRoute(dsl);
+        RouteDefinition route = getRoute(dsl);
         assertNotNull(route);
 
         StringBuilder sb = new StringBuilder();
@@ -71,4 +73,29 @@
         return sb.toString();
     }
 
+    public String renderRoutes(String dsl) throws Exception {
+        List<RouteDefinition> routes = getRoutes(dsl);
+
+        StringBuilder sb = new StringBuilder();
+        GroovyRenderer.renderRoutes(sb, routes);
+        return sb.toString();
+    }
+
+    /**
+     * create routes using the dsl and add them into camelContext
+     */
+    private void createAndAddRoute(String dsl) throws Exception, InstantiationException, IllegalAccessException {
+        if (context != null) {
+            context.stop();
+        }
+        context = new DefaultCamelContext();
+
+        String routeStr = header + dsl + footer;
+        GroovyClassLoader classLoader = new GroovyClassLoader();
+        Class clazz = classLoader.parseClass(routeStr);
+        RouteBuilder builder = (RouteBuilder)clazz.newInstance();
+
+        context.addRoutes(builder);
+    }
+
 }

Added: camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/InterceptDSLTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/InterceptDSLTest.java?rev=803128&view=auto
==============================================================================
--- camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/InterceptDSLTest.java (added)
+++ camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/InterceptDSLTest.java Tue Aug 11 13:59:36 2009
@@ -0,0 +1,53 @@
+/**
+ * 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.web.groovy;
+
+/**
+ *
+ */
+public class InterceptDSLTest extends GroovyRendererTestSupport {
+
+    public void testIntercept() throws Exception {
+        String DSL = "intercept().to(\"mock:intercepted\");from(\"direct:start\").to(\"mock:foo\").to(\"mock:bar\").to(\"mock:result\")";
+        String expectedDSL = DSL;
+
+        assertEquals(expectedDSL, render(DSL));
+    }
+
+    public void testInterceptStop() throws Exception {
+        String DSL = "intercept().to(\"mock:intercepted\").stop();from(\"direct:start\").to(\"mock:foo\").to(\"mock:bar\").to(\"mock:result\")";
+        String expectedDSL = DSL;
+
+        assertEquals(expectedDSL, render(DSL));
+    }
+
+    public void testInterceptWhen() throws Exception {
+        String DSL = "intercept().when(body().contains(\"Hello\")).to(\"mock:intercepted\");from(\"direct:start\").to(\"mock:foo\").to(\"mock:bar\").to(\"mock:result\")";
+        String expectedDSL = "intercept().choice().when(body().contains(\"Hello\")).to(\"mock:intercepted\").end();from(\"direct:start\").to(\"mock:foo\").to(\"mock:bar\").to(\"mock:result\")";
+
+        assertEquals(expectedDSL, render(DSL));
+    }
+
+    public void testInterceptWhenStop() throws Exception {
+        String DSL = "intercept().when(body().contains(\"Hello\")).to(\"mock:intercepted\").stop();from(\"direct:start\").to(\"mock:foo\").to(\"mock:bar\").to(\"mock:result\")";
+        String expectedDSL = "intercept().choice().when(body().contains(\"Hello\")).to(\"mock:intercepted\").stop().end();from(\"direct:start\").to(\"mock:foo\").to(\"mock:bar\").to(\"mock:result\")";
+
+        assertEquals(expectedDSL, render(DSL));
+    }
+
+}

Added: camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/InterceptFromDSLTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/InterceptFromDSLTest.java?rev=803128&view=auto
==============================================================================
--- camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/InterceptFromDSLTest.java (added)
+++ camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/InterceptFromDSLTest.java Tue Aug 11 13:59:36 2009
@@ -0,0 +1,79 @@
+/**
+ * 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.web.groovy;
+
+/**
+ *
+ */
+public class InterceptFromDSLTest extends GroovyRendererTestSupport {
+
+    public void testInterceptFromChoice() throws Exception {
+        String DSL = "interceptFrom().choice().when(header(\"foo\").isEqualTo(\"bar\")).to(\"mock:b\").stop().end();from(\"direct:start\").to(\"mock:a\")";
+        String expectedDSL = DSL;
+
+        assertEquals(expectedDSL, render(DSL));
+    }
+
+    public void testInterceptFromPredicateWithStop() throws Exception {
+        String DSL = "interceptFrom().when(header(\"usertype\").isEqualTo(\"test\")).stop();from(\"direct:start\").to(\"mock:result\")";
+        String expectedDSL = "interceptFrom().choice().when(header(\"usertype\").isEqualTo(\"test\")).stop().end();from(\"direct:start\").to(\"mock:result\")";
+
+        assertEquals(expectedDSL, render(DSL));
+    }
+
+    public void testInterceptFromToLog() throws Exception {
+        String DSL = "interceptFrom().to(\"log:received\");from(\"direct:start\").to(\"mock:result\")";
+        String expectedDSL = DSL;
+
+        assertEquals(expectedDSL, render(DSL));
+    }
+
+    public void testInterceptFromUriRegex() throws Exception {
+        String DSL = "interceptFrom(\"seda:(bar|foo)\").to(\"mock:intercept\");from(\"direct:start\").to(\"mock:result\");from(\"seda:bar\").to(\"mock:result\");from(\"seda:foo\").to(\"mock:result\");from(\"seda:cheese\").to(\"mock:result\")";
+        String expectedDSL = "from(\"direct:start\").to(\"mock:result\");" +
+         "interceptFrom(\"seda:(bar|foo)\").to(\"mock:intercept\");from(\"seda:bar\").to(\"mock:result\");" +
+         "interceptFrom(\"seda:(bar|foo)\").to(\"mock:intercept\");from(\"seda:foo\").to(\"mock:result\");" +
+         "from(\"seda:cheese\").to(\"mock:result\")";
+
+        assertEquals(expectedDSL, renderRoutes(DSL));
+    }
+
+    public void testInterceptFromUriSimpleLog() throws Exception {
+        String DSL = "interceptFrom(\"seda:bar\").to(\"mock:bar\");from(\"direct:start\").to(\"mock:first\").to(\"seda:bar\");from(\"seda:bar\").to(\"mock:result\");from(\"seda:foo\").to(\"mock:result\")";
+        String expectedDSL = "from(\"direct:start\").to(\"mock:first\").to(\"seda:bar\");interceptFrom(\"seda:bar\").to(\"mock:bar\");from(\"seda:bar\").to(\"mock:result\");from(\"seda:foo\").to(\"mock:result\")";
+
+        assertEquals(expectedDSL, renderRoutes(DSL));
+    }
+
+    public void testInterceptFromUriWildcard() throws Exception {
+        String DSL = "interceptFrom(\"seda*\").to(\"mock:intercept\");from(\"direct:start\").to(\"mock:result\");from(\"seda:bar\").to(\"mock:result\");from(\"seda:foo\").to(\"mock:result\")";
+        String expectedDSL = "from(\"direct:start\").to(\"mock:result\");" +
+         "interceptFrom(\"seda*\").to(\"mock:intercept\");from(\"seda:bar\").to(\"mock:result\");" +
+         "interceptFrom(\"seda*\").to(\"mock:intercept\");from(\"seda:foo\").to(\"mock:result\")";
+        
+        assertEquals(expectedDSL, renderRoutes(DSL));
+    }
+
+    public void testInterceptFromWithPredicate() throws Exception {
+        String DSL = "interceptFrom().when(header(\"foo\").isEqualTo(\"bar\")).to(\"mock:b\").stop();from(\"direct:start\").to(\"mock:a\")";
+        String expectedDSL = "interceptFrom().choice().when(header(\"foo\").isEqualTo(\"bar\")).to(\"mock:b\").stop().end();from(\"direct:start\").to(\"mock:a\")";
+
+        assertEquals(expectedDSL, render(DSL));
+    }
+
+}

Added: camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/InterceptSendToEndpointDSLTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/InterceptSendToEndpointDSLTest.java?rev=803128&view=auto
==============================================================================
--- camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/InterceptSendToEndpointDSLTest.java (added)
+++ camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/InterceptSendToEndpointDSLTest.java Tue Aug 11 13:59:36 2009
@@ -0,0 +1,53 @@
+/**
+ * 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.web.groovy;
+
+/**
+ *
+ */
+public class InterceptSendToEndpointDSLTest extends GroovyRendererTestSupport {
+
+    public void testInterceptSendToEndpoint() throws Exception {
+        String DSL = "interceptSendToEndpoint(\"mock:foo\").to(\"mock:detour\").transform(constant(\"Bye World\"));from(\"direct:first\").to(\"mock:bar\").to(\"mock:foo\").to(\"mock:result\")";
+        String expectedDSL = DSL;
+
+        assertEquals(expectedDSL, render(DSL));
+    }
+
+    public void testInterceptSendToEndpointDynamic() throws Exception {
+        String DSL = "interceptSendToEndpoint(\"file:*\").skipSendToOriginalEndpoint().to(\"mock:detour\");from(\"direct:first\").to(\"file://foo\").to(\"file://bar\").to(\"mock:result\")";
+        String expectedDSL = DSL;
+
+        assertEquals(expectedDSL, render(DSL));
+    }
+
+    public void testInterceptSendToEndpointInOnException() throws Exception {
+        String DSL = "onException(IOException.class).handled(true).to(\"mock:io\");interceptSendToEndpoint(\"mock:io\").skipSendToOriginalEndpoint().to(\"mock:intercepted\");from(\"direct:start\").to(\"mock:foo\").to(\"mock:result\")";
+        String expectedDSL = DSL;
+
+        assertEquals(expectedDSL, render(DSL));
+    }
+
+    public void _testInterceptSendToIssue() throws Exception {
+        String DSL = "interceptSendToEndpoint(\"direct:foo\").to(\"mock:foo\");from(\"direct:start\").setHeader(Exchange.FILE_NAME, constant(\"hello.txt\")).to(\"direct:foo\")";
+        String expectedDSL = DSL;
+
+        assertEquals(expectedDSL, render(DSL));
+    }
+
+}

Modified: camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/LoadBalanceDSLTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/LoadBalanceDSLTest.java?rev=803128&r1=803127&r2=803128&view=diff
==============================================================================
--- camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/LoadBalanceDSLTest.java (original)
+++ camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/LoadBalanceDSLTest.java Tue Aug 11 13:59:36 2009
@@ -36,4 +36,11 @@
         assertEquals(expectedDSL, render(DSL));
     }
 
+ public void testLoadBalanceSticky() throws Exception {
+        String DSL = "from(\"direct:start\").loadBalance().sticky(header(\"foo\")).to(\"mock:x\", \"mock:y\", \"mock:z\")";
+        String expectedDSL = "from(\"direct:start\").loadBalance().sticky(header(\"foo\")).to(\"mock:x\").to(\"mock:y\").to(\"mock:z\")";
+
+        assertEquals(expectedDSL, render(DSL));
+    }
+
 }

Added: camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/MulticastDSLTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/MulticastDSLTest.java?rev=803128&view=auto
==============================================================================
--- camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/MulticastDSLTest.java (added)
+++ camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/MulticastDSLTest.java Tue Aug 11 13:59:36 2009
@@ -0,0 +1,31 @@
+/**
+ * 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.web.groovy;
+
+/**
+ *
+ */
+public class MulticastDSLTest extends GroovyRendererTestSupport {
+
+    public void testMulticast() throws Exception {
+        String DSL = "from(\"direct:a\").multicast().to(\"mock:x\", \"mock:y\", \"mock:z\")";
+        String expectedDSL = "from(\"direct:a\").multicast().to(\"mock:x\").to(\"mock:y\").to(\"mock:z\")";
+
+        assertEquals(expectedDSL, render(DSL));
+    }
+}

Added: camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/OnCompletionDSLTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/OnCompletionDSLTest.java?rev=803128&view=auto
==============================================================================
--- camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/OnCompletionDSLTest.java (added)
+++ camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/OnCompletionDSLTest.java Tue Aug 11 13:59:36 2009
@@ -0,0 +1,89 @@
+/**
+ * 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.web.groovy;
+
+/**
+ *
+ */
+public class OnCompletionDSLTest extends GroovyRendererTestSupport {
+
+    public void testOnCompletionAndIntercept() throws Exception {
+        String DSL = "intercept().to(\"mock:intercept\");from(\"direct:start\").onCompletion().to(\"log:sync\").to(\"mock:sync\").end().to(\"mock:result\")";
+        String expectedDSL = DSL;
+
+        assertEquals(expectedDSL, render(DSL));
+    }
+
+    public void testOnCompletionAndInterceptAndOnException() throws Exception {
+        String DSL = "intercept().to(\"mock:intercept\");onCompletion().to(\"log:global\").to(\"mock:sync\");onException(Exception.class).to(\"mock:exception\");from(\"direct:start\").to(\"mock:result\")";
+        // the order is changed
+        String expectedDSL = "onException(Exception.class).to(\"mock:exception\");intercept().to(\"mock:intercept\");onCompletion().to(\"log:global\").to(\"mock:sync\");from(\"direct:start\").to(\"mock:result\")";
+
+        assertEquals(expectedDSL, render(DSL));
+    }
+
+    public void testOnCompletionDSL() throws Exception {
+        String DSL = "from(\"direct:start\").onCompletion().to(\"log:sync\").to(\"mock:sync\").end().to(\"mock:result\")";
+        String expectedDSL = DSL;
+
+        assertEquals(expectedDSL, render(DSL));
+    }
+
+    public void testOnCompletionGlobal() throws Exception {
+        String DSL = "onCompletion().to(\"log:global\").to(\"mock:sync\");from(\"direct:start\").to(\"mock:result\")";
+        String expectedDSL = DSL;
+
+        assertEquals(expectedDSL, render(DSL));
+    }
+
+    public void testOnCompletionMoreGlobal() throws Exception {
+        String DSL = "onCompletion().to(\"log:global\").to(\"mock:sync\");onCompletion().to(\"log:global\").to(\"mock:two\");onCompletion().onCompleteOnly().to(\"log:global\").to(\"mock:complete\");onCompletion().onFailureOnly().to(\"log:global\").to(\"mock:failure\");from(\"direct:start\").to(\"mock:result\")";
+        String expectedDSL = DSL;
+
+        assertEquals(expectedDSL, render(DSL));
+    }
+
+    public void testOnCompletionOnly() throws Exception {
+        String DSL = "from(\"direct:start\").onCompletion().onCompleteOnly().to(\"log:sync\").to(\"mock:sync\").end().to(\"mock:result\")";
+        String expectedDSL = DSL;
+
+        assertEquals(expectedDSL, render(DSL));
+    }
+
+    public void testOnCompletionRouteScopeOverrideGlobalScope() throws Exception {
+        String DSL = "onCompletion().to(\"log:global\").to(\"mock:global\");from(\"direct:start\").onCompletion().to(\"log:route\").to(\"mock:sync\").end().to(\"mock:result\")";
+        // the global onCompletion is removed
+        String expectedDSL = "from(\"direct:start\").onCompletion().to(\"log:route\").to(\"mock:sync\").end().to(\"mock:result\")";
+
+        assertEquals(expectedDSL, render(DSL));
+    }
+
+    public void testOnCompletionWhen() throws Exception {
+        String DSL = "from(\"direct:start\").onCompletion().onWhen(body().contains(\"Hello\")).to(\"log:sync\").to(\"mock:sync\").end().to(\"log:original\").to(\"mock:result\")";
+        String expectedDSL = DSL;
+
+        assertEquals(expectedDSL, render(DSL));
+    }
+
+    public void testOnFailureOnly() throws Exception {
+        String DSL = "from(\"direct:start\").onCompletion().onFailureOnly().to(\"log:sync\").to(\"mock:sync\").end().to(\"mock:result\")";
+        String expectedDSL = DSL;
+
+        assertEquals(expectedDSL, render(DSL));
+    }
+}