You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2009/09/29 09:11:44 UTC

svn commit: r819847 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/model/ProcessorDefinition.java test/java/org/apache/camel/processor/DualPipelineTest.java

Author: davsclaus
Date: Tue Sep 29 07:11:44 2009
New Revision: 819847

URL: http://svn.apache.org/viewvc?rev=819847&view=rev
Log:
CAMEL-1699: Added pipeline() with no urls to the builder so you can do the same as in spring XML.

Added:
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DualPipelineTest.java   (with props)
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java?rev=819847&r1=819846&r2=819847&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java Tue Sep 29 07:11:44 2009
@@ -691,6 +691,20 @@
 
     /**
      * <a href="http://camel.apache.org/pipes-nd-filters.html">Pipes and Filters EIP:</a>
+     * Creates a {@link Pipeline} so that the message
+     * will get processed by each endpoint in turn and for request/response the
+     * output of one endpoint will be the input of the next endpoint
+     *
+     * @return the builder
+     */
+    public PipelineDefinition pipeline() {
+        PipelineDefinition answer = new PipelineDefinition();
+        addOutput(answer);
+        return answer;
+    }
+
+    /**
+     * <a href="http://camel.apache.org/pipes-nd-filters.html">Pipes and Filters EIP:</a>
      * Creates a {@link Pipeline} of the list of endpoints so that the message
      * will get processed by each endpoint in turn and for request/response the
      * output of one endpoint will be the input of the next endpoint

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DualPipelineTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DualPipelineTest.java?rev=819847&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DualPipelineTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DualPipelineTest.java Tue Sep 29 07:11:44 2009
@@ -0,0 +1,83 @@
+/**
+ * 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.processor;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.model.MulticastDefinition;
+import org.apache.camel.model.PipelineDefinition;
+import org.apache.camel.model.SendDefinition;
+
+/**
+ * @version $Revision$
+ */
+public class DualPipelineTest extends ContextTestSupport {
+
+    public void testDualPipeline() throws Exception {
+        getMockEndpoint("mock:a").expectedBodiesReceived("Hello World");
+        getMockEndpoint("mock:b").expectedBodiesReceived("After A");
+        getMockEndpoint("mock:c").expectedBodiesReceived("Hello World");
+        getMockEndpoint("mock:d").expectedBodiesReceived("After C");
+        getMockEndpoint("mock:e").expectedBodiesReceived("After C");
+        getMockEndpoint("mock:result").expectedMessageCount(1);
+
+        template.sendBody("direct:start", "Hello World");
+
+        assertMockEndpointsSatisfied();
+
+        // now check the route
+        MulticastDefinition mc = assertIsInstanceOf(MulticastDefinition.class, context.getRouteDefinitions().get(0).getOutputs().get(0));
+        PipelineDefinition pd1 = assertIsInstanceOf(PipelineDefinition.class, mc.getOutputs().get(0));
+        PipelineDefinition pd2 = assertIsInstanceOf(PipelineDefinition.class, mc.getOutputs().get(1));
+
+        assertEquals(3, pd1.getOutputs().size());
+        assertEquals(4, pd2.getOutputs().size());
+
+        SendDefinition send1 = assertIsInstanceOf(SendDefinition.class, pd1.getOutputs().get(2));
+        assertEquals("mock://b", send1.getEndpoint().getEndpointUri());
+
+        SendDefinition send2 = assertIsInstanceOf(SendDefinition.class, pd2.getOutputs().get(3));
+        assertEquals("mock://e", send2.getEndpoint().getEndpointUri());
+
+        SendDefinition send = assertIsInstanceOf(SendDefinition.class, context.getRouteDefinitions().get(0).getOutputs().get(1));
+        assertEquals("mock://result", send.getEndpoint().getEndpointUri());
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start")
+                    .multicast()
+                        .pipeline()
+                            .to("mock:a")
+                            .setBody(constant("After A"))
+                            .to("mock:b")
+                        .end() //pipeline
+                        .pipeline()
+                            .to("mock:c")
+                            .setBody(constant("After C"))
+                            .to("mock:d")
+                            .to("mock:e")
+                        .end() //pipeline
+                    .end()//multicast
+                .to("mock:result");
+            }
+        };
+    }
+}

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DualPipelineTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DualPipelineTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date