Apache camel 如何在Apache Camel中模拟cxfbean调用?
我有一条叫cxfbean的路线:Apache camel 如何在Apache Camel中模拟cxfbean调用?,apache-camel,Apache Camel,我有一条叫cxfbean的路线: .to("cxfbean:reservationService") 在我的测试中试着用 @EndpointInject(uri = "mock:reservationService") MockEndpoint reservationSystemMock; @BeforeMethod private void setUpContext() throws Exception { context.getRouteDefinition( "send.to
.to("cxfbean:reservationService")
在我的测试中试着用
@EndpointInject(uri = "mock:reservationService")
MockEndpoint reservationSystemMock;
@BeforeMethod
private void setUpContext() throws Exception
{
context.getRouteDefinition( "send.to.res.svc.endpoint" ).adviceWith(
context, new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception
{
interceptSendToEndpoint("cxfbean:reservationService")
.skipSendToOriginalEndpoint()
.to("mock:reservationService");
}
});
}
还尝试使用weaveByToString(**reservationService”).replace().to(“mock:reservationService”)代码>。在这两种情况下,我得到:
Caused by: org.apache.camel.NoSuchBeanException: No bean could be found in the registry for: reservationService
我想在没有cxf bean实例化的情况下测试我的路由。我正在使用CamelTestSupport类作为父类。请记住在您的测试类上打开建议。如果使用这些注释,则将@UseAdviceWith
添加到类中
然后在您建议的之后启动camel上下文
使用weaveByToString(“to[cxfbean:reservationService]”模拟cxfbean端点
:
似乎我们还可以在debug watcher中使用context.getRoutedDefinitions().get(0).toString()
查看weaveByToString
的必要表达式
@EndpointInject(uri = "mock:reservationService")
protected MockEndpoint reservationSystemMock;
@BeforeMethod
private void setUpContext() throws Exception
{
context.getRouteDefinition( "send.to.res.svc.endpoint" ).adviceWith(
context, new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
weaveByToString( "To[cxfbean:reservationService]" )
.replace().to( "mock:reservationService" );
}
});
}