mirror of https://github.com/apache/nifi.git
NIFI-12019 Improved reliability of TestSynchronousFileWatcher
This closes #7770 Signed-off-by: David Handermann <exceptionfactory@apache.org>
This commit is contained in:
parent
9b591a2fe3
commit
1f87c16ab8
|
@ -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…
Reference in New Issue