66import java .io .IOException ;
77import java .nio .file .Files ;
88import java .nio .file .Path ;
9+ import java .time .Duration ;
910import java .util .concurrent .ExecutorService ;
1011import java .util .concurrent .Executors ;
1112import java .util .concurrent .Future ;
2223
2324public class DataFileWatchTest {
2425
26+ // This is a rather long timeout due to the GH runner instances running many things concurrently.
27+ static final Duration FUTURE_WAIT_DURATION = Duration .ofMinutes (15 );
28+
2529 @ TempDir
2630 Path tempDir ;
2731
@@ -55,7 +59,7 @@ public void dataFileSize() throws Exception {
5559 }
5660
5761 @ Test
58- public void waitForDataFileGoodCase () throws Exception {
62+ public void waitForDataFileGoodCase () {
5963 // Scenario:
6064 // - The Jacoco data file does not already exist
6165 // - File created after 2 wait iterations
@@ -92,7 +96,7 @@ void waitSleep() {
9296
9397 Future <Boolean > future = executor .submit (dataFileWatch ::waitForDataFile );
9498
95- assertThat (future . get ( 30 , TimeUnit . SECONDS )). isTrue ( );
99+ assertThat (future ). succeedsWithin ( FUTURE_WAIT_DURATION ). isEqualTo ( true );
96100 assertThat (waitIterations .get ()).isEqualTo (2 );
97101 assertThat (error .get ()).isNull ();
98102 }
@@ -136,13 +140,13 @@ void waitSleep() {
136140
137141 Future <Boolean > future = executor .submit (dataFileWatch ::waitForDataFile );
138142
139- assertThat (future . get ( 30 , TimeUnit . SECONDS )). isTrue ( );
143+ assertThat (future ). succeedsWithin ( FUTURE_WAIT_DURATION ). isEqualTo ( true );
140144 assertThat (waitIterations .get ()).isEqualTo (2 );
141145 assertThat (error .get ()).isNull ();
142146 }
143147
144148 @ Test
145- public void waitForDataFileJacocoStillRunning () throws Exception {
149+ public void waitForDataFileJacocoStillRunning () {
146150 // Scenario:
147151 // - The Jacoco data file does not already exist
148152 // - file created after 2 wait iterations
@@ -174,15 +178,15 @@ void waitSleep() {
174178
175179 Future <Boolean > future = executor .submit (dataFileWatch ::waitForDataFile );
176180
177- assertThat (future . get ( 30 , TimeUnit . SECONDS )). isFalse ( );
181+ assertThat (future ). succeedsWithin ( FUTURE_WAIT_DURATION ). isEqualTo ( false );
178182 assertThat (waitIterations .get ()).isEqualTo (0 );
179183 assertThat (error .get ()).isEqualTo (String .format (
180184 "Timed out waiting for Jacoco data file %s update, file size before test run: did not exist, current file size: 100" ,
181185 datafile ));
182186 }
183187
184188 @ Test
185- public void waitForDataFileThatNeverAppears () throws Exception {
189+ public void waitForDataFileThatNeverAppears () {
186190 // Scenario:
187191 // - The Jacoco data file does not already exist,
188192 // - The data file never appears
@@ -205,8 +209,8 @@ void waitSleep() {
205209
206210 Future <Boolean > future = executor .submit (dataFileWatch ::waitForDataFile );
207211
208- assertThat (future . isDone ()). isFalse ( );
209- assertThat (future .get (30 , TimeUnit . SECONDS )).isFalse ( );
212+ assertThat (future ). succeedsWithin ( FUTURE_WAIT_DURATION ). isEqualTo ( false );
213+ assertThat (waitIterations .get ()).isEqualTo ( 0 );
210214 assertThat (error .get ()).isEqualTo (String .format (
211215 "Timed out waiting for Jacoco data file %s update, file size before test run: did not exist, current file size: does not exist" ,
212216 datafile ));
@@ -238,8 +242,8 @@ void waitSleep() {
238242
239243 Future <Boolean > future = executor .submit (dataFileWatch ::waitForDataFile );
240244
241- assertThat (future . isDone ()). isFalse ( );
242- assertThat (future .get (30 , TimeUnit . SECONDS )).isFalse ( );
245+ assertThat (future ). succeedsWithin ( FUTURE_WAIT_DURATION ). isEqualTo ( false );
246+ assertThat (waitIterations .get ()).isEqualTo ( 0 );
243247 assertThat (error .get ()).isEqualTo (String .format (
244248 "Timed out waiting for Jacoco data file %s update, file size before test run: 100, current file size: 100" ,
245249 datafile ));
0 commit comments