Author: davsclaus
Date: Wed Jun 15 12:35:28 2011
New Revision: 1136012
URL: http://svn.apache.org/viewvc?rev=1136012&view=rev
Log:
CAMEL-4103: Fixed test
Added:
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TryCatchCaughtExceptionFinallyTest.java
- copied, changed from r1135974,
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TryCatchCaughtExceptionTest.java
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TryCatchCaughtExceptionTwoTimesTest.java
- copied, changed from r1135974,
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TryCatchCaughtExceptionTest.java
Modified:
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TryCatchCaughtExceptionTest.java
Copied:
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TryCatchCaughtExceptionFinallyTest.java
(from r1135974,
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TryCatchCaughtExceptionTest.java)
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TryCatchCaughtExceptionFinallyTest.java?p2=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TryCatchCaughtExceptionFinallyTest.java&p1=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TryCatchCaughtExceptionTest.java&r1=1135974&r2=1136012&rev=1136012&view=diff
==============================================================================
---
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TryCatchCaughtExceptionTest.java
(original)
+++
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TryCatchCaughtExceptionFinallyTest.java
Wed Jun 15 12:35:28 2011
@@ -18,32 +18,22 @@ 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;
-import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.impl.JndiRegistry;
/**
*
*/
-public class TryCatchCaughtExceptionTest extends ContextTestSupport {
+public class TryCatchCaughtExceptionFinallyTest extends ContextTestSupport {
- public void testTryCatchCaughtException() throws Exception {
+ public void testTryCatchCaughtExceptionFinally() throws Exception {
getMockEndpoint("mock:a").expectedMessageCount(1);
getMockEndpoint("mock:result").expectedMessageCount(1);
- MockEndpoint error = getMockEndpoint("mock:b");
- error.expectedMessageCount(1);
-
template.sendBody("direct:start", "Hello World");
assertMockEndpointsSatisfied();
-
- Exception e =
error.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT,
Exception.class);
- assertNotNull(e);
- assertEquals("Forced", e.getMessage());
-
- String to =
error.getReceivedExchanges().get(0).getProperty(Exchange.FAILURE_ENDPOINT,
String.class);
- assertEquals("bean://myBean?method=doSomething", to);
}
@Override
@@ -63,7 +53,21 @@ public class TryCatchCaughtExceptionTest
.to("mock:a")
.to("bean:myBean?method=doSomething")
.doCatch(Exception.class)
- .to("mock:b")
+ .process(new Processor() {
+ @Override
+ public void process(Exchange exchange) throws
Exception {
+
assertEquals("bean://myBean?method=doSomething",
exchange.getProperty(Exchange.FAILURE_ENDPOINT));
+ assertEquals("Forced",
exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Exception.class).getMessage());
+ }
+ })
+ .doFinally()
+ .process(new Processor() {
+ @Override
+ public void process(Exchange exchange) throws
Exception {
+
assertEquals("bean://myBean?method=doSomething",
exchange.getProperty(Exchange.FAILURE_ENDPOINT));
+ assertEquals("Forced",
exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Exception.class).getMessage());
+ }
+ })
.end()
.to("mock:result");
}
Modified:
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TryCatchCaughtExceptionTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TryCatchCaughtExceptionTest.java?rev=1136012&r1=1136011&r2=1136012&view=diff
==============================================================================
---
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TryCatchCaughtExceptionTest.java
(original)
+++
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TryCatchCaughtExceptionTest.java
Wed Jun 15 12:35:28 2011
@@ -18,8 +18,8 @@ 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;
-import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.impl.JndiRegistry;
/**
@@ -31,19 +31,9 @@ public class TryCatchCaughtExceptionTest
getMockEndpoint("mock:a").expectedMessageCount(1);
getMockEndpoint("mock:result").expectedMessageCount(1);
- MockEndpoint error = getMockEndpoint("mock:b");
- error.expectedMessageCount(1);
-
template.sendBody("direct:start", "Hello World");
assertMockEndpointsSatisfied();
-
- Exception e =
error.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT,
Exception.class);
- assertNotNull(e);
- assertEquals("Forced", e.getMessage());
-
- String to =
error.getReceivedExchanges().get(0).getProperty(Exchange.FAILURE_ENDPOINT,
String.class);
- assertEquals("bean://myBean?method=doSomething", to);
}
@Override
@@ -63,7 +53,13 @@ public class TryCatchCaughtExceptionTest
.to("mock:a")
.to("bean:myBean?method=doSomething")
.doCatch(Exception.class)
- .to("mock:b")
+ .process(new Processor() {
+ @Override
+ public void process(Exchange exchange) throws
Exception {
+
assertEquals("bean://myBean?method=doSomething",
exchange.getProperty(Exchange.FAILURE_ENDPOINT));
+ assertEquals("Forced",
exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Exception.class).getMessage());
+ }
+ })
.end()
.to("mock:result");
}
Copied:
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TryCatchCaughtExceptionTwoTimesTest.java
(from r1135974,
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TryCatchCaughtExceptionTest.java)
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TryCatchCaughtExceptionTwoTimesTest.java?p2=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TryCatchCaughtExceptionTwoTimesTest.java&p1=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TryCatchCaughtExceptionTest.java&r1=1135974&r2=1136012&rev=1136012&view=diff
==============================================================================
---
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TryCatchCaughtExceptionTest.java
(original)
+++
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TryCatchCaughtExceptionTwoTimesTest.java
Wed Jun 15 12:35:28 2011
@@ -18,32 +18,24 @@ 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;
-import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.impl.JndiRegistry;
/**
*
*/
-public class TryCatchCaughtExceptionTest extends ContextTestSupport {
+public class TryCatchCaughtExceptionTwoTimesTest extends ContextTestSupport {
public void testTryCatchCaughtException() throws Exception {
getMockEndpoint("mock:a").expectedMessageCount(1);
+ getMockEndpoint("mock:b").expectedMessageCount(1);
+ getMockEndpoint("mock:c").expectedMessageCount(1);
getMockEndpoint("mock:result").expectedMessageCount(1);
- MockEndpoint error = getMockEndpoint("mock:b");
- error.expectedMessageCount(1);
-
template.sendBody("direct:start", "Hello World");
assertMockEndpointsSatisfied();
-
- Exception e =
error.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT,
Exception.class);
- assertNotNull(e);
- assertEquals("Forced", e.getMessage());
-
- String to =
error.getReceivedExchanges().get(0).getProperty(Exchange.FAILURE_ENDPOINT,
String.class);
- assertEquals("bean://myBean?method=doSomething", to);
}
@Override
@@ -63,7 +55,26 @@ public class TryCatchCaughtExceptionTest
.to("mock:a")
.to("bean:myBean?method=doSomething")
.doCatch(Exception.class)
- .to("mock:b")
+ .process(new Processor() {
+ @Override
+ public void process(Exchange exchange) throws
Exception {
+
assertEquals("bean://myBean?method=doSomething",
exchange.getProperty(Exchange.FAILURE_ENDPOINT));
+ assertEquals("Forced",
exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Exception.class).getMessage());
+ }
+ })
+ .end()
+ .to("mock:b")
+ .doTry()
+ .to("mock:c")
+ .to("bean:myBean?method=doSomethingElse")
+ .doCatch(Exception.class)
+ .process(new Processor() {
+ @Override
+ public void process(Exchange exchange) throws
Exception {
+
assertEquals("bean://myBean?method=doSomethingElse",
exchange.getProperty(Exchange.FAILURE_ENDPOINT));
+ assertEquals("Forced Again",
exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Exception.class).getMessage());
+ }
+ })
.end()
.to("mock:result");
}
@@ -73,4 +84,8 @@ public class TryCatchCaughtExceptionTest
public void doSomething(String body) throws Exception {
throw new IllegalArgumentException("Forced");
}
+
+ public void doSomethingElse(String body) throws Exception {
+ throw new IllegalArgumentException("Forced Again");
+ }
}