Property placeholder’s issue in MUnit

Last Updated on 04/05/2021 by Patryk Bandurski

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.

Problem

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

Excerpt from flow with SMTP Connector
Excerpt from flow with SMTP Connector

The 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 not in curly. 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. So what is going on?

Solution

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.

Property placeholder’s issue in MUnit

Leave a Reply

Your email address will not be published.

Scroll to top