apache-cameljunit5camel-test

NPE during camel route test


I am trying to test camel route, and below are the annotations on my test class.

@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);
}
}

My test passes but at the console I keep receiving below error message.

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 *****

How do I resolve this error? Is it the error during my route processing?


Solution

  • This NPE is fixed in Camel 3.0.0-M3 which is to be released soon.