Stephan, You appear not to be mocking the activemq:queue:output endpoint before you get the mock endpoint i the test. If you temporarily change the route uri to mock:activemq:queue:output then the test works. I am not sure how you would do it using injection. I use advicewith on the route to mock URIs before the test. Here is a previous response https://stackoverflow.com/questions/29581561/in-an-apache-camel-application-how-can-unit-tests-inject-mock-endpoints-in-plac <https://stackoverflow.com/questions/29581561/in-an-apache-camel-application-how-can-unit-tests-inject-mock-endpoints-in-plac> to the same issue.
Here is another code snippet @RunWith(CamelSpringBootRunner.class) @MockEndpoints @UseAdviceWith @SpringBootTest(classes = MyApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class AssignOrderReferenceTests { public static final String ROUTE_ID = “myroute"; public static final String MOCK_ENRICH = "mock:put"; public static final String MOCK_OUT = "mock:out"; @Autowired private ProducerTemplate template; @Autowired private CamelContext camelContext; @Test public void formatReferenceFromCounter() throws Exception { camelContext.getRouteDefinition(ROUTE_ID).adviceWith(camelContext, new AdviceWithRouteBuilder() { @Override public void configure() throws Exception { replaceFromWith("direct:in"); weaveById(“id-of-endpoint").replace().inOut(MOCK_ENRICH); // you can use enpoint patterns. Have a look at the adviceWith docs. weaveAddLast().to(MOCK_OUT); } }); MockEndpoint mockEnrich = camelContext.getEndpoint(MOCK_ENRICH, MockEndpoint.class); MockEndpoint mockOut = camelContext.getEndpoint(MOCK_OUT, MockEndpoint.class); mockEnrich.whenAnyExchangeReceived(new Processor() { @Override public void process(Exchange exchange) throws Exception { exchange.getOut().setBody(COUNTER); } }); mockEnrich.expectedMessageCount(1); mockOut.expectedMessageCount(1); mockOut.expectedBodyReceived().constant(Prefix + (COUNTER)); camelContext.start(); template.sendBody("direct:in", 1); mockOut.assertIsSatisfied(); The AdviceWith is very powerful. HTH. O. > On 7 Jun 2017, at 11:27, Burkard Stephan <stephan.burk...@visana.ch> wrote: > > Hi > > I built Camel route tests in a Spring Boot project. My injected mock > endpoints do not receive any messages. I also tried to get the mock through > Camel context, but also without success. > > The log output says that the mock endpoints are created and the mocked > endpoint receives messages. Have I missed something or is this a known > problem? If the latter, how can I bring my mocks to work? > > I have attached a very simple Maven test project to show the problem. > > SpringBoot 1.4.2.RELEASE > Camel 2.17.3 > > Thanks > Stephan > <camelbootmocks.zip>