public void testResponseBodyWhenError() throws Exception {
try {
template.requestBody("http://localhost:{{port}}/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());
String type = cause.getResponseHeaders().get(Exchange.CONTENT_TYPE);
assertTrue(type.startsWith("text/plain"));
}
}