【发布时间】:2018-06-15 20:45:49
【问题描述】:
我刚刚阅读了一篇讨论在 Junit 中加载属性的帖子
(Loading Properties File In JUnit @BeforeClass)
属性 load 似乎有效,但我不确定如何在我的单元测试中引用特定属性...任何想法 - 我正在尝试加载 testinput 我的属性文件中的条目?
================================================ ============== 属性文件users.properties内容:
testinput=D/somefolder/somefile
public class OrderRouterTest2 extends CamelSpringTestSupport {
@Override
protected AbstractXmlApplicationContext createApplicationContext() {
return new ClassPathXmlApplicationContext("META-INF/spring/camel- context.xml");
}
@BeforeClass
public static void setUpBeforeClass() throws Exception {
final Properties props = new Properties();
final InputStream fileIn = OrderRouterTest2.class.getResourceAsStream("/**users.properties**");
**props.load(fileIn)**;
}
@Test
public void testSendToWebService() throws Exception {
// These don't work
String value1 = context.resolvePropertyPlaceholders("{{testinput}}");
String value2 = "I see ${testinput}";
String value3 = "I see {{testinput}}";
}
【问题讨论】:
标签: junit properties apache-camel