2323import java .time .Duration ;
2424import java .util .ArrayList ;
2525import java .util .List ;
26+ import java .util .Objects ;
2627import java .util .concurrent .CountDownLatch ;
2728import java .util .concurrent .TimeUnit ;
2829
@@ -89,16 +90,18 @@ void servesLivereloadJs() throws Exception {
8990 void triggerReload () throws Exception {
9091 LiveReloadWebSocketHandler handler = connect ();
9192 this .server .triggerReload ();
92- await ().atMost (Duration .ofSeconds (1 )).until (handler ::getMessages ,
93- (msgs ) -> msgs .get (0 ).contains ("http://livereload.com/protocols/official-7" )
94- && msgs .get (1 ).contains ("command\" :\" reload\" " ));
93+ List <String > messages = await ().atMost (Duration .ofSeconds (10 )).until (handler ::getMessages ,
94+ (msgs ) -> msgs .size () == 2 );
95+ assertThat (messages .get (0 )).contains ("http://livereload.com/protocols/official-7" );
96+ assertThat (messages .get (1 )).contains ("command\" :\" reload\" " );
97+
9598 }
9699
97100 @ Test
98101 void pingPong () throws Exception {
99102 LiveReloadWebSocketHandler handler = connect ();
100103 handler .sendMessage (new PingMessage ());
101- await ().atMost (Duration .ofSeconds (1 )).until (handler ::getPongCount , is (1 ));
104+ await ().atMost (Duration .ofSeconds (10 )).until (handler ::getPongCount , is (1 ));
102105 }
103106
104107 @ Test
@@ -117,7 +120,9 @@ private void awaitClosedException() throws InterruptedException {
117120 void serverClose () throws Exception {
118121 LiveReloadWebSocketHandler handler = connect ();
119122 this .server .stop ();
120- await ().atMost (Duration .ofSeconds (1 )).until (() -> handler .getCloseStatus ().getCode (), is (1006 ));
123+ CloseStatus closeStatus = await ().atMost (Duration .ofSeconds (10 )).until (handler ::getCloseStatus ,
124+ Objects ::nonNull );
125+ assertThat (closeStatus .getCode ()).isEqualTo (1006 );
121126 }
122127
123128 private LiveReloadWebSocketHandler connect () throws Exception {
0 commit comments