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 2011/06/11 18:11:49 UTC

svn commit: r1134681 - in /camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception: OnExceptionContinueTest.java OnExceptionContinueTwoTest.java

Author: davsclaus
Date: Sat Jun 11 16:11:49 2011
New Revision: 1134681

URL: http://svn.apache.org/viewvc?rev=1134681&view=rev
Log:
CAMEL-4057: Keep test as it was so the wiki example is the same and simple. Added 2nd test to test the issue with 2x continued. Added better validation that it was actually the 2nd exception that was caught at the end of the test.

Added:
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionContinueTwoTest.java
      - copied, changed from r1134678, camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionContinueTest.java
Modified:
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionContinueTest.java

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionContinueTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionContinueTest.java?rev=1134681&r1=1134680&r2=1134681&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionContinueTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionContinueTest.java Sat Jun 11 16:11:49 2011
@@ -51,8 +51,6 @@ public class OnExceptionContinueTest ext
                 from("direct:start")
                     .to("mock:start")
                     .throwException(new IllegalArgumentException("Forced"))
-                    //throw a second time to validate that the exchange is reset appropriately
-                    .throwException(new IllegalArgumentException("Forced"))
                     .to("mock:result");
             }
             // END SNIPPET: e1

Copied: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionContinueTwoTest.java (from r1134678, camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionContinueTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionContinueTwoTest.java?p2=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionContinueTwoTest.java&p1=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionContinueTest.java&r1=1134678&r2=1134681&rev=1134681&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionContinueTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionContinueTwoTest.java Sat Jun 11 16:11:49 2011
@@ -24,10 +24,11 @@ import org.apache.camel.component.mock.M
 /**
  * @version 
  */
-public class OnExceptionContinueTest extends ContextTestSupport {
+public class OnExceptionContinueTwoTest extends ContextTestSupport {
 
-    public void testContinued() throws Exception {
+    public void testContinuedTwo() throws Exception {
         getMockEndpoint("mock:start").expectedMessageCount(1);
+        getMockEndpoint("mock:middle").expectedMessageCount(1);
 
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedBodiesReceived("Hello World");
@@ -37,13 +38,15 @@ public class OnExceptionContinueTest ext
         template.sendBody("direct:start", "Hello World");
 
         assertMockEndpointsSatisfied();
+
+        Exception cause = mock.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT, Exception.class);
+        assertEquals("Forced Again", cause.getMessage());
     }
 
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             @Override
-            // START SNIPPET: e1
             public void configure() throws Exception {
                 // tell Camel to handle and continue when this exception is thrown
                 onException(IllegalArgumentException.class).continued(true);
@@ -51,11 +54,11 @@ public class OnExceptionContinueTest ext
                 from("direct:start")
                     .to("mock:start")
                     .throwException(new IllegalArgumentException("Forced"))
+                    .to("mock:middle")
                     //throw a second time to validate that the exchange is reset appropriately
-                    .throwException(new IllegalArgumentException("Forced"))
+                    .throwException(new IllegalArgumentException("Forced Again"))
                     .to("mock:result");
             }
-            // END SNIPPET: e1
         };
     }
 }
\ No newline at end of file