Search code examples
functional-programmingmuletestcasemule-el

Muel-esb: Testing Choice Router


Is there a way to test a choice router for the following scenario which is based on the http.status? I am seeking a way to test the first condition of the router

<flow>  
 <choice>
  <when expression="#[message.inboundProperties['http.status'] !=201">  
   ......
   <otherwise>
    .....
   </otherwise>
  </choice>
</flow>

I want to verify that a javax.ws.rs.core.Response with can be correctly handled by the HTTP endpoint.


Solution

  • The flow doesn't have an inbound endpoint (thus it's a private flow) so to test it

    • create a test flow in a test XML config file that you will load side by side with your other Mule configuration XML files,
    • add an inbound VM endpoint to this test flow and make it call the private flow you want to test,
    • in your functional test case, use the Mule Client to dispatch a test message over the VM endpoint, setting properties on this test message that will end-up as inbound properties in the private flow.