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:
Phillip Webb
2015-06-08 22:51:50 -07:00
parent 7bcd6567ba
commit d0349879c3
7 changed files with 84 additions and 19 deletions

View File

@@ -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);