greyp9 commented on pull request #5788:
URL: https://github.com/apache/nifi/pull/5788#issuecomment-1048317969


   > This looks to address the issue surfaced in NIFI-9577. What do you think 
of a unit test that verifies the dynamic behavior of the input directory 
property?
   
   A quick and dirty completion of this thought...
   
   ```
       @Test
       public void testExpressionLanguageOnProperty() throws IOException, 
InterruptedException {
           final Calendar calendar = Calendar.getInstance();
           final int seconds = calendar.get(Calendar.SECOND);
           final int seconds1 = seconds + 1;
           final int seconds2 = seconds + 2;
           final int millis = calendar.get(Calendar.MILLISECOND);
           final File folder1 = new File(TESTDIR, String.format("%02d", 
seconds1));
           assertTrue(folder1.mkdirs() || folder1.exists());
           final File folder2 = new File(TESTDIR, String.format("%02d", 
seconds2));
           assertTrue(folder2.mkdirs() || folder2.exists());
           // create one new file in folder "n + 1"
           final File file1 = new File(folder1, "1.txt");
           // create two new files in folder "n + 2"
           final File file2 = new File(folder2, "2.txt");
           final File file2A = new File(folder2, "2A.txt");
           for (final File file : Arrays.asList(file1, file2, file2A)) {
               assertTrue(file.createNewFile() || file.exists());
           }
           runner.setProperty(ListFile.DIRECTORY, TESTDIR + 
"/${now():format('ss')}");
           // wait until second "n + 1", then test
           Thread.sleep((1000 - millis) + 10);
           runner.run();
           runner.assertAllFlowFilesTransferred(ListFile.REL_SUCCESS, 1);
           runner.clearTransferState();
   
           // wait until second "n + 2", then test
           Thread.sleep(1000);
           runner.run();
           runner.assertAllFlowFilesTransferred(ListFile.REL_SUCCESS, 2);
       }
   ```


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to