2

I need to do end to end (Functional Testing)testing via Munit. For that, I need to attach actual payload which is Image. How can I attach the image in Inbound message processor( Munit - Set Message, there is no option for attachment) or any other way we can achieve this.

   <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 Version: 5.3.1

star
  • 1,493
  • 1
  • 28
  • 61

1 Answers1

4

The file inbound endpoint will by default return a input stream as payload with the content of the file you want to read.

Now MUnit disable inbound endpoints by default so to test this flow you'll have to do a flow-ref to your flow "TestImage". In this case you can use the set message processor and load the test file you want to use in the following way:

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

This'll create a message with a payload that's an input stream for your image.

HTH.

Dds
  • 712
  • 5
  • 7
  • Thanks!! I have tried as below `#[getResource('src/test/resources/12379.jpg').asStream()]`. It not seems to be loading my image present in the location. Could you please help. – star Oct 28 '15 at 00:31
  • 1
    Internally that MEL function is doing a getClassLoader.getResourceAs... If it's not getting picked up it's probably that the path/resource name you're providing is wrong. – Dds Oct 28 '15 at 14:52
  • Working perfectly fine. Thanks alot!!. I forget to set the inbound Property in set payload processor thus i got the null image. – star Oct 28 '15 at 21:27