繁体   English   中英

为什么我的Apache Camel模拟端点在测试中不起作用?

[英]Why my Apache Camel mock endpoint doesn't work in test?

我想测试我的骆驼溃败。 我有测试课:

public class RequestTest extends CamelTestSupport {
  @Override
  protected CamelContext createCamelContext() throws Exception {
    applicationContext = new ClassPathXmlApplicationContext("META-INF/spring/camel-context.xml");
    return applicationContext.getBean(CamelContext.class);
  }
  @Test
  public void testDeliveryPush() throws Exception {
    context.addRoutes(new RouteBuilder() {
      @Override
      public void configure() throws Exception {
        from("direct:start")
          .to("activemq:is2.request?requestTimeout=30s");    
        from("activemq:is2.messages")
          .to("mock:result");
      }
    });

    MockEndpoint endpoint = getMockEndpoint("mock:result");
    endpoint.setExpectedMessageCount(1);

    String req = "body";  
    String result = template.requestBodyAndHeader("direct:start", req, RequestProcessor.AGENT_ID, 1003, String.class);
    Thread.sleep(30000);
    endpoint.assertIsSatisfied();
  }
}

我不明白为什么测试失败,但是我的activeMq队列中有消息。 为什么消息不会出现在模拟:结果端点中? 该消息在is2.messages中 在此处输入图片说明

我得到: java.lang.AssertionError: mock://result Received message count. Expected: <1> but was: <0> Expected :<1> Actual :<0> java.lang.AssertionError: mock://result Received message count. Expected: <1> but was: <0> Expected :<1> Actual :<0>

您将消息发送到一个队列( is2.request ),但在另一个队列is2.messages is2.messages 第二条路线无法正常工作,因此Mock端点永远不会收到消息。 还是您的问题中的错字?

并且在您的屏幕截图中没有消息。 队列为空。 消息(入队的消息),但它已被消耗(出队的消息)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM