【问题标题】:Camel Properties Load骆驼属性加载
【发布时间】: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


    【解决方案1】:

    您应该使用来自 CamelTestSupport 的 useOverridePropertiesWithPropertiesComponent,请参阅:https://camel.apache.org/camel-test.html

    【讨论】:

      【解决方案2】:

      好的...我尝试了明显的...在 before 类之外定义 Property 对象,并且有效...似乎必须有另一种方法引用之前类中加载的属性对象。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-04-30
        • 2014-05-13
        • 1970-01-01
        • 1970-01-01
        • 2014-12-14
        • 1970-01-01
        • 2019-01-16
        相关资源
        最近更新 更多