我从骆驼开始,我在编写测试时遇到了一些问题。我的用例与cfx 代理示例完全相同。除了我不需要“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>
我究竟做错了什么?我发现的所有示例和其他问题似乎都使用“direct:start”或更改生产路线。