2016-01-21 13 views
1

我有路由調用cxfbean:如何在Apache Camel中模擬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類作爲父項。

回答

1

管理與weaveByToString("To[cxfbean:reservationService]")嘲笑cxfbean端點:

@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"); 
      } 
     }); 
} 

也似乎我們可以偷看必要的表達weaveByToString使用context.getRouteDefinitions().get(0).toString()在調試觀察者