如何在Munit中为功能测试用例附加文件-Mule ESB

如何在Munit中为功能测试用例附加文件-Mule ESB,mule,mule-studio,mule-component,munit,Mule,Mule Studio,Mule Component,Munit,我需要通过Munit进行端到端(功能测试)测试。为此,我需要附加实际有效载荷,即图像。如何在入站消息处理器中附加图像(Munit-Set消息,没有附加选项)或任何其他方法 <flow name="TestImage"> <file:inbound-endpoint path="tmp\imageUpload" responseTimeout="10000" doc:name="ImageFlow" connector-ref="fileConn" fileAge

我需要通过Munit进行端到端(功能测试)测试。为此,我需要附加实际有效载荷,即图像。如何在入站消息处理器中附加图像(Munit-Set消息,没有附加选项)或任何其他方法

   <flow name="TestImage"> 
    <file:inbound-endpoint path="tmp\imageUpload" responseTimeout="10000" doc:name="ImageFlow" connector-ref="fileConn" fileAge="100" pollingFrequency="500"></file:inbound-endpoint> 
     ............. many processor..... Logic involved...
   <file:outbound-endpoint path="tmp\Upload" responseTimeout="10000" doc:name="Flow" connector-ref="fileConn" fileAge="100" pollingFrequency="500"></file:outbound-endpoint> 

............. 许多处理器。。。。。涉及的逻辑。。。

Mule Studio版本:5.3.1

默认情况下,文件入站端点将返回一个输入流作为负载,其中包含要读取的文件内容

现在,MUnit默认禁用入站端点,因此要测试此流,您必须对流“TestImage”执行流引用。 在这种情况下,您可以使用set message processor并通过以下方式加载要使用的测试文件:

<munit:set payload="#[getResource('test_image.jpeg').asStream()]" doc:name="Set Message"/>

这将创建一条带有负载的消息,该负载是图像的输入流


嗯。

谢谢!!我已经尝试了如下
#[getResource('src/test/resources/12379.jpg').asStream()]
。它似乎没有加载我在该位置的图像。你能帮忙吗。在内部,MEL函数正在做一个getClassLoader。getResourceAs。。。如果没有被拾取,可能是因为您提供的路径/资源名称错误。工作正常。非常感谢!!。我忘记在set payload processor中设置入站属性,因此得到了空映像。