Quantcast

camel git commit: CAMEL-10724: Improve Java DSL support for Java 8

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

camel git commit: CAMEL-10724: Improve Java DSL support for Java 8

lburgazzoli-2
Repository: camel
Updated Branches:
  refs/heads/master e682e7ee0 -> 451887e9a


CAMEL-10724: Improve Java DSL support for Java 8


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

Branch: refs/heads/master
Commit: 451887e9a200cb22557d49937bc257eb7f115f8b
Parents: e682e7e
Author: lburgazzoli <[hidden email]>
Authored: Fri Feb 17 17:45:16 2017 +0100
Committer: lburgazzoli <[hidden email]>
Committed: Fri Feb 17 17:50:37 2017 +0100

----------------------------------------------------------------------
 .../camel/model/RecipientListDefinition.java    | 13 +++++
 .../processor/RecipientListFunctionalTest.java  | 54 ++++++++++++++++++++
 2 files changed, 67 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/451887e9/camel-core/src/main/java/org/apache/camel/model/RecipientListDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/RecipientListDefinition.java b/camel-core/src/main/java/org/apache/camel/model/RecipientListDefinition.java
index b7b3b85..1ae0d9c 100644
--- a/camel-core/src/main/java/org/apache/camel/model/RecipientListDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/RecipientListDefinition.java
@@ -28,6 +28,7 @@ import javax.xml.bind.annotation.XmlTransient;
 import org.apache.camel.CamelContextAware;
 import org.apache.camel.Expression;
 import org.apache.camel.Processor;
+import org.apache.camel.builder.ProcessClause;
 import org.apache.camel.model.language.ExpressionDefinition;
 import org.apache.camel.processor.EvaluateExpressionProcessor;
 import org.apache.camel.processor.Pipeline;
@@ -400,6 +401,18 @@ public class RecipientListDefinition<Type extends ProcessorDefinition<Type>> ext
     }
 
     /**
+     * TODO: document
+     * Note: this is experimental and subject to changes in future releases.
+     *
+     * @return the builder
+     */
+    public ProcessClause<RecipientListDefinition<Type>> onPrepare() {
+        ProcessClause<RecipientListDefinition<Type>> clause = new ProcessClause<>(this);
+        setOnPrepare(clause);
+        return clause;
+    }
+
+    /**
      * Uses the {@link Processor} when preparing the {@link org.apache.camel.Exchange} to be send.
      * This can be used to deep-clone messages that should be send, or any custom logic needed before
      * the exchange is send.

http://git-wip-us.apache.org/repos/asf/camel/blob/451887e9/camel-core/src/test/java/org/apache/camel/processor/RecipientListFunctionalTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/RecipientListFunctionalTest.java b/camel-core/src/test/java/org/apache/camel/processor/RecipientListFunctionalTest.java
new file mode 100644
index 0000000..757e6cd
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/processor/RecipientListFunctionalTest.java
@@ -0,0 +1,54 @@
+/**
+ * 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.component.mock.MockEndpoint;
+
+public class RecipientListFunctionalTest extends ContextTestSupport {
+
+    public void testRecipientList() throws Exception {
+        MockEndpoint x = getMockEndpoint("mock:x");
+        x.expectedBodiesReceived("answer");
+        x.expectedHeaderReceived("OnPrepare", true);
+
+        MockEndpoint y = getMockEndpoint("mock:y");
+        y.expectedBodiesReceived("answer");
+        y.expectedHeaderReceived("OnPrepare", true);
+
+        MockEndpoint z = getMockEndpoint("mock:z");
+        z.expectedBodiesReceived("answer");
+        z.expectedHeaderReceived("OnPrepare", true);
+
+        template.sendBodyAndHeader("direct:a", "answer", "Endpoints", "mock:x,mock:y,mock:z");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            public void configure() {
+                from("direct:a")
+                    .recipientList()
+                        .message(m -> m.getHeader("Endpoints", String.class).split(","))
+                        .onPrepare()
+                            .message(m -> m.setHeader("OnPrepare", true));
+            }
+        };
+    }
+}

Loading...