mirror of https://github.com/apache/jclouds.git
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:
parent
c8669a63c3
commit
13c2bba136
|
@ -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,48 +45,42 @@ 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
|
||||||
|
@ -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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue