svn commit: r803100 - 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/java/o...

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

svn commit: r803100 - 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/java/o...

janstey-3
Author: janstey
Date: Tue Aug 11 13:02:41 2009
New Revision: 803100

URL: http://svn.apache.org/viewvc?rev=803100&view=rev
Log:
CAMEL-1392 - add Split, InterceptFrom, InterceptSendToEndpoint DSL support and improve LoadBalancer, Stream, StreamCaching support

Thanks to Xueqiang Mi!


Added:
    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/InterceptSendToEndpointDSLTest.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/ResequenceDSLTest.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/StreamCachingDSLTest.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
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/InterceptSendToEndpointDefinition.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/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/OnExceptionDefinitionRenderer.java
    camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/OutputDefinitionRenderer.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/LoadBalanceDSLTest.java
    camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/SortDSLTest.java
    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=803100&r1=803099&r2=803100&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:02:41 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/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=803100&r1=803099&r2=803100&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:02:41 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/ExpressionNodeRenderer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/ExpressionNodeRenderer.java?rev=803100&r1=803099&r2=803100&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:02:41 2009
@@ -105,11 +105,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();

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=803100&r1=803099&r2=803100&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:02:41 2009
@@ -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=803100&r1=803099&r2=803100&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:02:41 2009
@@ -80,7 +80,7 @@
         // render the global dsl not started with from, like global
         // onCompletion, onException, intercept
         for (ProcessorDefinition processor : outputs) {
-            if (processor.getParent() == null) {
+            if (processor.getParent() == null && !(processor instanceof SendDefinition)) {
                 renderProcessor(buffer, processor);
                 buffer.append(";");
             }
@@ -96,9 +96,14 @@
         }
         buffer.append(")");
 
+        // render some route configurations
+        if (route.isStreamCache() != null && route.isStreamCache()) {
+            buffer.append(".streamCaching()");
+        }
+
         // render the outputs of the router
         for (ProcessorDefinition processor : outputs) {
-            if (processor.getParent() == route) {
+            if (processor.getParent() == route || processor instanceof SendDefinition) {
                 renderProcessor(buffer, processor);
             }
         }
@@ -165,7 +170,9 @@
             } else if (lb instanceof RoundRobinLoadBalancer) {
                 buffer.append(".roundRobin()");
             } else if (lb instanceof StickyLoadBalancer) {
-                buffer.append(".sticky()");
+                buffer.append(".sticky(");
+                ExpressionRenderer.renderExpression(buffer, ((StickyLoadBalancer)lb).getCorrelationExpression().toString());
+                buffer.append(")");
             } else if (lb instanceof TopicLoadBalancer) {
                 buffer.append(".topic()");
             }
@@ -189,12 +196,18 @@
 
             List<Expression> exps = resequence.getExpressionList();
             for (Expression exp : exps) {
-                buffer.append(exp.toString()).append("()");
+                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()");
+            }
+
         } else if (processor instanceof RoutingSlipDefinition) {
             RoutingSlipDefinition routingSlip = (RoutingSlipDefinition)processor;
             buffer.append(".").append(routingSlip.getShortName()).append("(\"").append(routingSlip.getHeaderName()).append("\", \"").append(routingSlip.getUriDelimiter())

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=803100&r1=803099&r2=803100&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:02:41 2009
@@ -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=803100&r1=803099&r2=803100&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:02:41 2009
@@ -17,14 +17,18 @@
 
 package org.apache.camel.web.util;
 
+import java.util.List;
+
 import javax.xml.bind.annotation.XmlRootElement;
 
 import org.apache.camel.model.AOPDefinition;
 import org.apache.camel.model.BeanDefinition;
+import org.apache.camel.model.ChoiceDefinition;
 import org.apache.camel.model.DataFormatDefinition;
 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;
@@ -44,6 +48,7 @@
 import org.apache.camel.model.TransactedDefinition;
 import org.apache.camel.model.TryDefinition;
 import org.apache.camel.model.UnmarshalDefinition;
+import org.apache.camel.model.WhenDefinition;
 
 /**
  *
@@ -81,11 +86,20 @@
             String resourceUri = enrich.substring(enrich.indexOf('[') + 1, enrich.indexOf(' '));
             buffer.append("(\"").append(resourceUri).append("\")");
         } else if (out instanceof FinallyDefinition) {
-            
+
         } else if (out instanceof InterceptDefinition) {
             buffer.append("()");
-        } else if (out instanceof InterceptSendToEndpointDefinition) {
+            if (out instanceof InterceptFromDefinition) {
 
+            } else {
+
+            }
+        } 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("()");
@@ -115,7 +129,7 @@
             ExpressionRenderer.renderExpression(buffer, sort.getExpression().toString());
             buffer.append(")");
         } else if (out instanceof StopDefinition) {
-
+            buffer.append("()");
         } else if (out instanceof ThreadsDefinition) {
 
         } else if (out instanceof TransactedDefinition) {
@@ -124,7 +138,6 @@
 
         } else if (out instanceof UnmarshalDefinition) {
             DataFormatDefinition dataFormat = ((UnmarshalDefinition)out).getDataFormatType();
-            Class clazz = dataFormat.getClass();
             buffer.append("().").append(dataFormat.getClass().getAnnotation(XmlRootElement.class).name()).append("()");
         }
     }

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=803100&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:02:41 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=803100&r1=803099&r2=803100&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:02:41 2009
@@ -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()";

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=803100&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:02:41 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/InterceptSendToEndpointDSLTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/InterceptSendToEndpointDSLTest.java?rev=803100&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:02:41 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=803100&r1=803099&r2=803100&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:02:41 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/OnCompletionDSLTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/OnCompletionDSLTest.java?rev=803100&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:02:41 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 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 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 testOnCompleteOnly() 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 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));
+    }
+
+    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 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 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));
+    }
+}

Added: camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/ResequenceDSLTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/ResequenceDSLTest.java?rev=803100&view=auto
==============================================================================
--- camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/ResequenceDSLTest.java (added)
+++ camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/ResequenceDSLTest.java Tue Aug 11 13:02:41 2009
@@ -0,0 +1,38 @@
+/**
+ * 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 ResequenceDSLTest extends GroovyRendererTestSupport {
+
+    public void testResequence() throws Exception {
+        String DSL = "from(\"direct:start\").resequence(body()).to(\"mock:result\")";
+        String expectedDSL = DSL;
+
+        assertEquals(expectedDSL, render(DSL));
+    }
+
+    public void testResequencer() throws Exception {
+        String DSL = "from(\"direct:start\").resequencer(header(\"seqnum\")).stream().to(\"mock:result\")";
+        String expectedDSL = "from(\"direct:start\").resequence(header(\"seqnum\")).stream().to(\"mock:result\")";
+
+        assertEquals(expectedDSL, render(DSL));
+    }
+}

Modified: camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/SortDSLTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/SortDSLTest.java?rev=803100&r1=803099&r2=803100&view=diff
==============================================================================
--- camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/SortDSLTest.java (original)
+++ camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/SortDSLTest.java Tue Aug 11 13:02:41 2009
@@ -22,7 +22,7 @@
  */
 public class SortDSLTest extends GroovyRendererTestSupport {
 
-    public void testRecipientList() throws Exception {
+    public void testSort() throws Exception {
         String DSL = "from(\"direct:start\").sort(body().tokenize(\",\")).to(\"bean:MyServiceBean.processLine\")";
         String expectedDSL = DSL;
 

Added: camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/SplitDSLTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/SplitDSLTest.java?rev=803100&view=auto
==============================================================================
--- camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/SplitDSLTest.java (added)
+++ camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/SplitDSLTest.java Tue Aug 11 13:02:41 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 SplitDSLTest extends GroovyRendererTestSupport {
+
+    public void testSplitStream() throws Exception {
+        String DSL = "from(\"direct:start\").split(body().tokenize(\",\")).streaming().to(\"mock:result\")";
+        String expectedDSL = DSL;
+
+        assertEquals(expectedDSL, render(DSL));
+    }
+
+    public void testSplitTokenize() throws Exception {
+        String DSL = "from(\"direct:start\").split(body(String.class).tokenize(\",\")).to(\"mock:result\")";
+        String expectedDSL = DSL;
+
+        assertEquals(expectedDSL, render(DSL));
+    }
+
+    public void testSplitMethod() throws Exception {
+        String DSL = "from(\"direct:start\").split().method(\"mySplitterBean\", \"splitBody\").to(\"mock:result\")";
+        String expectedDSL = DSL;
+
+        assertEquals(expectedDSL, render(DSL));
+    }
+
+    public void _testSplitXPath() throws Exception {
+        String DSL = "from(\"direct:start\").split(xpath(\"//foo/bar\")).convertBodyTo(String.class).to(\"mock:result\")";
+        String expectedDSL = DSL;
+
+        assertEquals(expectedDSL, render(DSL));
+    }
+
+}

Added: camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/StreamCachingDSLTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/StreamCachingDSLTest.java?rev=803100&view=auto
==============================================================================
--- camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/StreamCachingDSLTest.java (added)
+++ camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/StreamCachingDSLTest.java Tue Aug 11 13:02:41 2009
@@ -0,0 +1,32 @@
+/**
+ * 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 StreamCachingDSLTest extends GroovyRendererTestSupport {
+
+    public void test() throws Exception {
+        String DSL = "from(\"direct:start\").streamCaching().to(\"mock:result\")";
+        String expectedDSL = DSL;
+
+        assertEquals(expectedDSL, render(DSL));
+    }
+
+}

Added: camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/util/UriCharachersEncoderTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/util/UriCharachersEncoderTest.java?rev=803100&view=auto
==============================================================================
--- camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/util/UriCharachersEncoderTest.java (added)
+++ camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/util/UriCharachersEncoderTest.java Tue Aug 11 13:02:41 2009
@@ -0,0 +1,40 @@
+/**
+ * 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 junit.framework.TestCase;
+
+/**
+ *
+ */
+public class UriCharachersEncoderTest extends TestCase {
+    public void testEncoder() {
+        String afterEncoding = "direct:%2F%2Fstart";
+        String beforeEncoding = "direct://start";
+
+        String result = UriCharactersEncoder.encode(beforeEncoding);
+        assertEquals("Get the wrong encoding result", afterEncoding, result);
+    }
+
+    public void testNoEncoding() {
+        String noEncoding = "direct:start";
+        String result = UriCharactersEncoder.encode(noEncoding);
+        assertEquals("Get the wrong encoding result", noEncoding, result);
+    }
+
+}

Modified: camel/trunk/components/camel-web/src/test/resources/testedRoutes.txt
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/test/resources/testedRoutes.txt?rev=803100&r1=803099&r2=803100&view=diff
==============================================================================
--- camel/trunk/components/camel-web/src/test/resources/testedRoutes.txt (original)
+++ camel/trunk/components/camel-web/src/test/resources/testedRoutes.txt Tue Aug 11 13:02:41 2009
@@ -35,7 +35,8 @@
 from("direct:start").filter(body().contains("World")).to("mock:result")
 #########################loadBalance#########################
 from("direct:start").loadBalance().random().to("mock:x", "mock:y", "mock:z")
-#from("direct:start").loadBalance().failover(IOException.class).to("direct:x", "direct:y") // No getExceptions method for FailOverLoadBalancer
+from("direct:start").loadBalance().failover(IOException.class).to("mock:x", "mock:y", "mock:z")
+from("direct:start").loadBalance().sticky(header("foo")).to("mock:x", "mock:y", "mock:z")
 #########################loop#########################
 from("direct:start").loop(8).to("mock:result")
 from("direct:start").loop(header("loop")).to("mock:result")
@@ -49,7 +50,12 @@
 #########################recipientList#########################
 from("direct:start").recipientList(header("recipientListHeader").tokenize(","))
 #########################resequencer#########################
+<<<<<<< .mine
+from("direct:start").resequence(body()).to("mock:result")
+from("direct:start").resequencer(header("seqnum")).stream().to("mock:result")
+=======
 #from("direct:start").resequence(body()).to("mock:result")
+>>>>>>> .r801852
 #########################routingSlip#########################
 from("direct:start").routingSlip("headerName")
 from("direct:start").routingSlip("aRoutingSlipHeader", "#")
@@ -60,9 +66,9 @@
 from("direct:start").sort(body().tokenize(",")).to("bean:MyServiceBean.processLine")
 #from("direct:start").sort(body().tokenize("\n")).to("bean:MyServiceBean.processLine")
 #########################split#########################
-#from("direct:start").split(body().tokenize(",")).streaming().to("mock:result")
-#from("direct:start").split(body(String.class).tokenize("\n")).to("mock:result")
-#from("direct:start").split().method("mySplitterBean", "splitBody").to("mock:result")
+from("direct:start").split(body().tokenize(",")).streaming().to("mock:result")
+from("direct:start").split(body(String.class).tokenize("\n")).to("mock:result")
+from("direct:start").split().method("mySplitterBean", "splitBody").to("mock:result")
 #from("direct:start").split(xpath("//foo/bar")).convertBodyTo(String.class).to("mock:result")
 #########################throttle#########################
 from("direct:start").throttle(100).to("mock:result")
@@ -72,7 +78,7 @@
 from("direct:start").transform().constant("London").to("mock:result")
 from("direct:start").transform(body().append(" World!")).to("mock:result")
 from("direct:start").transform(sendTo("direct:foo")).to("mock:result")
-#from("activemq:SomeQueue").beanRef("myTransformerBean", "myMethodName").to("mqseries:AnotherQueue")
+#from("direct:start").beanRef("myTransformerBean", "myMethodName").to("mock:result")
 #########################validation#########################
 #########################xpath#########################
 from("direct:start").filter().xpath("/person[@name='James']").to("mock:result")
@@ -80,7 +86,7 @@
 #########################wireTap#########################
 from("direct:start").to("log:foo").wireTap("direct:tap").to("mock:result")
 from("direct:start").delay(1000).setBody().constant("Tapped").to("mock:result", "mock:tap")
-#from("direct:start").wireTap("direct:foo", constant("Bye World")).to("mock:result")
+from("direct:start").wireTap("direct:foo", constant("Bye World")).to("mock:result")
 #########################others#########################
 from("direct:start").marshal().serialization().to("direct:marshalled")
 from("direct:start").unmarshal().serialization().to("mock:result")
\ No newline at end of file