3030import static engineering .swat .watch .WatchEvent .Kind .DELETED ;
3131import static engineering .swat .watch .WatchEvent .Kind .MODIFIED ;
3232import static engineering .swat .watch .WatchEvent .Kind .OVERFLOW ;
33- import static org . awaitility . Awaitility .await ;
33+ import static engineering . swat . watch . util . WaitFor .await ;
3434
3535import java .io .IOException ;
3636import java .nio .file .Files ;
4545
4646import engineering .swat .watch .WatchEvent .Kind ;
4747import engineering .swat .watch .impl .EventHandlingWatch ;
48+ import engineering .swat .watch .util .WaitFor ;
4849
4950class SingleDirectoryTests {
5051 private TestDirectory testDir ;
@@ -63,7 +64,7 @@ void cleanup() {
6364
6465 @ BeforeAll
6566 static void setupEverything () {
66- Awaitility .setDefaultTimeout (TestHelper .NORMAL_WAIT );
67+ WaitFor .setDefaultTimeout (TestHelper .NORMAL_WAIT );
6768 }
6869
6970 @ Test
@@ -85,12 +86,12 @@ void deleteOfFileInDirectoryShouldBeVisible() throws IOException {
8586 // Delete the file
8687 Files .delete (target );
8788 await ("File deletion should generate delete event" )
88- .untilTrue (seenDelete );
89+ .until (seenDelete );
8990
9091 // Re-create it again
9192 Files .writeString (target , "Hello World" );
9293 await ("File creation should generate create event" )
93- .untilTrue (seenCreate );
94+ .until (seenCreate );
9495 }
9596 }
9697
@@ -116,12 +117,12 @@ public void onDeleted(WatchEvent ev) {
116117 // Delete the file
117118 Files .delete (target );
118119 await ("File deletion should generate delete event" )
119- .untilTrue (seenDelete );
120+ .until (seenDelete );
120121
121122 // Re-create it again
122123 Files .writeString (target , "Hello World" );
123124 await ("File creation should generate create event" )
124- .untilTrue (seenCreate );
125+ .until (seenCreate );
125126 }
126127 }
127128
@@ -181,22 +182,23 @@ void indexingRescanOnOverflow() throws IOException, InterruptedException {
181182 // Perform some file operations (after a short wait to ensure a new
182183 // last-modified-time). No events should be observed (because the
183184 // overflow simulation is running).
184- Thread .sleep (TestHelper . SHORT_WAIT . toMillis () );
185+ Thread .sleep (100 );
185186 Files .writeString (directory .resolve ("a.txt" ), "foo" );
186187 Files .writeString (directory .resolve ("b.txt" ), "bar" );
187188 Files .delete (directory .resolve ("c.txt" ));
188189 Files .createFile (directory .resolve ("d.txt" ));
189190
190191 await ("No events should have been triggered" )
191- .pollDelay (TestHelper .SHORT_WAIT )
192- .until (() -> bookkeeper .events ().none ());
192+ .time (TestHelper .SMALL_WAIT )
193+ .holds (() -> bookkeeper .events ().none ());
193194
194195 // End overflow simulation, and generate an `OVERFLOW` event.
195196 // Synthetic events should now be issued and observed.
196197 dropEvents .set (false );
197198 var overflow = new WatchEvent (WatchEvent .Kind .OVERFLOW , directory );
198199 ((EventHandlingWatch ) watch ).handleEvent (overflow );
199200
201+
200202 for (var e : new WatchEvent [] {
201203 new WatchEvent (MODIFIED , directory , Path .of ("a.txt" )),
202204 new WatchEvent (MODIFIED , directory , Path .of ("b.txt" )),
@@ -211,7 +213,7 @@ void indexingRescanOnOverflow() throws IOException, InterruptedException {
211213
212214 // Perform some more file operations. All events should be observed
213215 // (because the overflow simulation is no longer running).
214- Thread .sleep (TestHelper . SHORT_WAIT . toMillis () );
216+ Thread .sleep (500 );
215217 Files .delete (directory .resolve ("a.txt" ));
216218 Files .writeString (directory .resolve ("b.txt" ), "baz" );
217219 Files .createFile (directory .resolve ("c.txt" ));
@@ -232,8 +234,8 @@ void indexingRescanOnOverflow() throws IOException, InterruptedException {
232234 ((EventHandlingWatch ) watch ).handleEvent (overflow );
233235
234236 await ("No events should have been triggered" )
235- .pollDelay (TestHelper .SHORT_WAIT )
236- .until (() -> bookkeeper .events ().kindNot (OVERFLOW ).none ());
237+ .time (TestHelper .SMALL_WAIT )
238+ .holds (() -> bookkeeper .events ().kindNot (OVERFLOW ).none ());
237239 }
238240 }
239241}
0 commit comments