public void testResponseBodyWhenError() throws Exception {
try {
template.sendBody("http://localhost:8080/myapp/myservice", "bookid=123");
fail("Should have thrown an exception");
} catch (RuntimeCamelException e) {
HttpOperationFailedException cause = (HttpOperationFailedException) e.getCause();
assertEquals(500, cause.getStatusCode());
String body = context.getTypeConverter().convertTo(String.class, cause.getResponseBody());
assertTrue(body.indexOf("Damm") > -1);
assertTrue(body.indexOf("IllegalArgumentException") > -1);
assertNotNull(cause.getResponseHeaders());
assertTrue("Should have http header with content type set", cause.getResponseHeaders()[0].getValue().indexOf("text/plain") > -1);
}
}