JCLOUDS-1263: Add live integration test for manipulating objects through the Swift ObjectApi with unicode characters in their path
Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/d464e8a3 Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/d464e8a3 Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/d464e8a3 Branch: refs/heads/2.1.x Commit: d464e8a3704a780f7bec4873bce905413f987faa Parents: 4288c9e Author: Mat Mannion <[email protected]> Authored: Tue Apr 4 13:52:26 2017 +0100 Committer: Andrew Gaul <[email protected]> Committed: Mon May 21 22:23:04 2018 -0700 ---------------------------------------------------------------------- .../swift/v1/features/ObjectApiLiveTest.java | 35 +++++++++++++++----- 1 file changed, 27 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/jclouds/blob/d464e8a3/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ObjectApiLiveTest.java ---------------------------------------------------------------------- diff --git a/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ObjectApiLiveTest.java b/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ObjectApiLiveTest.java index 98a546e..02116f6 100644 --- a/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ObjectApiLiveTest.java +++ b/apis/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/features/ObjectApiLiveTest.java @@ -61,21 +61,40 @@ public class ObjectApiLiveTest extends BaseSwiftApiLiveTest { private String containerName = getClass().getSimpleName() + "Container"; static final Payload PAYLOAD = newByteSourcePayload(ByteSource.wrap("swifty".getBytes())); + protected void assertCanCreateReadUpdateDeleteList(String regionId, String containerName, String objectName) throws Exception { + assertNotNull(getApi().getContainerApi(regionId).create(containerName)); + assertNotNull(getApi().getObjectApi(regionId, containerName).put(objectName, PAYLOAD)); + + SwiftObject object = getApi().getObjectApi(regionId, containerName).get(objectName); + assertEquals(object.getName(), objectName); + checkObject(object); + assertEquals(toStringAndClose(object.getPayload().openStream()), "swifty"); + + String lexicographicallyBeforeName = objectName.substring(0, objectName.length() - 1); + object = getApi().getObjectApi(regionId, containerName) + .list(marker(lexicographicallyBeforeName)).get(0); + assertEquals(object.getName(), objectName); + checkObject(object); + + getApi().getObjectApi(regionId, containerName).delete(objectName); + getApi().getContainerApi(regionId).deleteIfEmpty(containerName); + } + public void testCreateWithSpacesAndSpecialCharacters() throws Exception { final String containerName = "container # ! special"; final String objectName = "object # ! special"; for (String regionId : regions) { - assertNotNull(getApi().getContainerApi(regionId).create(containerName)); - assertNotNull(getApi().getObjectApi(regionId, containerName).put(objectName, PAYLOAD)); + assertCanCreateReadUpdateDeleteList(regionId, containerName, objectName); + } + } - SwiftObject object = getApi().getObjectApi(regionId, containerName).get(objectName); - assertEquals(object.getName(), objectName); - checkObject(object); - assertEquals(toStringAndClose(object.getPayload().openStream()), "swifty"); + public void testCreateAndListWithUnicodeCharacters() throws Exception { + final String containerName = "container-unicâªde"; + final String objectName = "object-unicâªde"; - getApi().getObjectApi(regionId, containerName).delete(objectName); - getApi().getContainerApi(regionId).deleteIfEmpty(containerName); + for (String regionId : regions) { + assertCanCreateReadUpdateDeleteList(regionId, containerName, objectName); } }
