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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With