The attachments didn't come through....I've inlined them here: package au.com.zurich.phoenix.i90.routes;
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.test.junit4.CamelSpringTestSupport; import org.junit.Test; import org.springframework.context.support.AbstractXmlApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; /** * @author Mark Borner (gzhomzb) */ public class MultiCastRouteTest extends CamelSpringTestSupport { @Override protected AbstractXmlApplicationContext createApplicationContext() { return new ClassPathXmlApplicationContext("context/test-gateway.xml"); } @Override protected int getExpectedRouteCount() { // use 0 as we use a Java based route builder directly in this unit test return 0; } @Override protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { @Override public void configure() throws Exception { onException(Exception.class) .to("mock:end4") .handled(true) .transform(constant("Stop!")) .markRollbackOnly(); from("direct:start") .transacted() .multicast().stopOnException() .to("mock:end1", "mock:end2") .end() .to("mock:end3") .transform(constant("Hello to you too!")); } }; } @Test public void end1FailureTest() throws Exception { MockEndpoint end1 = getMockEndpoint("mock:end1"); end1.expectedMessageCount(1); end1.whenAnyExchangeReceived(new Processor() { public void process(Exchange exchange) throws Exception { throw new RuntimeException("Simulated Exception"); } }); MockEndpoint end4 = getMockEndpoint("mock:end4"); end4.expectedMessageCount(1); MockEndpoint end3 = getMockEndpoint("mock:end3"); end3.expectedMessageCount(0); MockEndpoint end2 = getMockEndpoint("mock:end2"); end2.expectedMessageCount(0); String result = (String)template.requestBody("direct:start", "Hello World!"); assertMockEndpointsSatisfied(); assertEquals("Stop!", result); } @Test public void end2FailureTest() throws Exception { MockEndpoint end1 = getMockEndpoint("mock:end1"); end1.expectedMessageCount(1); MockEndpoint end2 = getMockEndpoint("mock:end2"); end2.expectedMessageCount(1); end2.whenAnyExchangeReceived(new Processor() { public void process(Exchange exchange) throws Exception { throw new RuntimeException("Simulated Exception"); } }); MockEndpoint end3 = getMockEndpoint("mock:end3"); end3.expectedMessageCount(0); MockEndpoint end4 = getMockEndpoint("mock:end4"); end4.expectedMessageCount(1); String result = (String)template.requestBody("direct:start", "Hello World!"); assertMockEndpointsSatisfied(); assertEquals("Stop!", result); } @Test public void end3FailureTest() throws Exception { MockEndpoint end1 = getMockEndpoint("mock:end1"); end1.expectedMessageCount(1); MockEndpoint end2 = getMockEndpoint("mock:end2"); end2.expectedMessageCount(1); MockEndpoint end3 = getMockEndpoint("mock:end3"); end3.expectedMessageCount(1); end3.whenAnyExchangeReceived(new Processor() { public void process(Exchange exchange) throws Exception { throw new RuntimeException("Simulated Exception"); } }); MockEndpoint end4 = getMockEndpoint("mock:end4"); end4.expectedMessageCount(1); String result = (String)template.requestBody("direct:start", "Hello World!"); assertMockEndpointsSatisfied(); assertEquals("Stop!", result); } @Test public void goodRoute() throws Exception { MockEndpoint end1 = getMockEndpoint("mock:end1"); end1.expectedMessageCount(1); MockEndpoint end2 = getMockEndpoint("mock:end2"); end2.expectedMessageCount(1); MockEndpoint end3 = getMockEndpoint("mock:end3"); end3.expectedMessageCount(1); MockEndpoint end4 = getMockEndpoint("mock:end4"); end4.expectedMessageCount(0); String result = (String)template.requestBody("direct:start", "Hello World!"); assertMockEndpointsSatisfied(); assertEquals("Hello to you too!", result); } } And the Spring context: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx=" http://www.springframework.org/schema/tx" xsi:schemaLocation="http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"> <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="persistenceUnitName" value="testing"/> <property name="dataSource" ref="dataSource"/> <property name="jpaVendorAdapter"> <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"> <property name="database" value="DB2"/> <property name="databasePlatform" value="org.hibernate.dialect.DB2Dialect"/> </bean> </property> <property name="jpaProperties"> <props> <!--<prop key="hibernate.format_sql">true</prop>--> <!--<prop key="hibernate.show_sql">true</prop>--> <prop key="hibernate.default_schema">I90_GTWY</prop> </props> </property> </bean> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="com.ibm.db2.jcc.DB2Driver"/> <property name="url" value="jdbc:db2://zuxho15:50000/pxlocal"/> <property name="username" value="pxusr"/> <property name="password" value="phenx123"/> </bean> <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> <property name="entityManagerFactory" ref="entityManagerFactory"/> </bean> <tx:annotation-driven/> <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/> </beans> Thanks, Mark Mark Borner Java Developer - ZStream Xpress ----- Forwarded by Mark Borner/HO/Australia/Zurich on 18/11/2010 04:24 PM ----- From: Mark Borner <mark.bor...@zurich.com.au> To: "users@camel.apache.org" <users@camel.apache.org> Date: 18/11/2010 04:16 PM Subject: Multicast() Behaviour with Exceptions Hello all: Can someone help me with the behaviour of multicast() when exceptions are thrown? I've attached a unit test & Spring context to outline my question. What I'm expecting is that all unit tests pass. What I'm experiencing is that unit test "end1FailureTest" doesn't pass. And I don't understand why. Why would the behaviour be different if the first endpoint of a multicast() throws an exception versus the second? I've executed the unit test under Camel 2.4 and 2.5 with the same results. Any help is appreciated! Mark Mark Borner Java Developer - ZStream Xpress ---- This email is intended for the named recipient only. It may contain information which is confidential, commercially sensitive, or copyright. If you are not the intended recipient you must not reproduce or distribute any part of the email, disclose its contents, or take any action in reliance. If you have received this email in error, please contact the sender and delete the message. It is your responsibility to scan this email and any attachments for viruses and other defects. To the extent permitted by law, Zurich and its associates will not be liable for any loss or damage arising in any way from this communication including any file attachments. We may monitor email you send to us, either as a reply to this email or any email you send to us, to confirm our systems are protected and for compliance with company policies. Although we take reasonable precautions to protect the confidentiality of our email systems, we do not warrant the confidentiality or security of email or attachments we receive. ---- This email is intended for the named recipient only. It may contain information which is confidential, commercially sensitive, or copyright. If you are not the intended recipient you must not reproduce or distribute any part of the email, disclose its contents, or take any action in reliance. If you have received this email in error, please contact the sender and delete the message. It is your responsibility to scan this email and any attachments for viruses and other defects. To the extent permitted by law, Zurich and its associates will not be liable for any loss or damage arising in any way from this communication including any file attachments. We may monitor email you send to us, either as a reply to this email or any email you send to us, to confirm our systems are protected and for compliance with company policies. Although we take reasonable precautions to protect the confidentiality of our email systems, we do not warrant the confidentiality or security of email or attachments we receive.