public void testSeda() throws Exception {
CamelContext context = new DefaultCamelContext();
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("seda:inbound").convertBodyTo(String.class).process(new Processor()
{
public void process(Exchange arg0)
throws Exception {
System.out.println("proc 3/1: "
+ arg0 + "/" +
Thread.currentThread());
}
}).to("seda:stage-1");
from("seda:stage-1").process(new Processor() {
public void process(Exchange arg0)
throws Exception {
System.out.println("proc 3/2: "
+ arg0 + "/" +
Thread.currentThread());
}
}).to("mock:eventPublisher");
}
});
CamelTemplate template = new CamelTemplate(context);
context.start();
template.sendBody("seda:inbound", "test-direct-endpoints");
MockEndpoint eventPubilsher =
context.getEndpoint("mock:event-publisher",
MockEndpoint.class);
eventPubilsher.expectedMessageCount(1);
MockEndpoint.assertIsSatisfied(1, TimeUnit.SECONDS,
eventPubilsher);
context.stop();
}
public void testDirect() throws Exception {
CamelContext context = new DefaultCamelContext();
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("seda:inbound").convertBodyTo(String.class).process(new Processor()
{
public void process(Exchange arg0)
throws Exception {
System.out.println("proc 2/1: "
+ arg0 + "/" +
Thread.currentThread());
}
}).to("direct:stage-1");
from("direct:stage-1").process(new Processor() {
public void process(Exchange arg0)
throws Exception {
System.out.println("proc 2/2: "
+ arg0 + "/" +
Thread.currentThread());
}
}).to("mock:eventPublisher");
}
});
CamelTemplate template = new CamelTemplate(context);
context.start();
template.sendBody("seda:inbound", "test-direct-endpoints");
MockEndpoint eventPubilsher =
context.getEndpoint("mock:event-publisher",
MockEndpoint.class);
eventPubilsher.expectedMessageCount(1);
eventPubilsher.assertIsSatisfied();
context.stop();
}
Exceptions traces are respectivelly:
java.lang.AssertionError: Timeout waiting for endpoints to receive enough
messages. mock:event-publisher timed out.
at
org.apache.camel.component.mock.MockEndpoint.assertWait(MockEndpoint.java:73)
at
org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied(MockEndpoint.java:83)
at
xxxx.actions.common.route.CommonRouteTest.testSeda(CommonRouteTest.java:93)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at junit.framework.TestCase.runTest(TestCase.java:164)
at junit.framework.TestCase.runBare(TestCase.java:130)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:120)
at junit.framework.TestSuite.runTest(TestSuite.java:230)
at junit.framework.TestSuite.run(TestSuite.java:225)
at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
and
java.lang.AssertionError: mock:event-publisher Received message count.
Expected: <1> but was: <0>
at
org.apache.camel.component.mock.MockEndpoint.fail(MockEndpoint.java:511)
at
org.apache.camel.component.mock.MockEndpoint.assertEquals(MockEndpoint.java:493)
at
org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied(MockEndpoint.java:148)
at
org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied(MockEndpoint.java:125)
at
xxx.actions.common.route.CommonRouteTest.testDirect(CommonRouteTest.java:133)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at junit.framework.TestCase.runTest(TestCase.java:164)
at junit.framework.TestCase.runBare(TestCase.java:130)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:120)
at junit.framework.TestSuite.runTest(TestSuite.java:230)
at junit.framework.TestSuite.run(TestSuite.java:225)
at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Thanks !!
--
View this message in context:
http://www.nabble.com/Why-are-both-tests-failing--tf4643641s22882.html#a13263902
Sent from the Camel - Users mailing list archive at Nabble.com.