Я пытаюсь проверить ниже верблюжий маршрут. Однако проблема в том, что я не могу получить что-либо на мой mockQueue
, вместо того, чтобы получать сообщение на моем mockQueue
, оно отправляется в настоящую очередь.
Также обратите внимание, что я отправляю сообщение в MQ, используя бин intead конечной точки очереди.
Я также пытался издеваться над бобом, как показано ниже.
@EndpointInject(uri = "mock:mqService")
private MockEndpoint mqService;
Маршрут
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)
Ниже мой Junit
@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);
}
}