我想更改文件类从哪个文件类获得它们。
我的班级现在这个样子:Junit替换属性
public class MyClass {
private String str;
public MyClass() throws IOException {
loadProperties();
}
private void loadProperties() throws IOException {
Properties props = new Properties();
props.load(getClass().getClassLoader().getResourceAsStream("my.properties"));
str= props.getProperty("property");
}
而且whyle测试我想性能,从另一个文件中加载。
这是Apache的骆驼的应用程序,所以我有这个现在:
public class ConverterTest {
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new MyClass(); //--> Here i must load from another file
}
@Test
// test
}
才能实现这一目标?
它将如何有效的呢?我将仅使用此构造函数进行测试。但我想知道是否有可能做到这一点,而不需要添加任何东西到我的主类。 – qiGuar