### Question:
S3ObjectResponseHandler extends AbstractS3ResponseHandler<S3Object> { @Override public AmazonWebServiceResponse<S3Object> handle(HttpResponse response) throws Exception { final S3Object object = new S3Object(); final AmazonWebServiceResponse<S3Object> awsResponse = parseResponseMetadata(response); if (response.getHeaders().get(Headers.REDIRECT_LOCATION) != null) { object.setRedirectLocation(response.getHeaders().get(Headers.REDIRECT_LOCATION)); } if (response.getHeaders().get(Headers.REQUESTER_CHARGED_HEADER) != null) { object.setRequesterCharged(true); } if (response.getHeaders().get(Headers.S3_TAGGING_COUNT) != null) { object.setTaggingCount(Integer.parseInt(response.getHeaders().get(Headers.S3_TAGGING_COUNT))); } final ObjectMetadata metadata = object.getObjectMetadata(); populateObjectMetadata(response, metadata); object.setObjectContent(new S3ObjectInputStream(response.getContent())); awsResponse.setResult(object); return awsResponse; }  @Override AmazonWebServiceResponse<S3Object> handle(HttpResponse response); @Override boolean needsConnectionLeftOpen();  }### Answer:
@Test public void testHandle() throws Exception { ByteArrayInputStream bais = new ByteArrayInputStream("content".getBytes(StringUtils.UTF8)); HttpResponse response = new HttpResponse.Builder().content(bais) .header(Headers.REDIRECT_LOCATION, "redirect") .header(Headers.REQUESTER_CHARGED_HEADER, "true").build(); S3ObjectResponseHandler handler = new S3ObjectResponseHandler(); AmazonWebServiceResponse<S3Object> object = handler.handle(response); S3Object content = object.getResult(); assertEquals(content.getRedirectLocation(), "redirect"); assertTrue(content.isRequesterCharged()); S3ObjectInputStream is = content.getObjectContent(); int curr = -1; ByteArrayOutputStream baos = new ByteArrayOutputStream(); while ((curr = is.read()) != -1) { baos.write(curr); } assertArrayEquals(baos.toByteArray(), "content".getBytes(StringUtils.UTF8)); }