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 2013/10/10 10:27:38 UTC

[4/4] git commit: CAMEL-6845: Using recipient list to a route that has no error handler should allow caller route to trigger its error handler

CAMEL-6845: Using recipient list to a route that has no error handler should allow caller route to trigger its error handler


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

Branch: refs/heads/master
Commit: a3bc4641ccf5ce16477c0bd376ce503dd1566232
Parents: 39fd059
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Oct 10 10:26:38 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Oct 10 10:26:38 2013 +0200

----------------------------------------------------------------------
 .../RoutingSlipNoErrorHandlerTest.java          | 60 ++++++++++++++++++++
 .../processor/SendToNoErrorHandlerTest.java     | 60 ++++++++++++++++++++
 2 files changed, 120 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/a3bc4641/camel-core/src/test/java/org/apache/camel/processor/RoutingSlipNoErrorHandlerTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/RoutingSlipNoErrorHandlerTest.java b/camel-core/src/test/java/org/apache/camel/processor/RoutingSlipNoErrorHandlerTest.java
new file mode 100644
index 0000000..0bd644c
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/processor/RoutingSlipNoErrorHandlerTest.java
@@ -0,0 +1,60 @@
+/**
+ * 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.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+
+public class RoutingSlipNoErrorHandlerTest extends ContextTestSupport {
+
+    public void testRoutingSlipNoErrorHandler() throws Exception {
+        getMockEndpoint("mock:foo").expectedMessageCount(1);
+        getMockEndpoint("mock:result").expectedMessageCount(0);
+        getMockEndpoint("mock:dead").expectedMessageCount(1);
+        getMockEndpoint("mock:dead").message(0).property(Exchange.EXCEPTION_CAUGHT).isInstanceOf(IllegalArgumentException.class);
+
+        template.sendBody("direct:start", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                errorHandler(deadLetterChannel("mock:dead"));
+
+                from("direct:start")
+                    .routingSlip().constant("direct:foo")
+                    .to("mock:result");
+
+                from("direct:foo")
+                    .errorHandler(noErrorHandler())
+                    .to("mock:foo")
+                    .process(new Processor() {
+                        @Override
+                        public void process(Exchange exchange) throws Exception {
+                            throw new IllegalArgumentException("Forced");
+                        }
+                    });
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/a3bc4641/camel-core/src/test/java/org/apache/camel/processor/SendToNoErrorHandlerTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/SendToNoErrorHandlerTest.java b/camel-core/src/test/java/org/apache/camel/processor/SendToNoErrorHandlerTest.java
new file mode 100644
index 0000000..aece2d4
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/processor/SendToNoErrorHandlerTest.java
@@ -0,0 +1,60 @@
+/**
+ * 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.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+
+public class SendToNoErrorHandlerTest extends ContextTestSupport {
+
+    public void testSendToNoErrorHandler() throws Exception {
+        getMockEndpoint("mock:foo").expectedMessageCount(1);
+        getMockEndpoint("mock:result").expectedMessageCount(0);
+        getMockEndpoint("mock:dead").expectedMessageCount(1);
+        getMockEndpoint("mock:dead").message(0).property(Exchange.EXCEPTION_CAUGHT).isInstanceOf(IllegalArgumentException.class);
+
+        template.sendBody("direct:start", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                errorHandler(deadLetterChannel("mock:dead"));
+
+                from("direct:start")
+                    .to("direct:foo")
+                    .to("mock:result");
+
+                from("direct:foo")
+                    .errorHandler(noErrorHandler())
+                    .to("mock:foo")
+                    .process(new Processor() {
+                        @Override
+                        public void process(Exchange exchange) throws Exception {
+                            throw new IllegalArgumentException("Forced");
+                        }
+                    });
+            }
+        };
+    }
+}