Repository: nifi Updated Branches: refs/heads/0.x a42fa991e -> e152dce07
NIFI-1180 Adding more IT tests. This closes #336. Signed-off-by: Andy LoPresto <alopre...@apache.org> Project: http://git-wip-us.apache.org/repos/asf/nifi/repo Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/e152dce0 Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/e152dce0 Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/e152dce0 Branch: refs/heads/0.x Commit: e152dce07329576dbd894df938149a4a610082c3 Parents: a42fa99 Author: ijokarumawak <ijokaruma...@gmail.com> Authored: Fri Apr 8 17:20:27 2016 +0900 Committer: Andy LoPresto <alopre...@apache.org> Committed: Tue Apr 12 17:45:23 2016 -0700 ---------------------------------------------------------------------- .../nifi/processors/aws/s3/ITFetchS3Object.java | 8 ++- .../nifi/processors/aws/s3/ITPutS3Object.java | 61 ++++++++++++++++++++ 2 files changed, 68 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/nifi/blob/e152dce0/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/s3/ITFetchS3Object.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/s3/ITFetchS3Object.java b/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/s3/ITFetchS3Object.java index db115bb..b318924 100644 --- a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/s3/ITFetchS3Object.java +++ b/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/s3/ITFetchS3Object.java @@ -55,6 +55,10 @@ public class ITFetchS3Object extends AbstractS3IT { runner.run(1); runner.assertAllFlowFilesTransferred(FetchS3Object.REL_SUCCESS, 1); + final List<MockFlowFile> ffs = runner.getFlowFilesForRelationship(FetchS3Object.REL_SUCCESS); + MockFlowFile ff = ffs.get(0); + ff.assertAttributeNotExists(PutS3Object.S3_SSE_ALGORITHM); + ff.assertContentEquals(getFileFromResourceName(SAMPLE_FILE_RESOURCE_NAME)); } @Test @@ -75,7 +79,9 @@ public class ITFetchS3Object extends AbstractS3IT { runner.assertAllFlowFilesTransferred(FetchS3Object.REL_SUCCESS, 1); final List<MockFlowFile> ffs = runner.getFlowFilesForRelationship(FetchS3Object.REL_SUCCESS); - ffs.get(0).assertAttributeEquals(PutS3Object.S3_SSE_ALGORITHM, ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION); + MockFlowFile ff = ffs.get(0); + ff.assertAttributeEquals(PutS3Object.S3_SSE_ALGORITHM, ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION); + ff.assertContentEquals(getFileFromResourceName(SAMPLE_FILE_RESOURCE_NAME)); } @Test http://git-wip-us.apache.org/repos/asf/nifi/blob/e152dce0/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/s3/ITPutS3Object.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/s3/ITPutS3Object.java b/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/s3/ITPutS3Object.java index 5d7797e..2db6c74 100644 --- a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/s3/ITPutS3Object.java +++ b/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/s3/ITPutS3Object.java @@ -119,6 +119,67 @@ public class ITPutS3Object extends AbstractS3IT { } } + private void testPutThenFetch(String sseAlgorithm) throws IOException { + + // Put + TestRunner runner = TestRunners.newTestRunner(new PutS3Object()); + + runner.setProperty(PutS3Object.CREDENTIALS_FILE, CREDENTIALS_FILE); + runner.setProperty(PutS3Object.REGION, REGION); + runner.setProperty(PutS3Object.BUCKET, BUCKET_NAME); + if(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION.equals(sseAlgorithm)){ + runner.setProperty(PutS3Object.SERVER_SIDE_ENCRYPTION, sseAlgorithm); + } + + final Map<String, String> attrs = new HashMap<>(); + attrs.put("filename", "filename-on-s3.txt"); + runner.enqueue(getResourcePath(SAMPLE_FILE_RESOURCE_NAME), attrs); + runner.run(); + + runner.assertAllFlowFilesTransferred(PutS3Object.REL_SUCCESS, 1); + List<MockFlowFile> ffs = runner.getFlowFilesForRelationship(PutS3Object.REL_SUCCESS); + if(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION.equals(sseAlgorithm)){ + ffs.get(0).assertAttributeEquals(PutS3Object.S3_SSE_ALGORITHM, ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION); + } else { + ffs.get(0).assertAttributeNotExists(PutS3Object.S3_SSE_ALGORITHM); + } + + // Fetch + runner = TestRunners.newTestRunner(new FetchS3Object()); + + runner.setProperty(FetchS3Object.CREDENTIALS_FILE, CREDENTIALS_FILE); + runner.setProperty(FetchS3Object.REGION, REGION); + runner.setProperty(FetchS3Object.BUCKET, BUCKET_NAME); + + runner.enqueue(new byte[0], attrs); + + runner.run(1); + + runner.assertAllFlowFilesTransferred(FetchS3Object.REL_SUCCESS, 1); + ffs = runner.getFlowFilesForRelationship(FetchS3Object.REL_SUCCESS); + MockFlowFile ff = ffs.get(0); + ff.assertContentEquals(getFileFromResourceName(SAMPLE_FILE_RESOURCE_NAME)); + + if(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION.equals(sseAlgorithm)){ + ff.assertAttributeEquals(PutS3Object.S3_SSE_ALGORITHM, ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION); + } else { + ff.assertAttributeNotExists(PutS3Object.S3_SSE_ALGORITHM); + } + + } + + + @Test + public void testPutThenFetchWithoutSSE() throws IOException { + testPutThenFetch(PutS3Object.NO_SERVER_SIDE_ENCRYPTION); + } + + @Test + public void testPutThenFetchWithSSE() throws IOException { + testPutThenFetch(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION); + } + + @Test public void testPutS3ObjectUsingCredentialsProviderService() throws Throwable { final TestRunner runner = TestRunners.newTestRunner(new PutS3Object());