### Question:
S3MetadataResponseHandler extends AbstractS3ResponseHandler<ObjectMetadata> { @Override public AmazonWebServiceResponse<ObjectMetadata> handle(HttpResponse response) throws Exception { ObjectMetadata metadata = new ObjectMetadata(); populateObjectMetadata(response, metadata); AmazonWebServiceResponse<ObjectMetadata> awsResponse = parseResponseMetadata(response); awsResponse.setResult(metadata); return awsResponse; }  @Override AmazonWebServiceResponse<ObjectMetadata> handle(HttpResponse response);  }### Answer:
@Test public void testHandle() throws Exception { HttpResponse response = new HttpResponse.Builder() .header(Headers.REQUEST_ID, "testId") .header(Headers.EXTENDED_REQUEST_ID, "extendedId") .header(Headers.S3_USER_METADATA_PREFIX + "userKey", "userValue") .header(Headers.LAST_MODIFIED, "Sun, 1 Jan 2006 12:00:00 GMT") .header(Headers.CONTENT_LENGTH, "5") .header(Headers.ETAG, "Etag") .header(Headers.EXPIRES, "Sun, 1 Jan 2006 12:00:00 GMT") .header(Headers.EXPIRATION, "expiry-date=\"Fri, 21 Dec 2012 00:00:00 GMT\", rule-id=\"Rule for testfile.txt\"") .header(Headers.RESTORE, "ongoing-request=\"false\", expiry-date=\"Wed, 07 Nov 2012 00:00:00 GMT\"") .header("UndefinedKey", "UndefinedValue") .header(Headers.STORAGE_CLASS, "STANDARD_IA") .build(); S3MetadataResponseHandler handler = new S3MetadataResponseHandler(); AmazonWebServiceResponse<ObjectMetadata> awsr = handler.handle(response); assertEquals(awsr.getResponseMetadata().getRequestId(), "testId"); assertEquals(((S3ResponseMetadata) awsr.getResponseMetadata()).getHostId(), "extendedId"); ObjectMetadata om = awsr.getResult(); assertEquals(om.getRawMetadataValue(Headers.REQUEST_ID), null); assertEquals(om.getRawMetadataValue(Headers.EXTENDED_REQUEST_ID), null); assertEquals(om.getUserMetaDataOf("userKey"), "userValue"); assertEquals(1136116800000L, om.getLastModified().getTime()); assertEquals(om.getContentLength(), 5); assertEquals(om.getETag(), "Etag"); assertEquals(1356048000000L, om.getExpirationTime().getTime()); assertEquals(1136116800000L, om.getHttpExpiresDate().getTime()); assertEquals("Rule for testfile.txt", om.getExpirationTimeRuleId()); assertEquals(1352246400000L, om.getRestoreExpirationTime().getTime()); assertFalse(om.getOngoingRestore()); assertEquals(om.getStorageClass(), StorageClass.StandardInfrequentAccess.toString()); }