【发布时间】:2021-05-26 02:31:52
【问题描述】:
我正在使用 Camel Timer 组件从 Azure 存储容器中读取 blob。将创建一个路由,该路由将每 10 秒轮询一次 blob,并由 CloudBlobProcessor 处理。
from("timer://testRoute?fixedRate=true&period=10s")
.to("azure-blob://storageAccountName/storageContainerName?credentials=#credentials")
.to(CloudBlobProcessor)
.to("mock:result");
我想通过创建类似这样的模拟端点来编写测试用例
MockEndpoint timerMockEndpoint = context.getEndpoint("timer://testRoute?fixedRate=true&period=10s", MockEndpoint.class);
但是,我在创建上述模拟端点时收到以下异常。
java.lang.IllegalArgumentException: The endpoint is not of type:
class org.apache.camel.component.mock.MockEndpoint but is: org.apache.camel.component.timer.TimerEndpoint
下面是我试图跳过发送到原始端点的代码
@Override
protected RoutesBuilder createRouteBuilder() throws Exception {
return new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
interceptSendToEndpoint("timer://testRoute?fixedRate=true&period=10s").skipSendToOriginalEndpoint()
.log("Original Batch Endpoint skipped")
.to("azure-blob://*")
.to(CloudBlobProcessor).to("mock:result");
from("timer://testRoute?fixedRate=true&period=10s").to("mock:result");
}
};
}
【问题讨论】:
标签: java apache-camel camel-test