mirror of https://github.com/apache/jclouds.git
Updated JetS3t impl tests to follow new testing procedure (see Issue 57)
git-svn-id: http://jclouds.googlecode.com/svn/trunk@1452 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
parent
be824d757f
commit
8ea84a656a
|
@ -99,25 +99,37 @@ public class JCloudsS3ServiceIntegrationTest extends S3IntegrationTest {
|
|||
|
||||
@Test
|
||||
public void testCreateBucketImpl() throws S3ServiceException, InterruptedException,
|
||||
ExecutionException {
|
||||
ExecutionException, TimeoutException
|
||||
{
|
||||
String bucketName = getScratchBucketName();
|
||||
try {
|
||||
S3Bucket bucket = service.createBucket(new S3Bucket(bucketName));
|
||||
assertEquals(bucket.getName(), bucketName);
|
||||
assertTrue(client.bucketExists(bucketName).get());
|
||||
} finally {
|
||||
returnScratchBucket(bucketName);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@AfterSuite
|
||||
public void testDeleteBucketImpl() throws S3ServiceException, InterruptedException,
|
||||
ExecutionException, TimeoutException {
|
||||
emptyBucket(bucketName);
|
||||
|
||||
String bucketName = getScratchBucketName();
|
||||
try {
|
||||
service.deleteBucket(bucketName);
|
||||
assertFalse(client.bucketExists(bucketName).get(10, TimeUnit.SECONDS));
|
||||
} finally {
|
||||
returnScratchBucket(bucketName);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "testCreateBucketImpl")
|
||||
public void testDeleteObjectImpl() throws InterruptedException, ExecutionException,
|
||||
TimeoutException, S3ServiceException, IOException {
|
||||
TimeoutException, S3ServiceException, IOException
|
||||
{
|
||||
String bucketName = getBucketName();
|
||||
try {
|
||||
String objectKey = "key-testDeleteObjectImpl";
|
||||
String objectValue = "test";
|
||||
|
||||
|
@ -129,11 +141,17 @@ public class JCloudsS3ServiceIntegrationTest extends S3IntegrationTest {
|
|||
|
||||
assertEquals(client.headObject(bucketName, objectKey).get(10, TimeUnit.SECONDS),
|
||||
org.jclouds.aws.s3.domain.S3Object.Metadata.NOT_FOUND);
|
||||
} finally {
|
||||
returnBucket(bucketName);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "testCreateBucketImpl")
|
||||
public void testGetObjectDetailsImpl() throws InterruptedException, ExecutionException,
|
||||
TimeoutException, S3ServiceException, IOException {
|
||||
TimeoutException, S3ServiceException, IOException
|
||||
{
|
||||
String bucketName = getBucketName();
|
||||
try {
|
||||
String objectKey = "key-testGetObjectDetailsImpl";
|
||||
String objectValue = "test";
|
||||
String metadataName = "metadata-name-1";
|
||||
|
@ -151,13 +169,17 @@ public class JCloudsS3ServiceIntegrationTest extends S3IntegrationTest {
|
|||
assertEquals(objectDetails.getContentLength(), 4);
|
||||
assertNull(objectDetails.getDataInputStream());
|
||||
assertEquals(objectDetails.getMetadata(metadataName), metadataValue);
|
||||
|
||||
emptyBucket(bucketName);
|
||||
} finally {
|
||||
returnBucket(bucketName);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "testCreateBucketImpl")
|
||||
public void testGetObjectImpl() throws InterruptedException, ExecutionException,
|
||||
TimeoutException, S3ServiceException, IOException {
|
||||
TimeoutException, S3ServiceException, IOException
|
||||
{
|
||||
String bucketName = getBucketName();
|
||||
try {
|
||||
String objectKey = "key-testGetObjectImpl";
|
||||
String objectValue = "test";
|
||||
String metadataName = "metadata-name-2";
|
||||
|
@ -178,13 +200,17 @@ public class JCloudsS3ServiceIntegrationTest extends S3IntegrationTest {
|
|||
assertEquals(object.getMetadata(metadataName), metadataValue);
|
||||
|
||||
// TODO: Test conditional gets
|
||||
|
||||
emptyBucket(bucketName);
|
||||
} finally {
|
||||
returnBucket(bucketName);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "testCreateBucketImpl")
|
||||
public void testListAllBucketsImpl() throws InterruptedException, ExecutionException,
|
||||
TimeoutException, S3ServiceException {
|
||||
TimeoutException, S3ServiceException
|
||||
{
|
||||
String bucketName = getBucketName();
|
||||
try {
|
||||
// Ensure there is at least 1 bucket in S3 account to list and compare.
|
||||
S3Bucket[] jsBuckets = service.listAllBuckets();
|
||||
|
||||
|
@ -200,11 +226,16 @@ public class JCloudsS3ServiceIntegrationTest extends S3IntegrationTest {
|
|||
org.jclouds.aws.s3.domain.S3Bucket.Metadata jcBucket = jcBucketsIter.next();
|
||||
assert jsBucket.getName().equals(jcBucket.getName());
|
||||
}
|
||||
} finally {
|
||||
returnBucket(bucketName);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "testCreateBucketImpl")
|
||||
public void testListObjectsChunkedImpl() throws InterruptedException, ExecutionException,
|
||||
TimeoutException, IOException, S3ServiceException {
|
||||
String bucketName = getBucketName();
|
||||
try {
|
||||
addObjectToBucket(bucketName, "item1/subobject2");
|
||||
addObjectToBucket(bucketName, "item2");
|
||||
addObjectToBucket(bucketName, "object1");
|
||||
|
@ -275,13 +306,17 @@ public class JCloudsS3ServiceIntegrationTest extends S3IntegrationTest {
|
|||
assertEquals(chunk.getDelimiter(), "/");
|
||||
assertEquals(chunk.getPrefix(), "item");
|
||||
assertNull(chunk.getPriorLastKey());
|
||||
|
||||
emptyBucket(bucketName);
|
||||
} finally {
|
||||
returnBucket(bucketName);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "testCreateBucketImpl")
|
||||
public void testListObjectsImpl() throws InterruptedException, ExecutionException,
|
||||
TimeoutException, IOException, S3ServiceException {
|
||||
String bucketName = null;
|
||||
try {
|
||||
bucketName = getScratchBucketName();
|
||||
addObjectToBucket(bucketName, "item1/subobject2");
|
||||
addObjectToBucket(bucketName, "item2");
|
||||
addObjectToBucket(bucketName, "object1");
|
||||
|
@ -313,13 +348,16 @@ public class JCloudsS3ServiceIntegrationTest extends S3IntegrationTest {
|
|||
objects = service.listObjects(bucketName, "item", "/", 1000);
|
||||
assertEquals(objects.length, 1);
|
||||
assertEquals(objects[0].getKey(), "item2");
|
||||
|
||||
emptyBucket(bucketName);
|
||||
} finally {
|
||||
returnBucket(bucketName);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "testCreateBucketImpl")
|
||||
public void testPutObjectImpl() throws S3ServiceException, InterruptedException,
|
||||
ExecutionException, TimeoutException, NoSuchAlgorithmException, IOException {
|
||||
String bucketName = getBucketName();
|
||||
try {
|
||||
String objectKey = "putObject";
|
||||
|
||||
S3Object requestObject, jsResultObject;
|
||||
|
@ -390,14 +428,17 @@ public class JCloudsS3ServiceIntegrationTest extends S3IntegrationTest {
|
|||
assertTrue(jsResultObject.verifyData(data.getBytes("UTF-8")));
|
||||
assertEquals(jsResultObject.getMd5HashAsHex(), S3Utils.toHexString(jcObject.getMetadata()
|
||||
.getMd5()));
|
||||
|
||||
emptyBucket(bucketName);
|
||||
} finally {
|
||||
returnBucket(bucketName);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "testCreateBucketImpl")
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testCopyObjectImpl() throws InterruptedException, ExecutionException,
|
||||
TimeoutException, IOException, S3ServiceException {
|
||||
String bucketName = getBucketName();
|
||||
try {
|
||||
String data = "This is my data";
|
||||
String sourceObjectKey = "šriginalObject"; // Notice the use of non-ASCII
|
||||
String destinationObjectKey = "dŽstinationObject"; // characters here.
|
||||
|
@ -449,8 +490,9 @@ public class JCloudsS3ServiceIntegrationTest extends S3IntegrationTest {
|
|||
jcDestinationObject = client.getObject(bucketName, destinationObject.getKey()).get(10,
|
||||
TimeUnit.SECONDS);
|
||||
// TODO: Test destination ACL is changed (ie public-read)
|
||||
|
||||
emptyBucket(bucketName);
|
||||
} finally {
|
||||
returnBucket(bucketName);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(enabled = false)
|
||||
|
|
Loading…
Reference in New Issue