Reputation: 492
Hy all,
suppose I have to following production code:
from("file:/home/test/from/")
.setHeader("targetDynamicEndpoint", constant("file:/home/test/to/"))
.toD("${header.targetDynamicEndpoint}")
How would I be able to mock the producer endpoint ('toD')?
I would be able to guess the string passed to the 'toD', because its set via StringBoot properties
Upvotes: 4
Views: 2547
Reputation: 436
In a test you could use AdviceWith and call the method weaveByType
for example:
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);
or you could even give the producer endpoint an id and use the method weaveById
Upvotes: 5