运行 骆驼蓝图测试时正在加载属性文件

Loading properties file while running camel blueprint test

我正在使用 property-placeholder 标签加载如下属性:

<cm:property-placeholder id="myblueprint.test" persistent-id="camel.blueprint"/>

在 JBOSS Fuse 上部署我的项目时,它将从 FUSE 的 /etc/ 目录加载 camel.blueprint.cfg,当我在结构配置文件上部署项目时,它将从属性中读取在配置文件中创建的文件。

但是,当我 运行 camel blueprint test 时,如何配置它以从特定位置加载属性文件?

浏览 documentation property-placeholder 后,我得到了解决方案。我们可以在测试用例文件中设置属性文件的位置,如下所示:

@Override
protected String[] loadConfigAdminConfigurationFile() {
    // String[0] = tell Camel the path of the .cfg file to use for OSGi ConfigAdmin in the blueprint XML file
    // String[1] = tell Camel the persistence-id of the cm:property-placeholder in the blueprint XML file
    return new String[]{"src/test/resources/etc/stuff.cfg", "stuff"};
}
  • 请确保 属性 文件的扩展名为 .cfg。否则将被忽略。