Esempio n. 1
0
  public void testPutWithReducedRedundancyStorage() throws InterruptedException {
    String containerName = getContainerName();
    try {
      String blobName = "test-rrs";
      BlobStore blobStore = view.getBlobStore();
      blobStore.createContainerInLocation(null, containerName);

      Blob blob = blobStore.blobBuilder(blobName).payload("something").build();
      blobStore.putBlob(containerName, blob, storageClass(StorageClass.REDUCED_REDUNDANCY));

      S3Client s3Client = S3Client.class.cast(view.unwrap(AWSS3ApiMetadata.CONTEXT_TOKEN).getApi());
      ListBucketResponse response = s3Client.listBucket(containerName, withPrefix(blobName));

      ObjectMetadata metadata = response.iterator().next();
      assertEquals(metadata.getStorageClass(), StorageClass.REDUCED_REDUNDANCY);

    } finally {
      returnContainer(containerName);
    }
  }
Esempio n. 2
0
  /**
   * Tests {@link S3#listBucket(S3Client, String, ListBucketOptions)} where retrieving all results
   * requires multiple requests.
   *
   * @throws Exception if anything goes wrong
   */
  @Test
  public void testMultiPageResult() throws Exception {
    String nextMarker = "FOO";
    S3Client api = createMock(S3Client.class);
    ListBucketOptions options = new ListBucketOptions();
    ListBucketResponse response2 = new ListBucketHandlerTest().expected();
    ListBucketResponse response1 =
        new ListBucketResponseImpl(
            response2.getName(),
            response2,
            response2.getPrefix(),
            null,
            nextMarker,
            response2.getMaxKeys(),
            response2.getDelimiter(),
            false,
            response2.getCommonPrefixes());

    expect(api.listBucket("bucket", options)).andReturn(response1).once();
    expect(api.listBucket("bucket", options.afterMarker(nextMarker))).andReturn(response2).once();

    EasyMock.replay(api);

    PagedIterable<ObjectMetadata> result = S3.listBucket(api, "bucket", options);

    // number of objects
    assertEquals(result.concat().size(), 20);
  }