Github user patricker commented on a diff in the pull request: https://github.com/apache/nifi/pull/3033#discussion_r224948420 --- Diff: nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestGetFile.java --- @@ -151,6 +151,90 @@ public void testFilePickedUp() throws IOException { assertEquals(absTargetPathStr, absolutePath); } + @Test + public void testFilePickedUpArrivalSinceListing() throws IOException { + final File directory = new File("target/test/data/in"); + deleteDirectory(directory); + assertTrue("Unable to create test data directory " + directory.getAbsolutePath(), directory.exists() || directory.mkdirs()); + + final TestRunner runner = TestRunners.newTestRunner(new GetFile()); + runner.setProperty(GetFile.DIRECTORY, directory.getAbsolutePath()); + runner.setProperty(GetFile.KEEP_SOURCE_FILE, "false"); + + final File inFile = new File("src/test/resources/hello.txt"); + { + final Path inPath = inFile.toPath(); + final File destFile = new File(directory, inFile.getName()); + final Path targetPath = destFile.toPath(); + Files.copy(inPath, targetPath); + } + { + final Path inPath = inFile.toPath(); + final File destFile = new File(directory, inFile.getName() + "1"); + final Path targetPath = destFile.toPath(); + Files.copy(inPath, targetPath); + + runner.run(1); + } + final Path inPath = inFile.toPath(); + final File destFile = new File(directory, inFile.getName() + "2"); + final Path targetPath = destFile.toPath(); + final Path absTargetPath = targetPath.toAbsolutePath(); + final String absTargetPathStr = absTargetPath.getParent() + "/"; + Files.copy(inPath, targetPath); + + runner.run(1); + runner.run(1); + + runner.assertAllFlowFilesTransferred(GetFile.REL_SUCCESS, 3); + final List<MockFlowFile> successFiles = runner.getFlowFilesForRelationship(GetFile.REL_SUCCESS); + successFiles.get(0).assertContentEquals("Hello, World!".getBytes("UTF-8")); + successFiles.get(1).assertContentEquals("Hello, World!".getBytes("UTF-8")); + successFiles.get(2).assertContentEquals("Hello, World!".getBytes("UTF-8")); + + final String path = successFiles.get(2).getAttribute("path"); + assertEquals("/", path); + final String absolutePath = successFiles.get(2).getAttribute(CoreAttributes.ABSOLUTE_PATH.key()); + assertEquals(absTargetPathStr, absolutePath); + } + + @Test --- End diff -- On further testing of this test case, weird results. Does this test work for you? I get a mix of Actual counts. I ran this test on the full code and get Actual 9996. I took out the limit, and got an actual of 9999. Not really sure what's going on.
---