小编jon*_*123的帖子

在测试Camel路由时如何正确使用Mocks?

我正在尝试编写一个Camel测试,检查以确保基于内容的路由器正确地路由XML文件.以下是我的blueprint.xml中的enpoints和路由:

<endpoint uri="activemq:queue:INPUTQUEUE" id="jms.queue.input" />
<endpoint uri="activemq:queue:QUEUE1" id="jms.queue.1" />
<endpoint uri="activemq:queue:QUEUE2" id="jms.queue.2" />

<route id="general-jms.to.specific-jms">
    <from ref="jms.queue.input" />
    <choice>
      <when>
        <xpath>//object-type = '1'</xpath>
        <log message="Sending message to queue: QUEUE1" />
        <to ref="jms.queue.1" />
      </when>
      <when>
        <xpath>//object-type = '2'</xpath>
        <log message="Sending message to queue: QUEUE2" />
        <to ref="jms.queue.2" />
      </when>
      <otherwise>
        <log message="No output was able to be determined based on the input." />
      </otherwise>
    </choice>
</route>
Run Code Online (Sandbox Code Playgroud)

现在,我要做的就是发送一个1的示例源文件<object-type>并验证它是否路由到正确的队列(QUEUE1)并且是正确的数据(应该只将整个XML文件发送到QUEUE1) .这是我的测试代码:

public class RouteTest extends CamelBlueprintTestSupport {

    @Override
    protected String getBlueprintDescriptor() …
Run Code Online (Sandbox Code Playgroud)

apache-camel

5
推荐指数
1
解决办法
4541
查看次数

标签 统计

apache-camel ×1