簡體   English   中英

在測試Spring Boot Camel應用程序時出現NullPointerException

[英]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返回null我正在按照編寫測試用例

關於如何解決此問題的任何指示都將非常有幫助。

您需要使用路由的ID,而不是URL,例如,“ direct:start”是路由的URL,路由也具有ID。 如果不指定ID,然后一個id是自動分配,如route1route2等。

使用.routeId("myNameHere")指定路由的ID。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM