String destinationContainer = getContainerName();
String destinationObject = "copy.txt";
String destinationPath = "/" + destinationContainer + "/" + destinationObject;
String badDestination = "baddestination";
String data = "Hello World";
SwiftObject sourceSwiftObject = newSwiftObject(data, sourceObject);
getApi().putObject(sourceContainer, sourceSwiftObject);
// test that not giving a destination name *doesn't* copy source name to the destination container with
// the source name but copy still returns success :(
assertTrue(getApi().copyObject(sourceContainer, sourceObject, destinationContainer, ""));
assertFalse(getApi().objectExists(destinationContainer, sourceObject));
// test copy works
assertTrue(getApi().copyObject(sourceContainer, sourceObject, destinationContainer, destinationObject));
assertTrue(getApi().objectExists(destinationContainer, destinationObject));
SwiftObject destinationSwiftObject = getApi().getObject(destinationContainer, destinationObject);
assertEquals(Strings2.toStringAndClose(destinationSwiftObject.getPayload().openStream()), data);
// test exception thrown on bad destination container
try {
assertFalse(getApi().copyObject(sourceContainer, sourceObject, badDestination, destinationObject));
fail("Expected CopyObjectException");