私はCamelから出発していますが、テストを書く上で問題があります。私のユースケースは、cfx proxy exampleとまったく同じです。私は "RealWebservice"は必要ではないことを除いて。今私は、アノテーションのアプローチを使用して、ユニットテスト(ない例に含まれているとして、統合テスト)を書き込むしようとしている:模擬エンドポイントを使ったCamelテストのルートの開始方法
は@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>
何をしているのですか?私が見つけたすべての例と他の質問は、「直接的なもの:スタート」を使うか、生産ルートを変更するように見えます。