我有调用cxfbean的路由:
.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类作为父级。
答案 0 :(得分:1)
使用@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" );
}
});
}
管理模拟cxfbean端点:
weaveByToString
似乎我们可以在调试观察器中使用context.getRouteDefinitions().get(0).toString()
查看.thumbnail{
background: transparent;
}
的必要表达式
答案 1 :(得分:0)
请记住在测试课上打开建议。如果您使用这些注释,则将@UseAdviceWith
添加到班级。
然后在你建议的后启动驼峰上下文,