### Question:
S3ContentReferenceHandlerImpl extends AbstractUrlContentReferenceHandler { @Override public long putFile(File sourceFile, ContentReference targetContentReference) throws ContentIOException { if (! isContentReferenceSupported(targetContentReference)) { throw new ContentIOException("ContentReference not supported"); } long startTime = System.currentTimeMillis(); String remotePath = getRelativePath(targetContentReference.getUri()); try { long contentLength = sourceFile.length(); try { Upload xfer = tm.upload(s3BucketName, remotePath, sourceFile); xfer.waitForCompletion(); } catch (InterruptedException e) { logger.error("Upload was interrupted: "+e.getMessage()); Thread.currentThread().interrupt(); throw new ContentIOException("Failed to write content", e); } ObjectMetadata metadata = s3.getObjectMetadata( new GetObjectMetadataRequest(s3BucketName, remotePath)); long storedContentLength = metadata.getContentLength(); if (logger.isWarnEnabled()) { if (storedContentLength != contentLength) { logger.warn("Metadata length differs - expected " + contentLength + ", actual "+ storedContentLength); } } if (logger.isDebugEnabled()) { logger.debug("Upload file: " + s3BucketName + ":" + remotePath + " (in "+(System.currentTimeMillis()-startTime)+" msecs)"); } return storedContentLength; } catch (AmazonClientException e) { throw new ContentIOException("Failed to write content", e); } }  void setS3AccessKey(String s3AccessKey); void setS3SecretKey(String s3SecretKey); String getS3BucketName(); void setS3BucketName(String s3BucketName); void setS3BucketRegion(String s3BucketLocation); void init(); static AmazonS3 initClient(String s3AccessKey, String s3SecretKey, String s3BucketRegion); @Override boolean isContentReferenceSupported(ContentReference contentReference); @Override boolean isContentReferenceExists(ContentReference contentReference); @Override InputStream getInputStream(ContentReference contentReference, boolean waitForAvailability); @Override long putFile(File sourceFile, ContentReference targetContentReference); @Override long putInputStream(InputStream sourceInputStream, ContentReference targetContentReference); @Override void delete(ContentReference contentReference); static final String S3_STORE_PROTOCOL; static final String S3_PROTOCOL_DELIMITER; static final String HTTP_PROTOCOL; static final String HTTPS_PROTOCOL; }### Answer:
@Test public void testPutFile() throws IOException { Long pf_start_size = getVar("pf_start_size", new Long(1024 * 1024 * 1L), Long.class); Integer pf_multiplier = getVar("pf_multiplier", new Integer(2), Integer.class); Integer pf_count = getVar("pf_count", new Integer(3), Integer.class); Integer pf_repeat = getVar("pf_repeat", new Integer(1), Integer.class); if (logger.isInfoEnabled()) { logger.info("testPutFile: pf_start_size="+pf_start_size+", pf_multiplier="+pf_multiplier +", pf_count="+pf_count+", pf_repeat="+pf_repeat); } long testContentSizeInBytes = pf_start_size; for (int i = 0; i < pf_count; i++) { File testFile = createTestFile(testContentSizeInBytes); for (int j = 0; j < pf_repeat; j++) { testPutFileImpl(testFile, true); testPutFileImpl(testFile, false); } if (cleanup) { testFile.delete(); } testContentSizeInBytes = testContentSizeInBytes * pf_multiplier; } }