Issue 69: consolidated encoding test

git-svn-id: http://jclouds.googlecode.com/svn/trunk@1488 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
adrian.f.cole 2009-06-29 11:00:51 +00:00
parent c8669a63c3
commit 13c2bba136
1 changed files with 26 additions and 42 deletions

View File

@ -27,10 +27,12 @@ import static org.testng.Assert.assertEquals;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.jclouds.aws.AWSResponseException; import org.jclouds.aws.AWSResponseException;
import org.jclouds.aws.s3.S3IntegrationTest; 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; import org.testng.annotations.Test;
/** /**
@ -43,50 +45,44 @@ import org.testng.annotations.Test;
@Test(groups = { "integration", "live" }, testName = "s3.DeleteObjectIntegrationTest") @Test(groups = { "integration", "live" }, testName = "s3.DeleteObjectIntegrationTest")
public class DeleteObjectIntegrationTest extends S3IntegrationTest { public class DeleteObjectIntegrationTest extends S3IntegrationTest {
private static final String LOCAL_ENCODING = System.getProperty("file.encoding");
@Test @Test
void deleteObjectNotFound() throws Exception { void deleteObjectNotFound() throws Exception {
String bucketName = getBucketName(); String bucketName = getBucketName();
String key = "test";
try { try {
addObjectToBucket(bucketName, "test"); assert client.deleteObject(bucketName, key).get(10, TimeUnit.SECONDS);
assert client.deleteObject(bucketName, "test").get(10, TimeUnit.SECONDS);
} finally { } finally {
returnBucket(bucketName); returnBucket(bucketName);
} }
} }
@Test @DataProvider(name = "delete")
void deleteObjectWithSpaces() throws Exception { public Object[][] createData() {
return new Object[][] { { "sp ace" }, { "unic¿de" }, { "qu?stion" } };
}
@Test(dataProvider = "delete")
void deleteObject(String key) throws Exception {
String bucketName = getBucketName(); String bucketName = getBucketName();
try { try {
addObjectToBucket(bucketName, "p blic-read-acl"); addObjectToBucket(bucketName, key);
assert client.deleteObject(bucketName, "p blic-read-acl").get(10, TimeUnit.SECONDS); assert client.deleteObject(bucketName, key).get(10, TimeUnit.SECONDS);
assertBucketEmptyDeleting(bucketName, key);
} finally { } finally {
returnBucket(bucketName); returnBucket(bucketName);
} }
} }
@Test private void assertBucketEmptyDeleting(String bucketName, String key)
void deleteObjectUnicade() throws Exception { throws InterruptedException, ExecutionException, TimeoutException {
String bucketName = getBucketName(); S3Bucket listing = client.listBucket(bucketName).get(10, TimeUnit.SECONDS);
try { assertEquals(listing.getContents().size(), 0, String.format(
addObjectToBucket(bucketName, "p¿blic-read-acl"); "deleting %s, we still have %s left in bucket %s, using encoding %s", key, listing
assert client.deleteObject(bucketName, "p¿blic-read-acl").get(10, TimeUnit.SECONDS); .getContents().size(), bucketName, LOCAL_ENCODING));
} finally {
returnBucket(bucketName);
}
} }
@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 @Test
void deleteObjectNoBucket() throws Exception { void deleteObjectNoBucket() throws Exception {
try { 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);
}
}
} }