package camelinaction; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.test.spring.CamelSpringTestSupport; import org.junit.Test; import org.springframework.context.support.AbstractXmlApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; /** * Demonstrates how to use the Load Balancer EIP pattern. */ public class SpringFailoverLoadBalancerTest extends CamelSpringTestSupport { @Override protected AbstractXmlApplicationContext createApplicationContext() { return new ClassPathXmlApplicationContext("META-INF/spring/failover-loadbalancer.xml"); } @Test public void testLoadBalancer() throws Exception { // A should get the 1st, 3rd and 4th message MockEndpoint a = getMockEndpoint("mock:a"); a.expectedBodiesReceived("Hello", "Cool", "Bye"); // B should get the 2nd MockEndpoint b = getMockEndpoint("mock:b"); b.expectedBodiesReceived("Kaboom"); // send in 4 messages template.sendBody("direct:start", "Hello"); template.sendBody("direct:start", "Kaboom"); template.sendBody("direct:start", "Cool"); template.sendBody("direct:start", "Bye"); assertMockEndpointsSatisfied(); } }