1
我正在嘗試使用http://camel.apache.org/mock.html爲我的駱駝路由創建測試用例。我需要驗證路由中的處理器。但簡單的測試不適合我。駱駝測試 - java.lang.IllegalArgumentException:必須指定defaultEndpoint
public class CamelRouteTest extends CamelTestSupport {
@Override
public String isMockEndpointsAndSkip() {
// override this method and return the pattern for which endpoints to mock,
// and skip sending to the original endpoint.
return "mock:result";
}
@Test
public void verifyMessageCount() throws Exception {
template.sendBody("Test");
getMockEndpoint("mock:result").expectedMessageCount(1);
assertMockEndpointsSatisfied();
}
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").to("mock:result");
}
};
}
}
堆棧跟蹤:
java.lang.IllegalArgumentException: defaultEndpoint must be specified
at org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:308)
at org.apache.camel.impl.DefaultProducerTemplate.getMandatoryDefaultEndpoint(DefaultProducerTemplate.java:506)
at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:370)