camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oli <olilog...@gmail.com>
Subject Re: Testing CDI Route
Date Thu, 03 Nov 2016 16:06:24 GMT
Hi Antonin,

in other words, CamelCdiRunner would do the job? Why it doesn't work for me?
The test class:

@RunWith(CamelCdiRunner.class)
@Beans(classes = Route.class)
public class RouteTest {

    void advice(
            @Observes CamelContextStartingEvent event, 
            @Uri("mock:test") MockEndpoint messages, 
            ModelCamelContext context) throws Exception {

        context.getRouteDefinition("route")
                .adviceWith(context, new AdviceWithRouteBuilder() {
                    @Override
                    public void configure() {
                        replaceFromWith("direct:start");
                        weaveById("mybean").replace().to("mock:mybean");
                    }
                });
    }

    @Test
    /**
     * testing if the bean was properly mocked
     */
    public void testRoute(
            @Uri("direct:in") ProducerTemplate producer,
            @Uri("mock:mybean") MockEndpoint mock) throws
InterruptedException {

        mock.expectedMessageCount(1);
        mock.expectedBodiesReceived("bar");
        producer.sendBody("bar");
        MockEndpoint.assertIsSatisfied(5L, TimeUnit.SECONDS, mock);
    }

}



--
View this message in context: http://camel.465427.n5.nabble.com/Testing-CDI-Route-tp5789709p5789714.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message