骆驼路线测试期间的NPE

时间:2019-06-04 03:32:08

标签: apache-camel junit5 camel-test

我正在尝试测试骆驼路线,以下是我的测试课程的注释。

@RunWith(CamelSpringBootRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
@DisableJmx(true)
public class PortfolioTncRouteTest {
      ....
      ....
      @Test
public void portfolioTncRouteTest() throws Exception {
    Mockito.when(clientApiService.search(Mockito.any(TxnChangeLog.class))).thenReturn(txns);
    Mockito.when(cache.getValue("frequencies", "8")).thenReturn("Monthly");
    Mockito.when(cache.getValue("currencies", "1002")).thenReturn("USD");
    Transaction transaction = new Transaction();
    transaction.setRefStatusId(2);
    Mockito.when(transactionService.findTransaction(Mockito.any(), Mockito.any())).thenReturn(transaction);
    producerTemplate.sendBody(txns);
    mock.expectedMessageCount(1);
    mock.assertIsSatisfied(30000);
}
}

我的测试通过了,但是在控制台上,我不断收到以下错误消息。

2019-06-04 03:26:37,151 [main] INFO  g.t.r.PortfolioTncRoute$$EnhancerBySpringCGLIB$$e0e0e4a3 - ***** PORTFOLIO-TNC ROUTE STARTED *****
Exception in thread "CamelMainRunController" java.lang.RuntimeException: java.lang.NullPointerException
    at org.apache.camel.spring.boot.CamelSpringBootApplicationController.run(CamelSpringBootApplicationController.java:83)
    at org.apache.camel.spring.boot.CamelMainRunController$DaemonTask.run(CamelMainRunController.java:53)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
    at org.apache.camel.main.MainSupport.postProcessCamelContext(MainSupport.java:745)
    at org.apache.camel.main.MainSupport.initCamelContext(MainSupport.java:676)
    at org.apache.camel.main.Main.doStart(Main.java:107)
    at org.apache.camel.support.service.ServiceSupport.start(ServiceSupport.java:86)
    at org.apache.camel.main.MainSupport.run(MainSupport.java:203)
    at org.apache.camel.spring.boot.CamelSpringBootApplicationController.run(CamelSpringBootApplicationController.java:78)
    ... 2 more
2019-06-04 03:26:39,289 [Camel (ServicesRest) thread #5 - Split] INFO  g.t.r.PortfolioTncRoute$$EnhancerBySpringCGLIB$$e0e0e4a3 - ***** PORTFOLIO-TNC ROUTE COMPLETED *****

如何解决此错误?是我的路线处理过程中的错误吗?

1 个答案:

答案 0 :(得分:1)

此NPE已在即将发布的Camel 3.0.0-M3中修复。