@Test
public void testMalformedJson() throws Exception {
String in = "{ \"a\": 123, \"b\": true, \"c\": true2 }";
MockEndpoint mockXML = getMockEndpoint("mock:xml");
mockXML.expectedMessageCount(0);
MockEndpoint mockException = getMockEndpoint("mock:exception");
mockException.expectedMessageCount(1);
try {
template.requestBody("direct:unmarshal", in);
fail("Exception expected");
} catch (CamelExecutionException e) {
assertEquals("JSONException expected", JSONException.class, e.getCause().getClass());
}
List<Exchange> exchs = mockException.getExchanges();
assertEquals("Only one exchange was expected in mock:exception", 1, exchs.size());
Exception e = (Exception) exchs.get(0).getProperty(Exchange.EXCEPTION_CAUGHT);
assertNotNull("Exception expected", e);
assertEquals("JSONException expected", JSONException.class, e.getClass());