大家好,
假设我必须遵循生产代码:
from("file:/home/test/from/")
.setHeader("targetDynamicEndpoint", constant("file:/home/test/to/"))
.toD("${header.targetDynamicEndpoint}")
Run Code Online (Sandbox Code Playgroud)
我如何能够模拟生产者端点(“toD”)?
我能够猜测传递给“toD”的字符串,因为它是通过 StringBoot 属性设置的
在测试中,您可以使用AdviceWith并调用 weaveByType 方法
例如:
camelContext.getRouteDefinition("routeId").adviceWith(camelContext, new AdviceWithRouteBuilder() {
@Override
public void configure() {
weaveByType(ToDynamicDefinition.class).replace().to("mock:someMock")
}
});
MockEndpoint someMockEndpoint = camelContext.getEndpoint("mock:someMock", MockEndpoint.class);
Run Code Online (Sandbox Code Playgroud)
或者你甚至可以给生产者端点一个 id 并使用 weaveById 方法
| 归档时间: |
|
| 查看次数: |
2202 次 |
| 最近记录: |