Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Junit 骆驼无法在模拟队列端点上接收消息_Junit_Apache Camel - Fatal编程技术网

Junit 骆驼无法在模拟队列端点上接收消息

Junit 骆驼无法在模拟队列端点上接收消息,junit,apache-camel,Junit,Apache Camel,我试着在骆驼路线下测试。然而,问题是我无法接收任何到我的mockQueue的消息,而不是在我的mockQueue上接收消息,它将进入实际队列 还要注意,我正在使用队列端点的Bean intead向MQ发送消息 我还试着模仿豆子,如下所示 @EndpointInject(uri = "mock:mqService") private MockEndpoint mqService; 路线 日志 下面是我的Junit @ActiveProfiles(“测试”) @RunWith(Ca

我试着在骆驼路线下测试。然而,问题是我无法接收任何到我的
mockQueue
的消息,而不是在我的
mockQueue
上接收消息,它将进入实际队列

还要注意,我正在使用队列端点的Bean intead向MQ发送消息

我还试着模仿豆子,如下所示

    @EndpointInject(uri = "mock:mqService")
    private MockEndpoint mqService;
路线

日志

下面是我的Junit

@ActiveProfiles(“测试”)
@RunWith(CamelSpringBootRunner.class)
@SpringBootTest(类=MainApplication.class)
@启用路由平均值
@模拟端点
公共类PortfolioTncRouteTest{
私有最终记录器Logger=LoggerFactory.getLogger(this.getClass());
@端点注入(uri=“mock:{{ibm.mq.queueName}}”)
私有模拟队列;
@端点注入(uri=“{tp.tnc.source endpoint}”)
私人生产企业;
@蚕豆
私人客户服务;
@试验
public void portfolioTncRouteTest()引发ParseException、IOException、InterruptedException{
List data=(List)TestHelper.getObject(“data/test/mock_input/ptnc_scenario_1.xml”,List.class);
Mockito.when(clientApiService.getData(Mockito.any(TxnInfo.class)),然后返回(data);
producerTemplate.sendBody(数据);
mockQueue.expectedMessageCount(3);
mockQueue.assertessatified(10000);
}
}

@MockEndpoints
将向模拟端点和实际端点发送消息。如果只想执行前者,请使用
@MockEndpointsAndSkip

    from("{{tp.tnc.source-endpoint}}")
    .log("Procesisng Route PortfolioTnc")
    .doTry()
        .process(portfolioTncProcessor)
        .bean(transactionManager, "beginTransaction()")
        .setHeader("txnInfo", simple("${body}"))
        .bean(clientApi, "getData")
        .setHeader("transactions", simple("${body}"))
        .setHeader("transactionSize", simple("${body.size()}"))
        .choice()
            .when(header("transactionSize").isLessThan(1))
            .log("No Transactions found.")
            .bean(transactionManager, "markSuccess")
            .stop()
        .end()
        .log("There are transactions to process.")
        .log("Audit directory logging")
        .log("{{tp.tnc.auditDir}}" + "${header.inXmlFileName}")
        .log("{{tp.tnc.auditDir}}" + "${header.inBinaryFileName}")
        .log("{{tp.tnc.auditDir}}" + "${header.outXmlFileName}")
        .log("{{tp.tnc.auditDir}}" + "${header.outBinaryFileName}")
        .wireTap("{{tp.tnc.auditDir}}" + "${header.inXmlFileName}").onPrepare(jacksonProcessor)
        .wireTap("{{tp.tnc.auditDir}}" + "${header.inBinaryFileName}").onPrepare(binaryProcessor)
        .bean(transformationService, "tranform")
        .wireTap("{{tp.tnc.auditDir}}" + "${header.outXmlFileName}").onPrepare(jacksonProcessor)
        .wireTap("{{tp.tnc.auditDir}}" + "${header.outBinaryFileName}").onPrepare(binaryProcessor)
        .process(jacksonProcessor)
        .split(xpath("/Holder/Envelope")).convertBodyTo(String.class)
        .bean(mqService, "send")
        .end()
        .bean(transactionManager, "markSuccess")
    .endDoTry()
    .doCatch(Exception.class)
        .bean(transactionManager, "markFailure")
        .log(LoggingLevel.ERROR, "EXCEPTION: ${exception.stacktrace}")
    .end();
     INFO  g.t.processor.PortfolioTncProcessor - PortfolioTncProcessor.process()
     INFO  g.t.service.impl.CsvServiceImpl - lastSuccess 2019-04-16 00:00:00 000,2019-04-16 02:50:28 547,SUCCESS 
     INFO  route2 - There are transactions to process.
     INFO  route2 - Audit directory logging
     INFO  route2 - file:some-dir/?fileName=some_file_name-2019-04-16T02-53-05.xml
     INFO  route2 - file:some-dir/?fileName=some_file_name-2019-04-16T02-53-05.ser
     INFO  route2 - file:some-dir/?fileName=some_file_name_resp-2019-04-16T02-53-05.xml
     INFO  route2 - file:some-dir/?fileName=some_file_name_resp-2019-04-16T02-53-05.ser
     (camel-1) thread #2 - WireTap] INFO  o.a.c.i.InterceptSendToMockEndpointStrategy - Adviced endpoint [file://some-dir/?fileName=some_file_name-2019-04-16T02-53-05.xml] with mock endpoint [mock:file:some-dir/]
     (camel-1) thread #3 - WireTap] INFO  o.a.c.i.InterceptSendToMockEndpointStrategy - Adviced endpoint [file://some-dir/?fileName=some_file_name-2019-04-16T02-53-05.ser] with mock endpoint [mock:file:some-dir/]
     (camel-1) thread #4 - WireTap] INFO  o.a.c.i.InterceptSendToMockEndpointStrategy - Adviced endpoint [file://some-dir/?fileName=some_file_name_resp-2019-04-16T02-53-05.xml] with mock endpoint [mock:file:some-dir/]
     (camel-1) thread #5 - WireTap] INFO  o.a.c.i.InterceptSendToMockEndpointStrategy - Adviced endpoint [file://some-dir/?fileName=some_file_name_resp-2019-04-16T02-53-05.ser] with mock endpoint [mock:file:some-dir/]
     INFO  o.a.camel.builder.xml.XPathBuilder - Created default XPathFactory com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl@30ae3c46
     INFO  g.t.service.impl.MqServiceImpl - Message sent sucessfully.
     INFO  g.t.service.impl.MqServiceImpl - Message sent sucessfully.
     INFO  g.t.service.impl.MqServiceImpl - Message sent sucessfully.
     INFO  o.a.c.component.mock.MockEndpoint - Asserting: mock://MY-Q-NAME is satisfied
     INFO  g.t.route.PortfolioTncRouteTest - ********************************************************************************
     INFO  g.t.route.PortfolioTncRouteTest - Testing done: portfolioTncRouteTest(gic.tradepublisher.route.PortfolioTncRouteTest)
     INFO  g.t.route.PortfolioTncRouteTest - Took: 15.561 seconds (15561 millis)
    @ActiveProfiles("test")
    @RunWith(CamelSpringBootRunner.class)
    @SpringBootTest(classes = MainApplication.class)
    @EnableRouteCoverage
    @MockEndpoints
    public class PortfolioTncRouteTest {

        private final Logger logger = LoggerFactory.getLogger(this.getClass());

        @EndpointInject(uri = "mock:{{ibm.mq.queueName}}")
        private MockEndpoint mockQueue;

        @EndpointInject(uri = "{{tp.tnc.source-endpoint}}")
        private ProducerTemplate producerTemplate;

        @MockBean
        private ClientApiService clientApiService;

        @Test
        public void portfolioTncRouteTest() throws ParseException, IOException, InterruptedException {
            List<AgiTxn<Integer>> data = (List<AgiTxn<Integer>>) TestHelper.getObject("data/test/mock_input/ptnc_scenario_1.xml", List.class);
            Mockito.when(clientApiService.getData(Mockito.any(TxnInfo.class))).thenReturn(data);
            producerTemplate.sendBody(data);
            mockQueue.expectedMessageCount(3);
            mockQueue.assertIsSatisfied(10000);
        }
    }