h5chauhan
h5chauhan

Reputation: 1291

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.

Upvotes: 0

Views: 631

Answers (1)

Claus Ibsen
Claus Ibsen

Reputation: 55750

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.

Upvotes: 1

Related Questions