我正试图为我的camel jpa示例编写一个RouteTest类,由于以下行,它不像预期的那样工作:
Bundle RouteTest正在等待命名空间处理程序[http://aries.apache.org/xmlns/jpa/v1.1.0]
请在这里找到blueprint.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:camel="http://camel.apache.org/schema/blueprint"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
xmlns:jpa="http://aries.apache.org/xmlns/jpa/v1.1.0"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd
http://aries.apache.org/xmlns/jpa/v1.1.0 http://aries.apache.org/schemas/jpa/jpa_110.xsd">
<bean id="jpa" class="org.apache.camel.component.jpa.JpaComponent">
<jpa:unit unitname="persistence-pu" property="entityManagerFactory" />
</bean>
<camelContext trace="true" id="blueprintContext" xmlns="http://camel.apache.org/schema/blueprint">
<route id="persist">
<from uri="direct:persist"/>
<to uri="jpa:Person"/>
</route>
</camelContext>
</blueprint>
和RouteTest类:
public class RouteTest extends CamelBlueprintTestSupport {
@Override
protected String getBlueprintDescriptor() {
return "/OSGI-INF/blueprint/blueprint.xml";
}
@Test
public void testRoute() throws Exception {
getMockEndpoint("mock:result").expectedMinimumMessageCount(1);
ProducerTemplate producerTemplate = new DefaultCamelContext().createProducerTemplate();
Person person = new Person();
person.setName("Bob");
producerTemplate.sendBody("direct:persist", person);
// assert expectations
assertMockEndpointsSatisfied();
}
}
您需要提供Aries Blueprint,特别是您需要提供Aries JPA依赖项。你如何测试你的路线?我建议使用Pax-Exam,或者最好使用Pax-Exam- karaf并安装aries的jpa特性。