我從駱駝開始,我在編寫測試時遇到了一些問題。我的使用案例與cfx proxy example完全一樣。除了我不需要「RealWebservice」。現在,我試圖寫一個單元測試(如不包括在例如一個集成測試),使用註釋的方法:如何在模擬終端的駱駝測試中啓動路由
@RunWith(CamelSpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:application-context.xml" })
@MockEndpointsAndSkip
public class RoutesTest {
@Autowired
CamelContext camelContext;
@EndpointInject(uri = "mock:cxf:bean:cxfEndpoint", context = "camelContext")
MockEndpoint cxfEndpoint;
@EndpointInject(uri = "mock:log:input", context = "camelContext")
MockEndpoint logInputEndpoint;
@EndpointInject(uri = "mock:http:realhostname:8211/service", context = "camelContext")
MockEndpoint realEndpoint;
@EndpointInject(uri = "mock:cxf:bean:cxfEndpoint")
ProducerTemplate producer;
@Test
public void testLeleuxMifidRoute() throws InterruptedException {
String body = "<blah/>";
cxfEndpoint.expectedBodiesReceived(body);
logInputEndpoint.expectedBodiesReceived(body);
realEndpoint.expectedBodiesReceived(body);
producer.sendBody(body);
MockEndpoint.assertIsSatisfied(camelContext);
}
}
的cxfEndpoint收到消息但其他端點沒有。
的路線是這樣的(它,當我運行它,用了SoapUI發送郵件的作品,很明顯,我混淆在這個例子中,IPS和beannames):
<endpoint id="callRealWebService" uri="http://realhostname:8211/service?throwExceptionOnFailure=true" />
<route>
<from uri="cxf:bean:cxfEndpoint?dataFormat=MESSAGE"/>
<to uri="log:input?showStreams=true"/>
<to ref="callRealWebService"/>
<to uri="log:output"/>
</route>
我在做什麼錯?我發現的所有示例和其他問題似乎都使用「直接:開始」或更改生產路線。