camelContext is null in Camel Route Testing while replaceFromWith

Viewed 374

I am trying to write JUnit test case to replace my JMS camel route with direct route. I am trying to replace route "myRoute" with "direct:start". But my camel context is coming as null.

@CamelSpringBootTest
@SpringBootTest(class = Application.class)
@ContextConfiguration
public class AppTest{
    
    @Autowired
    CamelContext camelContext;
    
    
    public void testMethod(){
    
        AdviceWith.adviceWith(camelContext, "myRoute", routeBuilder -> {
            routeBuilder.replaceFromWith("direct:start");
        });
    }    
}

I tried to start the camel context in an init() method. But getting below exception from AdviceWith class

@Before
public void init() throws Exception{
    camelContext.start();    
}

Exception: Getting cannot AdviceRoute as there are no routes

0 Answers
Related