23
23
import java .time .Duration ;
24
24
import java .util .ArrayList ;
25
25
import java .util .List ;
26
+ import java .util .Objects ;
26
27
import java .util .concurrent .CountDownLatch ;
27
28
import java .util .concurrent .TimeUnit ;
28
29
@@ -89,16 +90,18 @@ void servesLivereloadJs() throws Exception {
89
90
void triggerReload () throws Exception {
90
91
LiveReloadWebSocketHandler handler = connect ();
91
92
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
+
95
98
}
96
99
97
100
@ Test
98
101
void pingPong () throws Exception {
99
102
LiveReloadWebSocketHandler handler = connect ();
100
103
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 ));
102
105
}
103
106
104
107
@ Test
@@ -117,7 +120,9 @@ private void awaitClosedException() throws InterruptedException {
117
120
void serverClose () throws Exception {
118
121
LiveReloadWebSocketHandler handler = connect ();
119
122
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 );
121
126
}
122
127
123
128
private LiveReloadWebSocketHandler connect () throws Exception {
0 commit comments