[英]load properties in mule munit
I have some placeholders in my flow. 我的流程中有一些占位符。 Values for these placeholders are specified in a properties file (in classpath ).
这些占位符的值在属性文件(在classpath中 )中指定。 I am doing munit using java.
我正在使用Java执行munit。 Currently, these placeholders are not getting replaced by values in property file.
当前,这些占位符尚未被属性文件中的值替换。 Any idea how do I load this file while running munit?
知道如何在运行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. 在Overrideing
getConfigResources()
指定一个test-config.xml
,其中包含您的模拟连接器和属性文件的上下文属性占位符。 Store that test properties file in src/test/resources 将该测试属性文件存储在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: 在
mule-config-test.xml
,定义测试属性文件,如下所示:
<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. 在这种情况下,
wmo-mule-app.properties
是我的实际应用属性文件,而wmo-mule-app-unit-test.properties
是最重要的单元测试属性文件。 This unit-test property file will take precedence over wmo-mule-app.properties
此单元测试属性文件将优先于
wmo-mule-app.properties
目前,您可能会将文件放在/ src / main / resources中,尝试将其放在/ src / test / resources中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.