I have some placeholders in my flow. Values for these placeholders are specified in a properties file (in classpath ). I am doing munit using java. Currently, these placeholders are not getting replaced by values in property file. Any idea how do I load this file while running munit?
My munit is like this:
Class MyClass extends FunctionalMunitSuite{
@Override
protected String getConfigResources() {
//try 1[gave give value pairs directly]: didnt worked
System.getProperties().put("prop.key", "value");
//try2[load prop files]:didn't worked
prop.load(this.getClass().getResourceAsStream("mypropertyfile.properties"));
System.setProperties(prop);
}
}
In Overriding getConfigResources()
specify a test-config.xml
which has your mock connector and context property placeholder of properties file. Store that test properties file in src/test/resources
@Override
protected String getConfigResources() {
return "mule-config-test.xml" + ",actual-flow-to-test.xml";
}
Inside mule-config-test.xml
, define test property file like this:
<context:property-placeholder ignore-resource-not-found="true" location="wmo-mule-app.properties,wmo-mule-app-unit-test.properties" />
In this case, wmo-mule-app.properties
is my actual app property file while wmo-mule-app-unit-test.properties
is the over-riding unit-test property file. This unit-test property file will take precedence over wmo-mule-app.properties
目前,您可能会将文件放在/ src / main / resources中,尝试将其放在/ src / test / resources中
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.