Repository: jclouds
Updated Branches:
  refs/heads/2.1.x c2b76d1d4 -> dd4de2d0b


JCLOUDS-1399: Support S3 One Zone-IA storage class

Also improve test coverage of storage classes.


Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/dd4de2d0
Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/dd4de2d0
Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/dd4de2d0

Branch: refs/heads/2.1.x
Commit: dd4de2d0b802f1fae60e9cebd75d3d8a51a87f2b
Parents: c2b76d1
Author: Andrew Gaul <g...@apache.org>
Authored: Wed Apr 4 21:05:46 2018 -0700
Committer: Andrew Gaul <g...@apache.org>
Committed: Fri Apr 6 00:12:34 2018 -0700

----------------------------------------------------------------------
 .../org/jclouds/s3/domain/ObjectMetadata.java   |  1 +
 .../org/jclouds/aws/s3/AWSS3ClientLiveTest.java | 35 ++++++++++++--------
 2 files changed, 23 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds/blob/dd4de2d0/apis/s3/src/main/java/org/jclouds/s3/domain/ObjectMetadata.java
----------------------------------------------------------------------
diff --git a/apis/s3/src/main/java/org/jclouds/s3/domain/ObjectMetadata.java 
b/apis/s3/src/main/java/org/jclouds/s3/domain/ObjectMetadata.java
index c439a35..0c5b5f4 100644
--- a/apis/s3/src/main/java/org/jclouds/s3/domain/ObjectMetadata.java
+++ b/apis/s3/src/main/java/org/jclouds/s3/domain/ObjectMetadata.java
@@ -36,6 +36,7 @@ public interface ObjectMetadata extends 
Comparable<ObjectMetadata> {
    public enum StorageClass {
       STANDARD(Tier.STANDARD),
       STANDARD_IA(Tier.INFREQUENT),
+      ONEZONE_IA(Tier.INFREQUENT),
       REDUCED_REDUNDANCY(Tier.STANDARD),
       GLACIER(Tier.ARCHIVE);
 

http://git-wip-us.apache.org/repos/asf/jclouds/blob/dd4de2d0/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3ClientLiveTest.java
----------------------------------------------------------------------
diff --git 
a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3ClientLiveTest.java 
b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3ClientLiveTest.java
index 2e57042..a5d3752 100644
--- a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3ClientLiveTest.java
+++ b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3ClientLiveTest.java
@@ -16,7 +16,8 @@
  */
 package org.jclouds.aws.s3;
 
-import static 
org.jclouds.aws.s3.blobstore.options.AWSS3PutOptions.Builder.storageClass;
+import static org.assertj.core.api.Assertions.assertThat;
+import static 
org.jclouds.aws.s3.blobstore.options.AWSS3PutObjectOptions.Builder.storageClass;
 import static org.jclouds.s3.options.ListBucketOptions.Builder.withPrefix;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertNotNull;
@@ -33,11 +34,11 @@ import org.jclouds.http.HttpRequest;
 import org.jclouds.http.HttpResponse;
 import org.jclouds.location.predicates.LocationPredicates;
 import org.jclouds.rest.HttpClient;
-import org.jclouds.s3.S3Client;
 import org.jclouds.s3.S3ClientLiveTest;
 import org.jclouds.s3.domain.ListBucketResponse;
 import org.jclouds.s3.domain.ObjectMetadata;
 import org.jclouds.s3.domain.ObjectMetadata.StorageClass;
+import org.jclouds.s3.domain.S3Object;
 import org.testng.ITestContext;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
@@ -64,22 +65,30 @@ public class AWSS3ClientLiveTest extends S3ClientLiveTest {
       super.setUpResourcesOnThisThread(testContext);
    }
 
-   public void testPutWithReducedRedundancyStorage() throws 
InterruptedException {
+   public void testPutWithStorageClass() throws Exception {
       String containerName = getContainerName();
+      AWSS3Client s3Client = getApi();
       try {
-         String blobName = "test-rrs";
-         BlobStore blobStore = view.getBlobStore();
-         blobStore.createContainerInLocation(null, containerName);
+         for (StorageClass storageClass : StorageClass.values()) {
+            if (storageClass == StorageClass.GLACIER) {
+               // AWS does not allow creation of Glacier objects
+               continue;
+            }
+
+            String blobName = "test-" + storageClass;
+            BlobStore blobStore = view.getBlobStore();
+            blobStore.createContainerInLocation(null, containerName);
 
-         Blob blob = 
blobStore.blobBuilder(blobName).payload("something").build();
-         blobStore.putBlob(containerName, blob,
-            storageClass(StorageClass.REDUCED_REDUNDANCY));
+            S3Object object = s3Client.newS3Object();
+            object.getMetadata().setKey(blobName);
+            object.setPayload("something");
+            s3Client.putObject(containerName, object, 
storageClass(storageClass));
 
-         S3Client s3Client = view.unwrapApi(S3Client.class);
-         ListBucketResponse response = s3Client.listBucket(containerName, 
withPrefix(blobName));
+            ListBucketResponse response = s3Client.listBucket(containerName, 
withPrefix(blobName));
 
-         ObjectMetadata metadata = response.iterator().next();
-         assertEquals(metadata.getStorageClass(), 
StorageClass.REDUCED_REDUNDANCY);
+            ObjectMetadata metadata = response.iterator().next();
+            assertThat(metadata.getStorageClass()).isEqualTo(storageClass);
+         }
 
       } finally {
          returnContainer(containerName);

Reply via email to