camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1136065 - in /camel/trunk: camel-core/src/test/java/org/apache/camel/issues/ components/camel-spring/src/test/java/org/apache/camel/spring/issues/ components/camel-spring/src/test/resources/org/apache/camel/spring/issues/
Date Wed, 15 Jun 2011 14:22:32 GMT
Author: davsclaus
Date: Wed Jun 15 14:22:31 2011
New Revision: 1136065

URL: http://svn.apache.org/viewvc?rev=1136065&view=rev
Log:
CAMEL-4107: Added unit test.

Added:
    camel/trunk/camel-core/src/test/java/org/apache/camel/issues/MultipleErrorHandlerOnExceptionIssueTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/issues/SpringMultipleErrorHandlerOnExceptionIssueTest.java
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/SpringMultipleErrorHandlerOnExceptionIssueTest.xml
      - copied, changed from r1136049, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/stringDataFormatTest.xml

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/issues/MultipleErrorHandlerOnExceptionIssueTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/issues/MultipleErrorHandlerOnExceptionIssueTest.java?rev=1136065&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/issues/MultipleErrorHandlerOnExceptionIssueTest.java
(added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/issues/MultipleErrorHandlerOnExceptionIssueTest.java
Wed Jun 15 14:22:31 2011
@@ -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 java.io.IOException;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.LoggingLevel;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ *
+ */
+public class MultipleErrorHandlerOnExceptionIssueTest extends ContextTestSupport {
+
+    public void testMultipleErrorHandlerOnExceptionA() throws Exception {
+        getMockEndpoint("mock:handled").expectedMessageCount(1);
+        getMockEndpoint("mock:a").expectedMessageCount(1);
+        getMockEndpoint("mock:b").expectedMessageCount(0);
+        getMockEndpoint("mock:dead.a").expectedMessageCount(0);
+        getMockEndpoint("mock:dead.b").expectedMessageCount(0);
+
+        template.sendBody("seda:a", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    public void testMultipleErrorHandlerOnExceptionB() throws Exception {
+        getMockEndpoint("mock:handled").expectedMessageCount(0);
+        getMockEndpoint("mock:a").expectedMessageCount(0);
+        getMockEndpoint("mock:b").expectedMessageCount(1);
+        getMockEndpoint("mock:dead.a").expectedMessageCount(0);
+        getMockEndpoint("mock:dead.b").expectedMessageCount(1);
+
+        template.sendBody("seda:b", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                onException(IllegalArgumentException.class)
+                    .handled(true)
+                    .to("mock:handled");
+
+                from("seda:a")
+                    .errorHandler(deadLetterChannel("mock:dead.a")
+                            .maximumRedeliveries(3).redeliveryDelay(0)
+                            .retryAttemptedLogLevel(LoggingLevel.WARN).asyncDelayedRedelivery())
+                    .to("mock:a")
+                    .throwException(new IllegalArgumentException("Forced A"));
+
+                from("seda:b")
+                        .errorHandler(deadLetterChannel("mock:dead.b")
+                            .maximumRedeliveries(2).redeliveryDelay(0)
+                            .retryAttemptedLogLevel(LoggingLevel.WARN))
+                    .to("mock:b")
+                    .throwException(new IOException("Some IO error"));
+            }
+        };
+    }
+}

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/issues/SpringMultipleErrorHandlerOnExceptionIssueTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/issues/SpringMultipleErrorHandlerOnExceptionIssueTest.java?rev=1136065&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/issues/SpringMultipleErrorHandlerOnExceptionIssueTest.java
(added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/issues/SpringMultipleErrorHandlerOnExceptionIssueTest.java
Wed Jun 15 14:22:31 2011
@@ -0,0 +1,33 @@
+/**
+ * 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.spring.issues;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.issues.MultipleErrorHandlerOnExceptionIssueTest;
+
+import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
+
+/**
+ *
+ */
+public class SpringMultipleErrorHandlerOnExceptionIssueTest extends MultipleErrorHandlerOnExceptionIssueTest
{
+
+    protected CamelContext createCamelContext() throws Exception {
+        return createSpringCamelContext(this, "org/apache/camel/spring/issues/SpringMultipleErrorHandlerOnExceptionIssueTest.xml");
+    }
+
+}

Copied: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/SpringMultipleErrorHandlerOnExceptionIssueTest.xml
(from r1136049, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/stringDataFormatTest.xml)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/SpringMultipleErrorHandlerOnExceptionIssueTest.xml?p2=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/SpringMultipleErrorHandlerOnExceptionIssueTest.xml&p1=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/stringDataFormatTest.xml&r1=1136049&r2=1136065&rev=1136065&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/stringDataFormatTest.xml
(original)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/SpringMultipleErrorHandlerOnExceptionIssueTest.xml
Wed Jun 15 14:22:31 2011
@@ -22,26 +22,45 @@
        http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
     ">
 
-    <bean id="xs" class="org.apache.camel.model.dataformat.StringDataFormat">
-        <property name="charset" value="utf-8"/>
-    </bean>
-
-    <camelContext xmlns="http://camel.apache.org/schema/spring">
-        <route>
-            <from uri="direct:marshal"/>
-            <!-- using a bean id -->
-            <marshal ref="xs"/>
-            <to uri="mock:marshal"/>
-        </route>
-
-        <route>
-            <from uri="direct:unmarshal"/>
-            <!-- using a child node -->
-            <unmarshal>
-                <string charset="UTF-8"/>
-            </unmarshal>
-            <to uri="mock:unmarshal"/>
-        </route>
-    </camelContext>
+  <bean id="forcedA" class="java.lang.IllegalArgumentException">
+    <constructor-arg index="0" value="Forced A"/>
+  </bean>
+
+  <bean id="ioError" class="java.io.IOException">
+    <constructor-arg index="0" value="Some IO error"/>
+  </bean>
+
+  <camelContext xmlns="http://camel.apache.org/schema/spring">
+
+    <errorHandler id="dlcA" type="DeadLetterChannel" deadLetterUri="mock:dead.a" redeliveryPolicyRef="redeliveryPolicyA"/>
+    <errorHandler id="dlcB" type="DeadLetterChannel" deadLetterUri="mock:dead.b" redeliveryPolicyRef="redeliveryPolicyB"/>
+
+
+    <redeliveryPolicyProfile id="redeliveryPolicyA" maximumRedeliveries="3" redeliveryDelay="0"
+                             retryAttemptedLogLevel="WARN" asyncDelayedRedelivery="true"/>
+    <redeliveryPolicyProfile id="redeliveryPolicyB" maximumRedeliveries="2" redeliveryDelay="0"
+                             retryAttemptedLogLevel="WARN"/>
+
+    <onException>
+      <exception>java.lang.IllegalArgumentException</exception>
+      <handled>
+        <constant>true</constant>
+      </handled>
+      <to uri="mock:handled"/>
+    </onException>
+
+    <route errorHandlerRef="dlcA">
+      <from uri="seda:a"/>
+      <to uri="mock:a"/>
+      <throwException ref="forcedA"/>
+    </route>
+
+    <route errorHandlerRef="dlcB">
+      <from uri="seda:b"/>
+      <to uri="mock:b"/>
+      <throwException ref="ioError"/>
+    </route>
+
+  </camelContext>
 
 </beans>



Mime
View raw message