tlsmith109 commented on a change in pull request #4620:
URL: https://github.com/apache/nifi/pull/4620#discussion_r539617748
##########
File path:
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestFTP.java
##########
@@ -144,6 +146,61 @@ public void basicFileUpload() throws IOException {
// Check file was uploaded
Assert.assertTrue(results.exists("c:\\data\\randombytes-1"));
}
+ @Test
+ public void basicProvenanceEventTest() throws IOException {
+ TestRunner runner = TestRunners.newTestRunner(PutFTP.class);
+ runner.setValidateExpressionUsage(false);
+
+ runner.setProperty(FTPTransfer.HOSTNAME, "localhost");
+ runner.setProperty(FTPTransfer.USERNAME, username);
+ runner.setProperty(FTPTransfer.PASSWORD, password);
+ runner.setProperty(FTPTransfer.PORT, Integer.toString(ftpPort));
+
+ // Get two flowfiles to test by running data
+ try (FileInputStream fis = new
FileInputStream("src/test/resources/randombytes-1")) {
+ Map<String, String> attributes = new HashMap<String, String>();
+ attributes.put(CoreAttributes.FILENAME.key(), "randombytes-1");
+ attributes.put("transfer-host", "localhost");
+ runner.enqueue(fis, attributes);
+ runner.run();
+ }
+ try (FileInputStream fis = new
FileInputStream("src/test/resources/hello.txt")) {
+ Map<String, String> attributes = new HashMap<String, String>();
+ attributes.put(CoreAttributes.FILENAME.key(), "hello.txt");
+
+ attributes.put("transfer-host", "127.0.0.1");
+ runner.enqueue(fis, attributes);
+ runner.run();
+ }
+ runner.assertQueueEmpty();
+ runner.assertTransferCount(PutFTP.REL_SUCCESS, 2);
+
+ MockFlowFile flowFile1 =
runner.getFlowFilesForRelationship(PutFileTransfer.REL_SUCCESS).get(0);
+
+ MockFlowFile flowFile2 =
runner.getFlowFilesForRelationship(PutFileTransfer.REL_SUCCESS).get(1);
+
+ runner.clearProvenanceEvents();
+ runner.clearTransferState();
+ HashMap<String, String> map1 = new HashMap<>();
+ HashMap<String, String> map2 = new HashMap<>();
+ map1.put(CoreAttributes.FILENAME.key(), "randombytes-xx");
+ map2.put(CoreAttributes.FILENAME.key(), "randombytes-yy");
+
+ flowFile1.putAttributes(map1);
+ flowFile2.putAttributes(map2);
+ //set to derive hostname
+ runner.setProperty(FTPTransfer.HOSTNAME, "${transfer-host}");
+
+ runner.enqueue(flowFile1);
+ runner.run();
Review comment:
Required to ensure order of provenance events.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]