String fullPath = FilenameUtils.concat(SYSTEM_TMP.getAbsolutePath(),
filename);
logger.info("Test Copy File Location: " + fullPath);
try {
byte randomData[] = makeRandomFile(fullPath);
FilesClient client = new FilesClient();
assertTrue(client.login());
// Set up
client.createContainer(containerSrc);
if (null != containerDest && !containerSrc.equals(containerDest)) {
client.createContainer(containerDest);
}
// Store it
logger.info("About to save: " + filename);
String mime = "application/octet-stream";
assertNotNull(client.storeObjectAs(containerSrc,
new File(fullPath),
mime,
filename));
verifyStoredObject(containerSrc,
filename,
mime,
randomData,
client);
// Do the copy
logger.info("About to copy: " + filename);
String dest = null == containerDest ? "not-exist" : containerDest;
String etag = client.copyObject(containerSrc,
filename,
dest,
filename);
String md5 = FilesClient.md5Sum(randomData);
assertEquals(md5, etag);
verifyStoredObject(containerDest,
filename,
mime,
randomData,
client);
// Clean up
client.deleteObject(containerSrc, filename);
assertTrue(client.deleteContainer(containerSrc));
if (null != containerDest && !containerSrc.equals(containerDest)) {
client.deleteObject(containerDest, filename);
assertTrue(client.deleteContainer(containerDest));
}
} catch (FilesException fe) {
System.err.println(fe.getHttpHeadersAsString());
System.err.println(fe.getHttpStatusMessage());