public void testDeleteMultipleObjects() throws InterruptedException { String container = getContainerName(); try { ImmutableSet.Builder<String> builder = ImmutableSet.builder(); for (int i = 0; i < 5; i++) { String key = UUID.randomUUID().toString(); Blob blob = view.getBlobStore().blobBuilder(key).payload("").build(); view.getBlobStore().putBlob(container, blob); builder.add(key); } Set<String> keys = builder.build(); DeleteResult result = getApi().deleteObjects(container, keys); assertTrue(result.getDeleted().containsAll(keys)); assertEquals(result.getErrors().size(), 0); for (String key : keys) { assertConsistencyAwareBlobDoesntExist(container, key); } } finally { returnContainer(container); } }
@BeforeClass(groups = { "integration", "live" }) @Override public void setUpResourcesOnThisThread(ITestContext testContext) throws Exception { super.setUpResourcesOnThisThread(testContext); oneHundredOneConstitutions = getTestDataSupplier(); oneHundredOneConstitutionsMD5 = asByteSource(oneHundredOneConstitutions.getInput()).hash(md5()).asBytes(); }
public void testDirectoryEndingWithSlash() throws InterruptedException { String containerName = getContainerName(); try { BlobStore blobStore = view.getBlobStore(); blobStore.createDirectory(containerName, "someDir"); // According to the S3 documentation, a directory is nothing but a blob // whose name ends with a '/'. So let's try to remove the blob we just // created. blobStore.removeBlob(containerName, "someDir/"); // The directory "someDir" shouldn't exist since we removed it. If this // test succeeds, it confirms that a directory (or folder) is nothing // but a blob with a name ending in '/'. assertEquals(blobStore.directoryExists(containerName, "someDir"), false); } finally { returnContainer(containerName); } } }
public void testMultipartSynchronously() throws InterruptedException, IOException { String containerName = getContainerName(); S3Object object = null; try { String key = "constitution.txt"; String uploadId = getApi().initiateMultipartUpload(containerName, ObjectMetadataBuilder.create().key(key).contentMD5(oneHundredOneConstitutionsMD5).build()); byte[] buffer = toByteArray(oneHundredOneConstitutions); eTagOf1 = getApi().uploadPart(containerName, key, 1, uploadId, part1); } catch (KeyNotFoundException e) { eTagOf1 = getApi().uploadPart(containerName, key, 1, uploadId, part1); String eTag = getApi().completeMultipartUpload(containerName, key, uploadId, ImmutableMap.of(1, eTagOf1)); object = getApi().getObject(containerName, key); assertEquals(toByteArray(object.getPayload()), buffer); assertEquals(getApi().headObject(containerName, key).getContentMetadata().getContentMD5(), null); returnContainer(containerName);
String containerName = getScratchContainerName() + "eu"; try { BlobStore blobStore = view.getBlobStore(); destroyContainer(containerName);
public void testDirectoryEndingWithSlash() throws InterruptedException { String containerName = getContainerName(); try { BlobStore blobStore = view.getBlobStore(); blobStore.createDirectory(containerName, "someDir"); // According to the S3 documentation, a directory is nothing but a blob // whose name ends with a '/'. So let's try to remove the blob we just // created. blobStore.removeBlob(containerName, "someDir/"); // The directory "someDir" shouldn't exist since we removed it. If this // test succeeds, it confirms that a directory (or folder) is nothing // but a blob with a name ending in '/'. assertEquals(blobStore.directoryExists(containerName, "someDir"), false); } finally { returnContainer(containerName); } }
public void testPutWithStorageClass() throws Exception { String containerName = getContainerName(); AWSS3Client s3Client = getApi(); try { 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); S3Object object = s3Client.newS3Object(); object.getMetadata().setKey(blobName); object.setPayload("something"); s3Client.putObject(containerName, object, storageClass(storageClass)); ListBucketResponse response = s3Client.listBucket(containerName, withPrefix(blobName)); ObjectMetadata metadata = response.iterator().next(); assertThat(metadata.getStorageClass()).isEqualTo(storageClass); } } finally { returnContainer(containerName); } }
public void testMultipartAsynchronouslySmallBlob() throws IOException, InterruptedException, Exception { String containerName = getContainerName(); try { AsyncBlobStore asyncBlobStore = view.getAsyncBlobStore(); asyncBlobStore.createContainerInLocation(null, containerName).get(); Blob blob = asyncBlobStore.blobBuilder("small").payload("small").build(); asyncBlobStore.putBlob(containerName, blob, PutOptions.Builder.multipart()).get(); } finally { returnContainer(containerName); } }
public void testMultipartChunkedFileStream() throws IOException, InterruptedException { File file = new File("target/const.txt"); Files.copy(oneHundredOneConstitutions, file); String containerName = getContainerName(); try { BlobStore blobStore = view.getBlobStore(); blobStore.createContainerInLocation(null, containerName); Blob blob = blobStore.blobBuilder("const.txt").payload(file).build(); blobStore.putBlob(containerName, blob, PutOptions.Builder.multipart()); } finally { returnContainer(containerName); } }
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); } }