Apache camel PaxExam和CmPropertyPlaceholder
我正在尝试实现PaxExam来测试蓝图骆驼路线:Apache camel PaxExam和CmPropertyPlaceholder,apache-camel,apache-karaf,blueprint-osgi,pax-exam,Apache Camel,Apache Karaf,Blueprint Osgi,Pax Exam,我正在尝试实现PaxExam来测试蓝图骆驼路线: <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0" xmlns:camel="http://camel.
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
xmlns:camel="http://camel.apache.org/schema/blueprint"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.0.0.xsd
http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
<cm:property-placeholder persistent-id="paxexam.HelloBean">
<cm:default-properties>
<cm:property name="greeter" value="Hey"/>
</cm:default-properties>
</cm:property-placeholder>
<bean id="helloBean" class="me.examples.paxexam.HelloBean">
<property name="say" value="${greeter} from Camel"/>
</bean>
[...]
这是我的PaxExam配置方法:
@Configuration
public static Option[] configure() throws Exception {
return new Option[] {
karafDistributionConfiguration().frameworkUrl(getFrameworkUrl("karaf"))
.karafVersion("2.2.11")
.useDeployFolder(false)
.unpackDirectory(new File("target/exam/unpack")),
logLevel(LogLevel.INFO),
keepRuntimeFolder(),
replaceConfigurationFile("etc/activemq-broker.xml", new File("src/test/resources/activemq-broker-test.xml")),
features(getKarafStandardFeaturesUrl(), "config", "http"),
features(getActiveMqFeaturesUrl(), "activemq-blueprint", "activemq-camel"),
features(getCamelFeaturesUrl(), "camel-core", "camel-blueprint", "camel-jms",
"camel-cxf", "camel-test", "camel-jackson", "camel-quartz"),
features(getSmixFeaturesUrl(), "saaj", "activemq-broker"),
streamBundle(bundle().add(Hello.class)
.add(HelloBean.class)
.add("OSGI-INF/blueprint/blueprint.xml",
new File("src/main/resources/OSGI-INF/blueprint/blueprint.xml").toURL())
.set(Constants.BUNDLE_SYMBOLICNAME, "me.examples.paxexam")
.set(Constants.IMPORT_PACKAGE, "org.osgi.service.blueprint,org.slf4j")
.set(Constants.DYNAMICIMPORT_PACKAGE, "*")
.build()).start()
};
}
在PaxExam中使用cm:property占位符需要做什么特殊的事情吗?
(移除标签使测试运行正常)
Thx提前,
干杯这是卡拉夫帕克斯考试吗? 如果是这样的话,您需要确保您有那些要通过配置管理服务设置的属性。
如果你说的是普通的Pax考试,你需要确保你有可用的ConfigurationAdmin服务。请稍后再看一看 这正是我需要的,非常感谢!有趣的是,我意识到我的代码实际上已经基于您在github上的项目,而您(再次)为我提供了解决方案……您是我的救星:)
@Configuration
public static Option[] configure() throws Exception {
return new Option[] {
karafDistributionConfiguration().frameworkUrl(getFrameworkUrl("karaf"))
.karafVersion("2.2.11")
.useDeployFolder(false)
.unpackDirectory(new File("target/exam/unpack")),
logLevel(LogLevel.INFO),
keepRuntimeFolder(),
replaceConfigurationFile("etc/activemq-broker.xml", new File("src/test/resources/activemq-broker-test.xml")),
features(getKarafStandardFeaturesUrl(), "config", "http"),
features(getActiveMqFeaturesUrl(), "activemq-blueprint", "activemq-camel"),
features(getCamelFeaturesUrl(), "camel-core", "camel-blueprint", "camel-jms",
"camel-cxf", "camel-test", "camel-jackson", "camel-quartz"),
features(getSmixFeaturesUrl(), "saaj", "activemq-broker"),
streamBundle(bundle().add(Hello.class)
.add(HelloBean.class)
.add("OSGI-INF/blueprint/blueprint.xml",
new File("src/main/resources/OSGI-INF/blueprint/blueprint.xml").toURL())
.set(Constants.BUNDLE_SYMBOLICNAME, "me.examples.paxexam")
.set(Constants.IMPORT_PACKAGE, "org.osgi.service.blueprint,org.slf4j")
.set(Constants.DYNAMICIMPORT_PACKAGE, "*")
.build()).start()
};
}