Hello. thank you for your reply! I tried to use CamelSpringTestSupport and it works. My working example: public class TestTest extends CamelSpringTestSupport { @Override protected AbstractApplicationContext createApplicationContext() { return new ClassPathXmlApplicationContext("test-camel.xml"); } @Override public boolean isUseAdviceWith(){ return true; } @Test public void test() throws Exception{ ...context.start(); .... } }
But I'd like to use annotation. I have found example: https://github.com/CamelCookbook/camel-cookbook-examples/blob/master/camel-cookbook-testing/src/test/java/org/camelcookbook/examples/testing/advicewith/FixedEndpointEnhancedSpringTest.java I tried to use it in my case but my test didn't passed again: @RunWith(CamelSpringJUnit4ClassRunner.class) @ContextConfiguration({"classpath:test-camel.xml"}) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) @UseAdviceWith(true) public class TestTest2 { @EndpointInject(ref="requestEP") ProducerTemplate requestEP; @EndpointInject(ref="beanEP") ProducerTemplate beanEP; @Autowired ModelCamelContext context; @Test public void test() throws Exception{ context.getRouteDefinition("testRoute").adviceWith( context , new AdviceWithRouteBuilder(){ @Override public void configure() throws Exception { interceptSendToEndpoint( beanEP.getDefaultEndpoint().getEndpointUri() ). to("mock:send"). skipSendToOriginalEndpoint(); } }); context.start(); TestUtils.waitingFor("Configuration applied", 2000); MockEndpoint mockEP = context.getEndpoint("mock:send",MockEndpoint.class); mockEP.setExpectedCount( 1 ); context.createProducerTemplate().sendBody(requestEP.getDefaultEndpoint(), "Message"); mockEP.assertIsSatisfied(); TestUtils.waitingFor("All rows commited", 2000); } } And I have detected that if I comment string "context.start();" in my first example I get "Exception" that there are no consumers, but if I comment this string in my second example, I don't get the same error. As I understand http://camel.apache.org/spring-testing.html In case using @UseAdviceWith(true) CamelContexts don't start automatically. What is wrong and how to make test with annotation corrected? Thanks, Andrew -- View this message in context: http://camel.465427.n5.nabble.com/Apache-camel-InterceptSendTo-doesn-t-work-with-bean-endpoint-tp5779474p5779704.html Sent from the Camel - Users mailing list archive at Nabble.com.