Allow custom restart pollInterval and quietPeriod
Allow the pollInterval and the quietPeriod of the filewatcher to be configured. Fixes gh-3139
This commit is contained in:
@@ -64,6 +64,27 @@ public class FileSystemWatcherTests {
|
||||
setupWatcher(20, 10);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pollIntervalMustBePositive() throws Exception {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("PollInterval must be positive");
|
||||
new FileSystemWatcher(true, 0, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void quietPeriodMustBePositive() throws Exception {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("QuietPeriod must be positive");
|
||||
new FileSystemWatcher(true, 1, 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pollIntervalMustBeGreaterThanQuietPeriod() throws Exception {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("PollInterval must be greater than QuietPeriod");
|
||||
new FileSystemWatcher(true, 1, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void listenerMustNotBeNull() throws Exception {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
@@ -117,7 +138,7 @@ public class FileSystemWatcherTests {
|
||||
@Test
|
||||
public void waitsForIdleTime() throws Exception {
|
||||
this.changes.clear();
|
||||
setupWatcher(100, 0);
|
||||
setupWatcher(100, 1);
|
||||
File folder = startWithNewFolder();
|
||||
touch(new File(folder, "test1.txt"));
|
||||
Thread.sleep(200);
|
||||
|
||||
Reference in New Issue
Block a user