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