camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1041886 - /camel/trunk/camel-core/src/test/java/org/apache/camel/issues/TryCatchSetHeaderIssueTest.java
Date Fri, 03 Dec 2010 15:45:58 GMT
Author: davsclaus
Date: Fri Dec  3 15:45:58 2010
New Revision: 1041886

URL: http://svn.apache.org/viewvc?rev=1041886&view=rev
Log:
add try catch test with multiple catch blocks

Modified:
    camel/trunk/camel-core/src/test/java/org/apache/camel/issues/TryCatchSetHeaderIssueTest.java

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/issues/TryCatchSetHeaderIssueTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/issues/TryCatchSetHeaderIssueTest.java?rev=1041886&r1=1041885&r2=1041886&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/issues/TryCatchSetHeaderIssueTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/issues/TryCatchSetHeaderIssueTest.java
Fri Dec  3 15:45:58 2010
@@ -25,6 +25,21 @@ import org.apache.camel.builder.RouteBui
 public class TryCatchSetHeaderIssueTest extends ContextTestSupport {
 
     public void testTryCatchSetHeaderIssue() throws Exception {
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start")
+                    .doTry()
+                        .setHeader("foo", constant("try"))
+                        .throwException(new IllegalArgumentException("Damn"))
+                    .doCatch(Exception.class)
+                        .setHeader("foo", constant("error"))
+                    .end()
+                    .to("mock:end");
+            }
+        });
+        context.start();
+
         getMockEndpoint("mock:end").expectedBodiesReceived("Hello World");
         getMockEndpoint("mock:end").expectedHeaderReceived("foo", "error");
 
@@ -33,20 +48,43 @@ public class TryCatchSetHeaderIssueTest 
         assertMockEndpointsSatisfied();
     }
 
-    @Override
-    protected RouteBuilder createRouteBuilder() throws Exception {
-        return new RouteBuilder() {
+    public void testTryCatchTwoSetHeaderIssue() throws Exception {
+        context.addRoutes(new RouteBuilder() {
             @Override
             public void configure() throws Exception {
                 from("direct:start")
                     .doTry()
                         .setHeader("foo", constant("try"))
                         .throwException(new IllegalArgumentException("Damn"))
-                    .doCatch(Exception.class)
+                    .doCatch(IllegalArgumentException.class)
                         .setHeader("foo", constant("error"))
+                    .doCatch(Exception.class)
+                        .setHeader("foo", constant("damn"))
                     .end()
                     .to("mock:end");
             }
+        });
+        context.start();
+
+        getMockEndpoint("mock:end").expectedBodiesReceived("Hello World");
+        getMockEndpoint("mock:end").expectedHeaderReceived("foo", "error");
+
+        template.sendBody("direct:start", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+            }
         };
     }
 }



Mime
View raw message