Java 如何在基于CamelSpringTestSupport的测试期间设置属性值
Im正在创建由驼峰路由组成的ServiceMix模块 在my beans.xml中,我有:Java 如何在基于CamelSpringTestSupport的测试期间设置属性值,java,spring,testing,apache-camel,apache-servicemix,Java,Spring,Testing,Apache Camel,Apache Servicemix,Im正在创建由驼峰路由组成的ServiceMix模块 在my beans.xml中,我有: <osgix:cm-properties id="companyProps" persistent-id="com.company.integration"> </osgix:cm-properties> <ctx:property-placeholder location=" file:${karaf.base}/etc/com.company.integ
<osgix:cm-properties id="companyProps"
persistent-id="com.company.integration">
</osgix:cm-properties>
<ctx:property-placeholder location="
file:${karaf.base}/etc/com.company.integration.cfg
" />
我想去掉test.xml,最好从属性文件加载测试属性。
我已经看到了一些对PropertyComponent的引用,但我无法实现这一点:-(在我们的组织中,我们将SpringOSGi配置与SpringBean配置分开 在我们的spring osgi配置中,我们将具有以下功能:
<osgix:cm-properties id="companyProps" persistent-id="com.company.integration">
<prop key="name">value</prop>
<prop key="name">value</prop>
...
</osgix:cm-properties>
<ctx:property-placeholder location="classpath*:test.properties" />
价值
价值
...
以及任何特定于osgi的配置(如服务注册、事件等)
在Springbean配置中,我们定义了可以在osgi容器外部使用的所有bean,包括camelRoutes/context等
对于我们的测试,我们使用Springbean定义和包含以下内容的测试spring配置启动ClassPathXmlContext:
<osgix:cm-properties id="companyProps" persistent-id="com.company.integration">
<prop key="name">value</prop>
<prop key="name">value</prop>
...
</osgix:cm-properties>
<ctx:property-placeholder location="classpath*:test.properties" />
以及osgi特定bean所需的任何模拟
希望这能有所帮助。非常有效!谢谢!:)
<ctx:property-placeholder location="classpath*:test.properties" />