public static void awaitRoute ( URL routeUrl , int timeout , TimeUnit timeoutUnit , int repetitions , int ... statusCodes ) { AtomicInteger successfulAwaitsInARow = new AtomicInteger ( 0 ) ; await ( ) . atMost ( timeout , timeoutUnit ) . until ( ( ) -> { if ( tryConnect ( routeUrl , statusCodes ) ) { successfulAwaitsInARow . incrementAndGet ( ) ; } else { successfulAwaitsInARow . set ( 0 ) ; } return successfulAwaitsInARow . get ( ) >= repetitions ; } ) ; }
Waits for the timeout duration until the url responds with correct status code