我有一个流,我正在尝试使用Munit在Mule中测试一个基本的HTTP流,该流如下所示:
<flow name="health-checkFlow">
<http:listener config-ref="HTTP_Listener_Configuration"
path="/" allowedMethods="GET" doc:name="HTTP">
<http:response-builder />
</http:listener>
....
</flow>对于Munit,我使用以下方法调用该流:
MuleEvent resultEvent = runFlow("health-checkFlow", testEvent(""));resultEvent对象具有正确的有效负载,但是当我尝试使用以下方法获取http响应代码时:
assertEquals("HTTP status code should be 200","200",resultEvent.getMessage().getOutboundProperty("http.status"));状态始终为空。如何从Munit中的消息中获取http响应代码?
发布于 2015-04-02 09:45:04
通过调用runFlow,您实际上绕过了http:listener,直接调用了流。默认情况下,将禁用入站端点和连接器。若要测试http部分,请在测试用例中覆盖以下内容:
@Override
protected boolean haveToMockMuleConnectors()
{
return false;
}
@Override
protected boolean haveToDisableInboundEndpoints()
{
return false;
}然后,我将使用标准的Java客户机或Mule客户机来测试HTTP入站端点并检查状态代码。
https://stackoverflow.com/questions/29403352
复制相似问题