This is what my test looks like

@EndpointInject(uri="mock:coreEndpoint", context="coreContext")
MockEndpoint mockEndpoint;

@Produce(uri="direct:jmsInputQueue")
ProducerTemplate producerTemplate;

@Test
public void test(){
  mockEndpoint.whenAnyExchangeReceived(new Processor(){  
         public void process(Exchange ago0) throws Exception{ 
             System.out.println("here"); 
              throw new RuntimeException("blah"); 
        } 

  producerTemplate.sendBody("blahblah");

  // do verification here that my error handler handled and logged the
exception
}); 

}

All logging is routed to the Console. When I run the above, I see the
logging from my route and the "here" in the console but I do not see the
exception (nor the stack trace) logged. This should be logged either by the
default error handler or my onException handling.

If instead of using the MockEndpoint.whenAnyExchangeReceived I use
adviceWith on the route and throw a RuntimeException I see the exception on
the console (via the logger) and am able to verify that my onException
handled the exception due to the logging.

The route design is as follows (using all direct components)...

Context 1: 
    from("direct:input")... to("direct:input2");
    from("direct:input2)... to("context2:coreChannel");

Context 2:
    from("direct:coreChannel").log(...).to("mock:mockEndpoint");



--
View this message in context: 
http://camel.465427.n5.nabble.com/Using-MockEndpoint-to-throw-an-Exception-not-propated-tp5733088p5733129.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to