Package org.jclouds.s3

Examples of org.jclouds.s3.S3ClientMockTest


      http.getPayload().getContentMetadata().setContentEncoding("encoding");
      http.getPayload().getContentMetadata().setContentType(MediaType.APPLICATION_OCTET_STREAM);

      MutableObjectMetadata response = parser.apply(http);

      MutableObjectMetadataImpl expects = new MutableObjectMetadataImpl();
      expects.setCacheControl("cacheControl");
      expects.getContentMetadata().setContentDisposition("contentDisposition");
      expects.getContentMetadata().setContentEncoding("encoding");
      expects.getContentMetadata().setContentType(MediaType.APPLICATION_OCTET_STREAM);
      expects.getContentMetadata().setContentLength(1025l);
      expects.setETag("\"abcd-1\"");
      expects.setKey("key");
      expects.setLastModified(now);
      expects.setOwner(null);
      expects.setStorageClass(StorageClass.STANDARD);
      expects.setUserMetadata(userMetadata);
      assertEquals(response, expects);
   }
View Full Code Here


      http.getPayload().getContentMetadata().setContentEncoding("encoding");
      http.getPayload().getContentMetadata().setContentType(MediaType.APPLICATION_OCTET_STREAM);

      MutableObjectMetadata response = parser.apply(http);

      MutableObjectMetadataImpl expects = new MutableObjectMetadataImpl();
      expects.setCacheControl("cacheControl");
      expects.getContentMetadata().setContentDisposition("contentDisposition");
      expects.getContentMetadata().setContentEncoding("encoding");
      expects.getContentMetadata().setContentMD5(base16().lowerCase().decode("abcd"));
      expects.getContentMetadata().setContentType(MediaType.APPLICATION_OCTET_STREAM);
      expects.getContentMetadata().setContentLength(1025l);
      expects.setETag("\"abcd\"");
      expects.setKey("key");
      expects.setLastModified(now);
      expects.setOwner(null);
      expects.setStorageClass(StorageClass.STANDARD);
      expects.setUserMetadata(userMetadata);

      assertEquals(response, expects);
   }
View Full Code Here

      return transform(blobStore.list(name, options), resource2BucketList, userExecutor);
   }

   public ListenableFuture<ObjectMetadata> copyObject(final String sourceBucket, final String sourceObject,
            final String destinationBucket, final String destinationObject, CopyObjectOptions... nullableOptions) {
      final CopyObjectOptions options = (nullableOptions.length == 0) ? new CopyObjectOptions() : nullableOptions[0];
      ConcurrentMap<String, Blob> source = containerToBlobs.get(sourceBucket);
      ConcurrentMap<String, Blob> dest = containerToBlobs.get(destinationBucket);
      if (source.containsKey(sourceObject)) {
         Blob object = source.get(sourceObject);
         if (options.getIfMatch() != null) {
            if (!object.getMetadata().getETag().equals(options.getIfMatch()))
               return immediateFailedFuture(LocalAsyncBlobStore.returnResponseException(412));
         }
         if (options.getIfNoneMatch() != null) {
            if (object.getMetadata().getETag().equals(options.getIfNoneMatch()))
               return immediateFailedFuture(LocalAsyncBlobStore.returnResponseException(412));
         }
         if (options.getIfModifiedSince() != null) {
            Date modifiedSince = dateService.rfc822DateParse(options.getIfModifiedSince());
            if (modifiedSince.after(object.getMetadata().getLastModified()))
               return immediateFailedFuture(LocalAsyncBlobStore.returnResponseException(412));

         }
         if (options.getIfUnmodifiedSince() != null) {
            Date unmodifiedSince = dateService.rfc822DateParse(options.getIfUnmodifiedSince());
            if (unmodifiedSince.before(object.getMetadata().getLastModified()))
               return immediateFailedFuture(LocalAsyncBlobStore.returnResponseException(412));
         }
         Blob sourceS3 = source.get(sourceObject);
         MutableBlobMetadata newMd = BlobStoreUtils.copy(sourceS3.getMetadata(), destinationObject);
         if (options.getAcl() != null)
            keyToAcl.put(destinationBucket + "/" + destinationObject, options.getAcl());

         newMd.setLastModified(new Date());
         Blob newBlob = blobProvider.create(newMd);
         newBlob.setPayload(sourceS3.getPayload());
         dest.put(destinationObject, newBlob);
View Full Code Here

      return transform(blobStore.list(name, options), resource2BucketList, userExecutor);
   }

   public ListenableFuture<ObjectMetadata> copyObject(final String sourceBucket, final String sourceObject,
            final String destinationBucket, final String destinationObject, CopyObjectOptions... nullableOptions) {
      final CopyObjectOptions options = (nullableOptions.length == 0) ? new CopyObjectOptions() : nullableOptions[0];
      ConcurrentMap<String, Blob> source = containerToBlobs.get(sourceBucket);
      ConcurrentMap<String, Blob> dest = containerToBlobs.get(destinationBucket);
      if (source.containsKey(sourceObject)) {
         Blob object = source.get(sourceObject);
         if (options.getIfMatch() != null) {
            if (!object.getMetadata().getETag().equals(options.getIfMatch()))
               return immediateFailedFuture(LocalAsyncBlobStore.returnResponseException(412));
         }
         if (options.getIfNoneMatch() != null) {
            if (object.getMetadata().getETag().equals(options.getIfNoneMatch()))
               return immediateFailedFuture(LocalAsyncBlobStore.returnResponseException(412));
         }
         if (options.getIfModifiedSince() != null) {
            Date modifiedSince = dateService.rfc822DateParse(options.getIfModifiedSince());
            if (modifiedSince.after(object.getMetadata().getLastModified()))
               return immediateFailedFuture(LocalAsyncBlobStore.returnResponseException(412));

         }
         if (options.getIfUnmodifiedSince() != null) {
            Date unmodifiedSince = dateService.rfc822DateParse(options.getIfUnmodifiedSince());
            if (unmodifiedSince.before(object.getMetadata().getLastModified()))
               return immediateFailedFuture(LocalAsyncBlobStore.returnResponseException(412));
         }
         Blob sourceS3 = source.get(sourceObject);
         MutableBlobMetadata newMd = BlobStoreUtils.copy(sourceS3.getMetadata(), destinationObject);
         if (options.getAcl() != null)
            keyToAcl.put(destinationBucket + "/" + destinationObject, options.getAcl());

         newMd.setLastModified(new Date());
         Blob newBlob = blobProvider.create(newMd);
         newBlob.setPayload(sourceS3.getPayload());
         dest.put(destinationObject, newBlob);
View Full Code Here

   @Override
   public ListenableFuture<Boolean> putBucketInRegion(@Nullable String region, String name,
            PutBucketOptions... optionsList) {
      region = region == null ? Region.US_STANDARD : region;
      final PutBucketOptions options = (optionsList.length == 0) ? new PutBucketOptions() : optionsList[0];
      keyToAcl.put(name, options.getAcl());
      return blobStore.createContainerInLocation(new LocationBuilder().scope(LocationScope.REGION).id(region)
               .description(region).build(), name);
   }
View Full Code Here

   @Override
   public ListenableFuture<Boolean> putBucketInRegion(@Nullable String region, String name,
            PutBucketOptions... optionsList) {
      region = region == null ? Region.US_STANDARD : region;
      final PutBucketOptions options = (optionsList.length == 0) ? new PutBucketOptions() : optionsList[0];
      keyToAcl.put(name, options.getAcl());
      return blobStore.createContainerInLocation(new LocationBuilder().scope(LocationScope.REGION).id(region)
               .description(region).build(), name);
   }
View Full Code Here

               + sourceObject));
   }

   public ListenableFuture<String> putObject(final String bucketName, final S3Object object,
            PutObjectOptions... nullableOptions) {
      final PutObjectOptions options = (nullableOptions.length == 0) ? new PutObjectOptions() : nullableOptions[0];
      if (options.getAcl() != null)
         keyToAcl.put(bucketName + "/" + object.getMetadata().getKey(), options.getAcl());
      return blobStore.putBlob(bucketName, object2Blob.apply(object));
   }
View Full Code Here

         object.getMetadata().setKey(publicReadWriteObjectKey);
         object.setPayload("");
         // Public Read-Write object
         getApi()
                  .putObject(containerName, object,
                           new PutObjectOptions().withAcl(CannedAccessPolicy.PUBLIC_READ_WRITE));

         assertConsistencyAware(new Runnable() {
            public void run() {
               try {
                  AccessControlList acl = getApi().getObjectACL(containerName, publicReadWriteObjectKey);
View Full Code Here

      final String containerName = getContainerName();
      try {
         S3Object object = getApi().newS3Object();
         object.getMetadata().setKey(publicReadObjectKey);
         object.setPayload("");
         getApi().putObject(containerName, object, new PutObjectOptions().withAcl(CannedAccessPolicy.PUBLIC_READ));

         assertConsistencyAware(new Runnable() {
            public void run() {
               try {
                  AccessControlList acl = getApi().getObjectACL(containerName, publicReadObjectKey);
View Full Code Here

               + sourceObject));
   }

   public ListenableFuture<String> putObject(final String bucketName, final S3Object object,
            PutObjectOptions... nullableOptions) {
      final PutObjectOptions options = (nullableOptions.length == 0) ? new PutObjectOptions() : nullableOptions[0];
      if (options.getAcl() != null)
         keyToAcl.put(bucketName + "/" + object.getMetadata().getKey(), options.getAcl());
      return blobStore.putBlob(bucketName, object2Blob.apply(object));
   }
View Full Code Here

TOP

Related Classes of org.jclouds.s3.S3ClientMockTest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.