This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-2.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-2.x by this push:
     new a5dc4d7  Added unit test example based on user forum issue with 
Multicast EIP change due to CAMEL-9444 and CAMEL-9573. Using claim check EIP
a5dc4d7 is described below

commit a5dc4d79e4e3c2b7a8dce912c53cc05996d697fd
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Fri Feb 8 15:08:16 2019 +0100

    Added unit test example based on user forum issue with Multicast EIP change 
due to CAMEL-9444 and CAMEL-9573. Using claim check EIP
---
 ...essageBodyAndEnrichedHeadersClaimCheckTest.java | 79 ++++++++++++++++++++++
 1 file changed, 79 insertions(+)

diff --git 
a/camel-core/src/test/java/org/apache/camel/issues/MulticastMixOriginalMessageBodyAndEnrichedHeadersClaimCheckTest.java
 
b/camel-core/src/test/java/org/apache/camel/issues/MulticastMixOriginalMessageBodyAndEnrichedHeadersClaimCheckTest.java
new file mode 100644
index 0000000..6d145ab
--- /dev/null
+++ 
b/camel-core/src/test/java/org/apache/camel/issues/MulticastMixOriginalMessageBodyAndEnrichedHeadersClaimCheckTest.java
@@ -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.issues;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.model.ClaimCheckOperation;
+import org.junit.Test;
+
+public class MulticastMixOriginalMessageBodyAndEnrichedHeadersClaimCheckTest 
extends ContextTestSupport {
+
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    @Test
+    public void testMulticastMixOriginalAndHeaders() throws Exception {
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                onException(Exception.class)
+                    .handled(true)
+                    // merge the message with the original message body but 
keep any existing headers
+                    .claimCheck(ClaimCheckOperation.Pop, "myOriginalBody", 
"body")
+                    .to("mock:b");
+
+                from("direct:start")
+                    // we want to preserve the real original message body and 
then include other headers that have been
+                    // set later during routing
+                    .claimCheck(ClaimCheckOperation.Push, "myOriginalBody")
+                    .setBody(constant("Changed body"))
+                    .setHeader("foo", constant("bar"))
+                    .multicast().shareUnitOfWork().stopOnException()
+                        .to("direct:a")
+                        .to("direct:b")
+                    .end();
+
+                from("direct:a")
+                    .to("mock:a");
+
+                from("direct:b")
+                    .to("mock:c")
+                    .throwException(new IllegalArgumentException("Forced"));
+            }
+        });
+        context.start();
+
+        getMockEndpoint("mock:a").expectedMessageCount(1);
+        getMockEndpoint("mock:a").expectedBodiesReceived("Changed body");
+        getMockEndpoint("mock:a").expectedHeaderReceived("foo", "bar");
+        getMockEndpoint("mock:b").expectedMessageCount(1);
+        getMockEndpoint("mock:b").expectedBodiesReceived("Hello World");
+        getMockEndpoint("mock:b").expectedHeaderReceived("foo", "bar");
+        getMockEndpoint("mock:c").expectedMessageCount(1);
+        getMockEndpoint("mock:c").expectedHeaderReceived("foo", "bar");
+        getMockEndpoint("mock:c").expectedBodiesReceived("Changed body");
+        getMockEndpoint("mock:result").expectedMessageCount(0);
+
+        template.sendBody("direct:start", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+}

Reply via email to