How do I replace a heavy-weight input endpoint with a mock and send a message to it?
Say I have the following route.
from("spring-ws:rootqname:{http://myNameSpace}SomeRequest?endpointMapping=#endpointMapping").
processor(new VeryComplicatedProcessor()).
to(etc).
to(etc)...
In other words, a spring web service that does a whole lotta processing.
One way to test this route is to start up the webservice in a webserver and send it a message, but that's a lot more overhead than I'd like to incur.
Instead, I'd expect that if I mock all of my endpoints, I should be able to do this:
public class RouteTest extends CamelSpringTestSupport {
@Override
public String isMockEndpoints() {
return "*"; // mock everything
}
@Test
public void simpleDirectTest() throws Exception {
String realURI = "spring-ws:rootqname:{http://myNameSpace}SomeRequest?endpointMapping=#endpointMapping";
String mockedURI = "mock:" + realURI;
String msg = buildSomeSoapMsg();
Object out = template.requestBody(mockedURI, msg);
log.debug(out.toString());
}
...
}
... and have the entire route run and return the response to me. Instead though, I just get the message sent right back to me, and the route hasn't been run.
Is my understanding of mocks incorrect? If so is there an alternative way to achieve this? I'd really like to avoid having to actually start the webservice to test these routes.
Thanks all.
EDIT - It looked for a minute like I could use AdviceWith to solve this problem, but AdviceWith only seems to work with outputs, and not inputs as is the case above.