I’m not sure why this is working in the real world, but the reason the test is 
failing is the default error handler is picking up the exception from the call 
to the direct://Validate <direct://Validate> route.  If you add 
".errorHandler(new NoErrorHandlerBuilder())” to the direct://Validate 
<direct://Validate> route, your test will pass.

Quinn Stevenson
qu...@pronoia-solutions.com
(801) 244-7758



> On Dec 1, 2017, at 6:07 AM, Burkard Stephan <stephan.burk...@visana.ch> wrote:
> 
> Hi Camel users
> 
> I have attached a simplified example project (Maven) to illustrate a strange 
> problem I have in the tests of a current project. 
> 
> *** Setup ***
> - There is a Camel route that receives messages
> - It sends them to a validation subroute
> - The validation subroute uses a choice/when block to check a header value
> 
> - If the header is ok, the message goes to the standard output endpoint
> - If the header is wrong, an exception is thrown and the error handler kicks 
> in
> - The error handler sends the message to an alternative endpoint
> 
> *** Problem ***
> If you open the project and run the route tests, you will see that one test 
> fails. 
> - It sends a message with the wrong header, so an exception is thrown
> - In the console output you can see that the error route processes the 
> message (as expected)
> ==> But the error endpoint mock does not receive the message (WHY? This is 
> wrong!)
> 
> *** It works in real life ***
> - When I run the real project with the real endpoints, the error endpoint 
> produces the messages
> - It is only in the test this does not work
> 
> *** Strange effect *** 
> When I move the choice/when block from the subroute to the main route, the 
> test is successful
> 
> Can anyone explain this? Is this a bug or am I doing/expecting something 
> wrong?
> 
> Thanks
> Stephan
> 
> 
> <CamelRouteTestDemo.zip>

Reply via email to