@Test public void testHandleNeedsConnectionLeftOpen() throws Exception { ByteArrayInputStream bais = new ByteArrayInputStream( "{\"key\" :\"Content\"}".getBytes(StringUtils.UTF8)); CRC32 crc32 = new CRC32(); crc32.update("{\"key\" :\"Content\"}".getBytes(StringUtils.UTF8)); HttpResponse response = new HttpResponse.Builder().statusText("testResponse") .statusCode(200).header("testKey", "testValue").content(bais).build(); final List<InputStream> capture = new ArrayList<InputStream>(); Unmarshaller<String, JsonUnmarshallerContext> unmarshaller = new Unmarshaller<String, JsonUnmarshallerContext>() { @Override public String unmarshall(JsonUnmarshallerContext in) throws Exception { capture.add(in.getHttpResponse().getContent()); return "OpenConnection"; } }; JsonResponseHandler<String> toTest = new JsonResponseHandler<String>(unmarshaller); toTest.needsConnectionLeftOpen = true; assertTrue(toTest.needsConnectionLeftOpen()); AmazonWebServiceResponse<String> awsResponse = toTest.handle(response); assertEquals(awsResponse.getResult(), "OpenConnection"); assertSame(capture.get(0), bais); } }