From 13c2bba13683ed907dc4c4921cd1fbb07f78230e Mon Sep 17 00:00:00 2001 From: "adrian.f.cole" Date: Mon, 29 Jun 2009 11:00:51 +0000 Subject: [PATCH] Issue 69: consolidated encoding test git-svn-id: http://jclouds.googlecode.com/svn/trunk@1488 3d8758e0-26b5-11de-8745-db77d3ebf521 --- .../commands/DeleteObjectIntegrationTest.java | 68 +++++++------------ 1 file changed, 26 insertions(+), 42 deletions(-) diff --git a/aws/s3/core/src/test/java/org/jclouds/aws/s3/commands/DeleteObjectIntegrationTest.java b/aws/s3/core/src/test/java/org/jclouds/aws/s3/commands/DeleteObjectIntegrationTest.java index f1d7bb8b37..8dd4ac5a8f 100644 --- a/aws/s3/core/src/test/java/org/jclouds/aws/s3/commands/DeleteObjectIntegrationTest.java +++ b/aws/s3/core/src/test/java/org/jclouds/aws/s3/commands/DeleteObjectIntegrationTest.java @@ -27,10 +27,12 @@ import static org.testng.Assert.assertEquals; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; import org.jclouds.aws.AWSResponseException; import org.jclouds.aws.s3.S3IntegrationTest; -import org.jclouds.aws.s3.domain.S3Object; +import org.jclouds.aws.s3.domain.S3Bucket; +import org.testng.annotations.DataProvider; import org.testng.annotations.Test; /** @@ -43,50 +45,44 @@ import org.testng.annotations.Test; @Test(groups = { "integration", "live" }, testName = "s3.DeleteObjectIntegrationTest") public class DeleteObjectIntegrationTest extends S3IntegrationTest { + private static final String LOCAL_ENCODING = System.getProperty("file.encoding"); + @Test void deleteObjectNotFound() throws Exception { String bucketName = getBucketName(); + String key = "test"; try { - addObjectToBucket(bucketName, "test"); - assert client.deleteObject(bucketName, "test").get(10, TimeUnit.SECONDS); + assert client.deleteObject(bucketName, key).get(10, TimeUnit.SECONDS); } finally { returnBucket(bucketName); } } - - @Test - void deleteObjectWithSpaces() throws Exception { + + @DataProvider(name = "delete") + public Object[][] createData() { + return new Object[][] { { "sp ace" }, { "unic¿de" }, { "qu?stion" } }; + } + + @Test(dataProvider = "delete") + void deleteObject(String key) throws Exception { String bucketName = getBucketName(); try { - addObjectToBucket(bucketName, "p blic-read-acl"); - assert client.deleteObject(bucketName, "p blic-read-acl").get(10, TimeUnit.SECONDS); + addObjectToBucket(bucketName, key); + assert client.deleteObject(bucketName, key).get(10, TimeUnit.SECONDS); + assertBucketEmptyDeleting(bucketName, key); } finally { returnBucket(bucketName); } } - - @Test - void deleteObjectUnicade() throws Exception { - String bucketName = getBucketName(); - try { - addObjectToBucket(bucketName, "p¿blic-read-acl"); - assert client.deleteObject(bucketName, "p¿blic-read-acl").get(10, TimeUnit.SECONDS); - } finally { - returnBucket(bucketName); - } + + private void assertBucketEmptyDeleting(String bucketName, String key) + throws InterruptedException, ExecutionException, TimeoutException { + S3Bucket listing = client.listBucket(bucketName).get(10, TimeUnit.SECONDS); + assertEquals(listing.getContents().size(), 0, String.format( + "deleting %s, we still have %s left in bucket %s, using encoding %s", key, listing + .getContents().size(), bucketName, LOCAL_ENCODING)); } - - @Test - void deleteObjectQuestion() throws Exception { - String bucketName = getBucketName(); - try { - addObjectToBucket(bucketName, "p?blic-read-acl"); - assert client.deleteObject(bucketName, "p?blic-read-acl").get(10, TimeUnit.SECONDS); - } finally { - returnBucket(bucketName); - } - } - + @Test void deleteObjectNoBucket() throws Exception { try { @@ -97,16 +93,4 @@ public class DeleteObjectIntegrationTest extends S3IntegrationTest { } } - @Test - void deleteObject() throws Exception { - String bucketName = getBucketName(); - try { - addObjectToBucket(bucketName, "test"); - assert client.deleteObject(bucketName, "test").get(10, TimeUnit.SECONDS); - assert client.headObject(bucketName, "test").get(10, TimeUnit.SECONDS) == S3Object.Metadata.NOT_FOUND; - } finally { - returnBucket(bucketName); - } - - } } \ No newline at end of file