MuleESB简单测试用例无法正常工作

时间:2016-05-28 16:15:57

标签: junit mule mule-studio

我有以下简单的Mule ESB流程,我试图编写一个测试用例:

<div id="test"></div>

有问题的测试案例是:

<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" basePath="/product-design" doc:name="HTTP Listener Configuration"/>
<jms:activemq-connector name="Active_MQ" brokerURL="tcp://localhost:61616" validateConnections="true" doc:name="Active MQ"/>
<flow name="product-designFlow">
    <http:listener  config-ref="HTTP_Listener_Configuration" path="/" allowedMethods="POST" doc:name="HTTP"/>
    <byte-array-to-string-transformer doc:name="Byte Array to String"/>
    <logger message="We received message: #[message.payload]" level="INFO" doc:name="Logger"/>
    <jms:outbound-endpoint topic="product-design-topic" connector-ref="Active_MQ" doc:name="JMS"/>
</flow>

但是,当我尝试运行此测试用例时,我收到以下异常。我错过了什么?

public class SimpleProductRegistrationTestCase extends FunctionalTestCase {

public String getConfigResources(){
    return "src/main/app/product-design.xml";
}

@Test
public void exampleCase() throws MuleException{
    MuleClient client=muleContext.getClient();
    MuleMessage inMessage = new DefaultMuleMessage("loalalal",muleContext);
    MuleMessage outMessage=client.send("http://localhost:8081/product-design", inMessage);
    assertNotNull(outMessage);
}
}

1 个答案:

答案 0 :(得分:2)

问题是您的侦听器设置为仅接受POST请求,但默认情况下MuleClient将发送GET。要配置MuleClient以发送POST,您应该按照here的说明定义OperationOptions。