-1

我正在尝试为我的骆驼 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();
    }

}
4

1 回答 1

0

您需要提供 Aries 蓝图,尤其是您需要提供 aries JPA 依赖项。你如何测试你的路线?我建议使用 Pax-Exam 或者可能更好地使用 Pax-Exam-Karaf 并安装 aries jpa 功能。

于 2013-04-03T06:45:47.130 回答