Java Code Examples for com.amazonaws.services.s3.model.StorageClass#values()

The following examples show how to use com.amazonaws.services.s3.model.StorageClass#values() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestPutS3Object.java    From nifi with Apache License 2.0 6 votes vote down vote up
@Test
public void testStorageClasses() {
    for (StorageClass storageClass : StorageClass.values()) {
        runner.setProperty(PutS3Object.STORAGE_CLASS, storageClass.name());
        prepareTest();

        runner.run(1);

        ArgumentCaptor<PutObjectRequest> captureRequest = ArgumentCaptor.forClass(PutObjectRequest.class);
        Mockito.verify(mockS3Client, Mockito.times(1)).putObject(captureRequest.capture());
        PutObjectRequest request = captureRequest.getValue();

        assertEquals(storageClass.toString(), request.getStorageClass());

        Mockito.reset(mockS3Client);
    }
}
 
Example 2
Source File: ITPutS3Object.java    From nifi with Apache License 2.0 6 votes vote down vote up
@Test
public void testStorageClasses() throws IOException {
    final TestRunner runner = TestRunners.newTestRunner(new PutS3Object());

    runner.setProperty(PutS3Object.CREDENTIALS_FILE, CREDENTIALS_FILE);
    runner.setProperty(PutS3Object.REGION, REGION);
    runner.setProperty(PutS3Object.BUCKET, BUCKET_NAME);

    Assert.assertTrue(runner.setProperty("x-custom-prop", "hello").isValid());

    for (StorageClass storageClass : StorageClass.values()) {
        runner.setProperty(PutS3Object.STORAGE_CLASS, storageClass.name());

        final Map<String, String> attrs = new HashMap<>();
        attrs.put("filename", "testStorageClasses/small_" + storageClass.name() + ".txt");
        runner.enqueue(getResourcePath(SAMPLE_FILE_RESOURCE_NAME), attrs);

        runner.run();

        runner.assertAllFlowFilesTransferred(PutS3Object.REL_SUCCESS, 1);
        FlowFile file = runner.getFlowFilesForRelationship(PutS3Object.REL_SUCCESS).get(0);
        Assert.assertEquals(storageClass.toString(), file.getAttribute(PutS3Object.S3_STORAGECLASS_ATTR_KEY));

        runner.clearTransferState();
    }
}
 
Example 3
Source File: ITPutS3Object.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Test
public void testStorageClassesMultipart() throws IOException {
    final TestRunner runner = TestRunners.newTestRunner(new PutS3Object());

    runner.setProperty(PutS3Object.CREDENTIALS_FILE, CREDENTIALS_FILE);
    runner.setProperty(PutS3Object.REGION, REGION);
    runner.setProperty(PutS3Object.BUCKET, BUCKET_NAME);
    runner.setProperty(PutS3Object.MULTIPART_THRESHOLD, "50 MB");
    runner.setProperty(PutS3Object.MULTIPART_PART_SIZE, "50 MB");

    Assert.assertTrue(runner.setProperty("x-custom-prop", "hello").isValid());

    for (StorageClass storageClass : StorageClass.values()) {
        runner.setProperty(PutS3Object.STORAGE_CLASS, storageClass.name());

        final Map<String, String> attrs = new HashMap<>();
        attrs.put("filename", "testStorageClasses/large_" + storageClass.name() + ".dat");
        runner.enqueue(new byte[50 * 1024 * 1024 + 1], attrs);

        runner.run();

        runner.assertAllFlowFilesTransferred(PutS3Object.REL_SUCCESS, 1);
        FlowFile file = runner.getFlowFilesForRelationship(PutS3Object.REL_SUCCESS).get(0);
        Assert.assertEquals(storageClass.toString(), file.getAttribute(PutS3Object.S3_STORAGECLASS_ATTR_KEY));

        runner.clearTransferState();
    }
}
 
Example 4
Source File: AmazonS3FileSystem.java    From iaf with Apache License 2.0 5 votes vote down vote up
public static List<String> getStorageClasses() {
	List<String> storageClasses = new ArrayList<String>(StorageClass.values().length);
	for (StorageClass storageClass : StorageClass.values())
		storageClasses.add(storageClass.toString());

	return storageClasses;
}