Mule SMTP testing with MUnit MailServer Mock

Very often we use Mule SMTP connector in flows. How to ensure it is sending emails as expected? Let's write a test case for it.

Manik Magar

4 minute read

Testing Mule SMTP using MUnit MailServer Mock We often use Mule SMTP connector in flows. But how to make sure that emails gets sent as expected? MUnit provides MailServer that we can use to mock real SMTP server and verify the mails sent by SMTP connector. Lets see how we can write munit test case for below subflow: <context:property-placeholder location="munit-mailserver-demo.properties" /> <sub-flow name="subflow-mail-sender"> <set-variable variableName="emailSubject" value="#[‘Welcome to UT’]" doc:name="Set Subject"/> <smtp:outbound-endpoint host="${email.

Unit Testing DataWeave JSON output

Often we generate JSON using DataWeave. What about testing it?

Manik Magar

2 minute read

In the previous post about unit testing DataWeave scripts with MUnit and JUnit, I showed you how to verify Java and CSV output of DataWeave scripts. We also looked at some error troubleshooting in dataweave scripts. Now, lets look at DataWeave with JSON output and how we can test the content of our output with MUnit and JUnit. DataWeave Script Let’s use the same DataWeave script from our previous post and change the output type to application/json.

Manik Magar

4 minute read

It is very common for any mule application to use external properties files. In this post, we will see how we can override properties values for testing. We will also cover how we can write to temporary folder during munit test, disable connector mocking and asserting file existence. For demonstration purpose, we will have a flow that uses DataWeave to convert xml file into csv and writes to an output folder using file:outbound-endpoint.