Upgrade to Pro — share decks privately, control downloads, hide ads and more …

MUnit Testing With Mulesoft (Mock Message Proce...

MUnit Testing With Mulesoft (Mock Message Processor)-Part II

MUnit Testing With Mulesoft (Mock Message Processor)-Part II

Jitendra Bafna

May 16, 2017
Tweet

More Decks by Jitendra Bafna

Other Decks in Technology

Transcript

  1. Mock Message Processor Mock is a feature provided by MUnit

    to mocked the behavior of the message processor. Basically, MUnit replace the actual behavior of message processor with the behavior define by us. There are various scenarios where we can use the Mock Message processor. We have completed the development of your mule application and need to test the application but in our application there is database connector in message processor region and database is not ready to accept the any request and we still want to test the application. In such cases, we can mock the normal database connector behavior.
  2. Mock Message Processor There can be more scenarios like we

    are connecting to JMS queue but JMS is not ready and want to test the application. In such cases again, we can make use of mock message processor. Let's walkthrough how to use mock component in MUnit test. Below is the flow for which we will going to create MUnit tests and will mock set-payload component.
  3. Mock Message Processor Right click the flow and create the

    MUnit tests. It will create MUnit tests in the folder src/test/munit of your mule application.
  4. Mock Message Processor Define Message Processor To Mock Drag and

    Drop Mock component in the setup region of MUnit test.
  5. Mock Message Processor Define Message Processor To Mock Drag and

    Drop Mock component in the setup region of MUnit test. when messageProcessor is used to specify the message processor to be mocked. In this case, we have mock set-payload component.
  6. Mock Message Processor Define Mock With Attributes When we have

    more than one similar component (i.e. 2 set-payload) in our mule flow but we want to mock only one set payload. In that case we need to add attributes in Mock component which accept name and value of message processor. Below is the Mule flow having 2 set-payload and we need to mock only one component.
  7. Mock Message Processor • name is the name of attribute

    and it cannot be MEL expressions. • whereValue is the value that the attribute of the real message processor should contain. It accepts MEL expressions.