Over a million developers have joined DZone.

Property Placeholder's Issue in MUnit [Snippet]

DZone's Guide to

Property Placeholder's Issue in MUnit [Snippet]

Let's look at this brief article that includes a code screenshot of a problem someone faced when running an MUnit test.

· Integration Zone ·
Free Resource

Discover how you can get APIs and microservices to work at true enterprise scale.

In this brief article, I will describe the problem and solution that I have lately faced. As it is a good practice not to hard-code connection data I have extracted them to an external file called connection.properties. I did not expect to receive an error something like $[smtp.host]. I did not know what it can means. Below I have described what it is.


I have setup SMTP connector, like in the screenshot below. When I run my MUnit test for this particular flow, I received an error that my application can't be built.

Excerpt from flow with SMTP ConnectorThe problem I got in the console was as follows:

Caused by: java.net.URISyntaxException: Illegal character in hostname at index 7: smtp://$[Illegal character in hostname exception

At first, I didn't know why $[smtp.host] is in square brackets and not in curly brackets. I thought that I have made a mistake. That is why I looked into my source code in XML view. There, I found that smpt.host is in curly brackets as it should be. So, what is going on?


It turned out that I did not get a root cause exception message. The root cause was missing smtp.host property. I needed to create a separate property file in src/test/resources and then connect it into my MUnit test suit using Property Placeholder (Configuration). After that, the problem was gone.

APIs and microservices are maturing, quickly. Learn what it takes to manage modern APIs and microservices at enterprise scale.

integration ,mulesoft ,munit ,smtp

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}