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 2010/09/26 13:49:03 UTC
svn commit: r1001415 - in
/camel/trunk/camel-core/src/test/java/org/apache/camel/processor:
FailOverAllFailedExceptionTest.java FailOverNotCatchedExceptionTest.java
Author: davsclaus
Date: Sun Sep 26 11:49:03 2010
New Revision: 1001415
URL: http://svn.apache.org/viewvc?rev=1001415&view=rev
Log:
Added more LB failover test.
Added:
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/FailOverAllFailedExceptionTest.java
- copied, changed from r1001371, camel/trunk/camel-core/src/test/java/org/apache/camel/processor/FailOverNotCatchedExceptionTest.java
Modified:
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/FailOverNotCatchedExceptionTest.java
Copied: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/FailOverAllFailedExceptionTest.java (from r1001371, camel/trunk/camel-core/src/test/java/org/apache/camel/processor/FailOverNotCatchedExceptionTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/FailOverAllFailedExceptionTest.java?p2=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/FailOverAllFailedExceptionTest.java&p1=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/FailOverNotCatchedExceptionTest.java&r1=1001371&r2=1001415&rev=1001415&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/FailOverNotCatchedExceptionTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/FailOverAllFailedExceptionTest.java Sun Sep 26 11:49:03 2010
@@ -16,7 +16,6 @@
*/
package org.apache.camel.processor;
-import java.io.IOException;
import java.net.SocketException;
import org.apache.camel.CamelExecutionException;
@@ -26,7 +25,7 @@ import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-public class FailOverNotCatchedExceptionTest extends ContextTestSupport {
+public class FailOverAllFailedExceptionTest extends ContextTestSupport {
protected MockEndpoint x;
protected MockEndpoint y;
@@ -44,15 +43,9 @@ public class FailOverNotCatchedException
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
- // START SNIPPET: e1
from("direct:start")
- // here we will load balance if IOException was thrown
- // any other kind of exception will result in the Exchange as failed
- // to failover over any kind of exception we can just omit the exception
- // in the failOver DSL
- .loadBalance().failover(IOException.class)
+ .loadBalance().failover(2, false, true)
.to("direct:x", "direct:y", "direct:z");
- // END SNIPPET: e1
from("direct:x").to("mock:x").process(new Processor() {
public void process(Exchange exchange) throws Exception {
@@ -66,24 +59,26 @@ public class FailOverNotCatchedException
}
});
- from("direct:z").to("mock:z");
+ from("direct:z").to("mock:z").process(new Processor() {
+ public void process(Exchange exchange) throws Exception {
+ throw new SocketException("Not Again");
+ }
+ });
}
};
}
- public void testExceptionNotCatched() throws Exception {
+ public void testAllFailed() throws Exception {
x.expectedMessageCount(1);
y.expectedMessageCount(1);
- z.expectedMessageCount(0);
-
- // to test that if a processor throw an exception that the failover loadbalancer
- // do not catch then the exception is propagated back
+ z.expectedMessageCount(1);
try {
template.sendBody("direct:start", "Hello World");
+ fail("Should have thrown exception");
} catch (CamelExecutionException e) {
- assertEquals("Illegal", e.getCause().getMessage());
- assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
+ assertEquals("Not Again", e.getCause().getMessage());
+ assertIsInstanceOf(SocketException.class, e.getCause());
}
assertMockEndpointsSatisfied();
Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/FailOverNotCatchedExceptionTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/FailOverNotCatchedExceptionTest.java?rev=1001415&r1=1001414&r2=1001415&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/FailOverNotCatchedExceptionTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/FailOverNotCatchedExceptionTest.java Sun Sep 26 11:49:03 2010
@@ -81,6 +81,7 @@ public class FailOverNotCatchedException
try {
template.sendBody("direct:start", "Hello World");
+ fail("Should have thrown exception");
} catch (CamelExecutionException e) {
assertEquals("Illegal", e.getCause().getMessage());
assertIsInstanceOf(IllegalArgumentException.class, e.getCause());