Hello,
in one of my tests, I just cannot get it working... expectedMessageCount
works fine and I see 3 incoming messages. I'd like to overwrite output
bodies to mock http call results, but whenAnyExchangeReceived is never
called and thus I cannot assert the final message content to be "foobar".
What could be reasons for that behavior?
MockEndpoint httpMock = getMockEndpoint("mock:http");
httpMock.expectedMessageCount(3);
httpMock.whenAnyExchangeReceived(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getIn().setBody("foobar"); // NEVER CALLEd
}
});
the rest of test setup:
@Before
public void mockEndpoints() throws Exception {
List<RouteDefinition> routeDefinitions =
context.getRouteDefinitions();
routeDefinitions.get(0).adviceWith(context,
new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
context().setStreamCaching(true);
replaceFromWith("direct:start");
weaveById("http").replace().to("mock:http");
}
});
}
@Override
protected AbstractApplicationContext createApplicationContext() {
FileSystemXmlApplicationContext ctx = new
FileSystemXmlApplicationContext(
"src/test/resources/configuration.xml"
);
return ctx;
}
And the route itself:
@Override
public void configure() throws Exception {
getContext().setStreamCaching(Boolean.TRUE);
from("file:input")
.split(body().tokenizeXML("number", "numbers"))
.setBody(simple(""))
.to("mock:http").id("http")
.setHeader(Exchange.FILE_NAME, constant("output.txt"))
.to("file:output");
}
Thanks for help!
--
View this message in context:
http://camel.465427.n5.nabble.com/whenAnyExchangeReceived-is-never-called-tp5749491.html
Sent from the Camel - Users mailing list archive at Nabble.com.