Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mule 如何使用MUnit XML验证出站属性?_Mule_Mule Component_Munit - Fatal编程技术网

Mule 如何使用MUnit XML验证出站属性?

Mule 如何使用MUnit XML验证出站属性?,mule,mule-component,munit,Mule,Mule Component,Munit,在将有效负载发送到JMS队列之前,我在消息中设置了一些出站属性,我想在将消息发送到JMS队列之前测试这些属性是否在消息中正确设置 我曾考虑在JMS出站端点之前使用MUnit Spy,但Spy只能验证会话属性、调用属性和负载。有没有其他方法可以使用MUnit XML实现这一点 我创建了一个迷你mule项目来进一步说明这个问题。代码如下所示。本质上,它只是一个调用子流的流,该子流在mule消息中设置出站属性,而MUnit有一个间谍,它断言出站属性是在调用子流后在mule消息中设置的。然而,MUnit

在将有效负载发送到JMS队列之前,我在消息中设置了一些出站属性,我想在将消息发送到JMS队列之前测试这些属性是否在消息中正确设置

我曾考虑在JMS出站端点之前使用MUnit Spy,但Spy只能验证会话属性、调用属性和负载。有没有其他方法可以使用MUnit XML实现这一点

我创建了一个迷你mule项目来进一步说明这个问题。代码如下所示。本质上,它只是一个调用子流的流,该子流在mule消息中设置出站属性,而MUnit有一个间谍,它断言出站属性是在调用子流后在mule消息中设置的。然而,MUnit间谍似乎无法访问mule出站属性。我想知道在这个时候是否还有其他的解决办法。我知道文档指定spy此时只能验证会话和调用属性以及负载。欢迎提出任何建议

Sandbox.xml-主Mule文件

    <?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
    xmlns:spring="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd">
    <flow name="outbound-props-flow">
        <flow-ref name="outbound-props-sub-flow" doc:name="Call outbound-props-sub-flow"/>
        <logger message="#[message]" level="INFO" doc:name="Log Message"/>
    </flow>
    <sub-flow name="outbound-props-sub-flow">
        <set-property propertyName="outbound-prop-1" value="test1" doc:name="set-outbound-prop-1"/>
        <set-property propertyName="outbount-prop-2" value="test2" doc:name="set-outbound-prop-2"/>
    </sub-flow>
</mule>

MUnit文件-测试主流

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:mock="http://www.mulesoft.org/schema/mule/mock" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:munit="http://www.mulesoft.org/schema/mule/munit" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:core="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/munit http://www.mulesoft.org/schema/mule/munit/current/mule-munit.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/mock http://www.mulesoft.org/schema/mule/mock/current/mule-mock.xsd">
    <munit:config name="munit" doc:name="MUnit configuration"/>
    <spring:beans>
        <spring:import resource="classpath:sandbox.xml"/>
    </spring:beans>
    <munit:test name="outbound-props-flow-outbound-props-flowTest" description="Test">
        <mock:spy messageProcessor="mule:sub-flow" doc:name="Spy">
            <mock:with-attributes>
                <mock:with-attribute name="name" whereValue="#[matchContains('outbound-props-sub-flow')]"/>
            </mock:with-attributes>
            <mock:assertions-after-call>
                <logger message="Message in SPY Module: #[message]" level="INFO" doc:name="Log Message in Spy"/>
                <munit:assert-on-equals message="outbound-props-1 is not set properly" expectedValue="test1" actualValue="#[message.outboundProperties['outbound-prop-1']]" doc:name="Assert outbound-props-1 is set properly"/>
                <munit:assert-on-equals message="outbound-props-2 is not set properly" expectedValue="test1" actualValue="#[message.outboundProperties['outbound-prop-2']]" doc:name="Assert outbound-props-2 is set properly"/>
            </mock:assertions-after-call>
        </mock:spy>
        <flow-ref name="outbound-props-flow" doc:name="Flow-ref to outbound-props-flow"/>
    </munit:test>
</mule>

谢谢


胡安

不要用“间谍”这个词,它有一些局限性。请参阅文档:

您可以简单地在flow ref之后添加断言

<munit:test name="outbound-props-flow-outbound-props-flowTest" description="Test">  
    <flow-ref name="outbound-props-flow" doc:name="Flow-ref to outbound-props-flow"/>
    <munit:assert-on-equals message="outbound-props-1 is not set properly" expectedValue="test1" actualValue="#[message.outboundProperties['outbound-prop-1']]" doc:name="Assert outbound-props-1 is set properly"/>
    <munit:assert-on-equals message="outbound-props-2 is not set properly" expectedValue="test2" actualValue="#[message.outboundProperties['outbound-prop-2']]" doc:name="Assert outbound-props-2 is set properly"/>
</munit:test>

Hi Davo-鉴于间谍的局限性,我认为这是正确的方法!谢谢我认为这应该是mulesoft在其下一个munit版本中修复的东西。