2
votes

I have a camel Java DSL route that's defined to pick up messages from a queue and route them to a Java processor. The route defines some exception handling that looks for exceptions of a particular type and places the message back on the queue if the processor throws that exception. I already know this route actually works, but I'd like to properly unit test the route.

Can someone post a simple Java DSL-based example of how to go about doing this? I'm piecing together suggestions from various postings that perhaps I should use the camel placeholder functionality to replace my activemq:queue endpoint with seda or a mock or a direct or something (not sure).

And perhaps I should use an interceptor to intercept the messages heading to the processor and have the interceptor's processor throw my exception. I'd like my unit test to send a message through, have my interceptor throw an exception, and expect the message to end up back on my simulated queue or something to that affect. But I'm not quite sure how to put it all together. Java DSL Examples please?

Thanks

1
stackoverflow.com/questions/25463356/… has a few suggestions that might also help - matt helliwell

1 Answers

4
votes

There is Java DSL examples as part of the unit tests of Apache Camel itself, though there is a lot of them, so it may take a bit to find a suitable examples.

Maybe better yet take a look at the examples from the Camel books such as Camel in Action, chapter 6:

And the Camel recipients book: