@Test public void testTransferException() throws Exception { WebRequest req = new PostMethodWebRequest( CONTEXT_URL + "/services/hello", new ByteArrayInputStream("".getBytes()), "text/plain"); ServletUnitClient client = newClient(); client.setExceptionsThrownOnErrorStatus(false); WebResponse response = client.getResponse(req); assertEquals(500, response.getResponseCode()); assertEquals(HttpConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT, response.getContentType()); Object object = HttpHelper.deserializeJavaObjectFromStream(response.getInputStream()); assertNotNull(object); IllegalArgumentException cause = assertIsInstanceOf(IllegalArgumentException.class, object); assertEquals("Damn", cause.getMessage()); }