mirror of
https://github.com/apache/nifi.git
synced 2025-02-07 02:28:31 +00:00
NIFI-12019 Improved reliability of TestSynchronousFileWatcher
This closes #7770 Signed-off-by: David Handermann <exceptionfactory@apache.org> (cherry picked from commit 1f87c16ab8473e98df5c31a4932c0ff92c7d031a)
This commit is contained in:
parent
990d0807c9
commit
9b7dadb214
@ -37,9 +37,8 @@ public class TestSynchronousFileWatcher {
|
|||||||
Files.copy(new ByteArrayInputStream("Hello, World!".getBytes("UTF-8")), path, StandardCopyOption.REPLACE_EXISTING);
|
Files.copy(new ByteArrayInputStream("Hello, World!".getBytes("UTF-8")), path, StandardCopyOption.REPLACE_EXISTING);
|
||||||
final UpdateMonitor monitor = new DigestUpdateMonitor();
|
final UpdateMonitor monitor = new DigestUpdateMonitor();
|
||||||
|
|
||||||
final SynchronousFileWatcher watcher = new SynchronousFileWatcher(path, monitor, 40L);
|
final SynchronousFileWatcher watcher = new SynchronousFileWatcher(path, monitor, 0L);
|
||||||
assertFalse(watcher.checkAndReset());
|
assertFalse(watcher.checkAndReset());
|
||||||
Thread.sleep(41L);
|
|
||||||
assertFalse(watcher.checkAndReset());
|
assertFalse(watcher.checkAndReset());
|
||||||
|
|
||||||
try (FileOutputStream fos = new FileOutputStream(path.toFile())) {
|
try (FileOutputStream fos = new FileOutputStream(path.toFile())) {
|
||||||
@ -47,11 +46,7 @@ public class TestSynchronousFileWatcher {
|
|||||||
fos.getFD().sync();
|
fos.getFD().sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
// immediately after file changes, but before the next check time is reached, answer should be false
|
// file has changed, answer should be true once
|
||||||
assertFalse(watcher.checkAndReset());
|
|
||||||
|
|
||||||
// after check time has passed, answer should be true
|
|
||||||
Thread.sleep(41L);
|
|
||||||
assertTrue(watcher.checkAndReset());
|
assertTrue(watcher.checkAndReset());
|
||||||
assertFalse(watcher.checkAndReset());
|
assertFalse(watcher.checkAndReset());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user