Hey, i am wondering how testing exception throwing in junit. I have my mock endpoint defined and the exchange received with a processor that throws an error. Now the template.sendBody on the endpoint does throw an error but still has a normal exchange message.
How can i do this last part to assert the exception on the exchange. Unit test: @Test @DirtiesContext public void test_echo_route_socketError() throws InterruptedException{ final String echoString = "Welcome to Camel echo demonstration" ; endPoint.expectedMessageCount(0); endPoint.whenAnyExchangeReceived(new Processor() { public void process(Exchange exchange) throws Exception { exchange.setException(new ConnectException("Simulated connection error")); } }); template.sendBody("mock:cxf:bean:echoService", echoString); endPoint.assertIsSatisfied(); } Route: @Override public void configure() throws Exception { onException(ConnectException.class) .log(LoggingLevel.WARN,".......") ; from("cxf:bean:echoService") .log(LoggingLevel.TRACE, "Start echo route") ; } -- View this message in context: http://camel.465427.n5.nabble.com/Test-exception-thrown-in-junit-test-tp5742984.html Sent from the Camel - Users mailing list archive at Nabble.com.