The fundamental question is how do I test my routes with mock endpoints on both ends? The following code works.
public class CamelTest extends CamelTestSupport { @EndpointInject(uri = "mock:result") protected MockEndpoint resultEndpoint; @Produce(uri = "direct:start") protected ProducerTemplate template; public static class MyBean1 { public void doIt(Exchange exchange) { System.out.println(this.getClass()); } } public static class MyBean2 { public void doIt(Exchange exchange) { System.out.println(this.getClass()); } } @Override protected Context createJndiContext() throws Exception { Context context = super.createJndiContext(); context.bind("bean1", new MyBean1()); context.bind("bean2", new MyBean2()); return context; } @Override protected RouteBuilder createRouteBuilder() { return new RouteBuilder() { public void configure() { from("direct:start") .beanRef("bean1") .beanRef("bean2") .to("mock:result"); } }; } @Test public void test1() throws InterruptedException { resultEndpoint.expectedBodiesReceived("Hello World"); template.sendBody("direct:start", "Hello World"); resultEndpoint.assertIsSatisfied(); } } 1. How can I replicate the same test, with route configured using XML? 2. I commented out line @Produce(uri = "direct:start") and added line template = this.context.getRegistry().lookup("template", ProducerTemplate.class); in createRouteBuilder(), but the template ended to be null. -- View this message in context: http://camel.465427.n5.nabble.com/ProducerTemplate-with-Spring-and-without-tp3266469p3267325.html Sent from the Camel - Users mailing list archive at Nabble.com.