junit - 骆驼属性加载
问题描述
我刚刚阅读了一篇讨论在 Junit 中加载属性的帖子
(在 JUnit @BeforeClass 中加载属性文件)
属性加载似乎有效,但我不确定如何在我的单元测试中引用特定属性......任何想法 - 我正在尝试在我的属性文件中加载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}}";
}
解决方案
您应该使用 CamelTestSupport 中的 useOverridePropertiesWithPropertiesComponent,请参阅:https ://camel.apache.org/camel-test.html
推荐阅读
- angular - 如何解决 Angular 中的 Rx_1.map 错误?
- javascript - (TS) 属性行在 HTMLInputElemet 类型上不存在
- php - 决定在similar_text中将哪个字符串转到第一个/第二个参数
- javascript - JS 从字符串中读取对象
- android - 如何使用正则表达式为 EditText 设置输入掩码?
- c# - 有两个非常大的列表/集合 - 如何有效地检测和/或删除重复项
- android - React js 应用程序具有相同的文件夹图像,但在 ios png 图像中显示 alpha 透明度问题
- sql - 如果当前行中不可用,则从前一行获取日期值
- ios - 将值从 Objective-C 类传递给 Swift TableViewCell
- php - 找出数组中有多少个数大于 N