我无法在模拟端点上断言。我在具有Java DSL路由的WildFly容器中使用JUnit和CDI注入。
...所以无论我嘲笑什么,都不是我所建议的:),所有断言都理应会失败。
@RunWith(Arquillian.class)
public class MyTest extends CamelTestSupport {
@Override
public boolean isUseAdviceWith() {
return true;
}
@Inject
private CamelContext camelContext;
@Test
public void someTest() {
camelContext.getRouteDefinition("routeid").adviceWith(camelContext,
new AdviceWithRouteBuilder() {
@Override
public void configure () throws Exception {
mockEndpoints();
}
});
Collection list = context.getEndpoints(); // the ModelCamelContext is always empty, looks bad
Collection list2 = camelContext.getEndpoints(); // has both route endpoints AND mocks, looks good
getMockEndpoint("mock:someid").expectedMessageCount(1); // will always CREATE a new endpoint in the empty modelcamelcontext
getMockEndpoint("mock:someid", false).expectedMessageCount(1); // will always crash, that endpoint ID is in the other context...
我会放弃注入的CamelContext,但是所有的路由都只在那创建,我不知道为什么。 CamelTestSupport的ModelCamelContext上下文始终为空...有些东西我初始化了不同/错误,但是我不能说什么。有人成功使用了Camel CDI模拟测试吗?