简体   繁体   中英

NullPointerException while testing Spring boot camel application

public class MyRouteTest extends CamelSpringTestSupport {

    @Override
    protected AbstractApplicationContext createApplicationContext() {
        AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
        ctx.scan("com.mypackage.routes");
        ctx.refresh();
        return ctx;
    }
    @Test
    public void testRouteRunning() throws Exception {
       assertTrue(context().getRouteStatus("direct:start").isStarted());
    }
}

getRouteStatus is returning null I am following this to write my test cases

Any pointers on how to fix this will be very helpful.

You need to use the id of the route, not the url, eg "direct:start" is the url of the route, the route has an id as well. If you do not specify an id, then an id is auto assigned such as route1 , route2 etc.

Use .routeId("myNameHere") to specify the id of a route.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM