From what I've read about Mock, it will only verify what comes in. I'm looking for a way to also send a response back in order for the route to continue.
Using the below example with line numbers (I've fixed my typos):
(3) .process(new Process())
If I set up a mock endpoint for line 2, I can test what comes in. But it's not clear how I would have the mock endpoint for line 2 return a value so the mock endpoint at line 4 can be tested.
I'm I mistaken what the mock endpoint is capable of?
I took a look at interceptSendToEndpoint. This looks very promising. Do you have an example of how I could apply this technique to the above example? I'm really trying to figure out a way to represent an endpoint that receives input and returns output.
You can use the whenAnyMessageReceived on the mock endpoint to provide a processor where you can manipulate the Exchange and set a response as you like.
For example doing that at step 2
The Camel in Action book contains an entire section in the test chapter #5, about using interceptSendToEndpoint in testing.
As always a good place to look for examples is also the camel source code in the src/test/java folder.
Just grep for interceptSendToEndpoint.
thanks. however, it should be whenAnyExchangeReceived. whenAnyMessageReceived is not a method defined on the MockEndpoint.
Edited by: lyfe on Feb 24, 2010 5:46 PM