Hi Oli, Indeed, your test class should work. However, it seems the WildFly Swarm plugin generates some other classes, like org.wildfly.swarm.cdi.StageConfigBean, that are deployed as bean classes and that seems to require some execution context. The CamelCdiRunner starts a Weld SE container with its default discovery mode enabled, hence those classes being deployed as well. IMHO, it’d be better to align with the testing approach recommended by WildFly Swarm as that is likely to make your life easier in the long run.
Antonin > On 03 Nov 2016, at 17:06, Oli <olilog...@gmail.com> wrote: > > 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.