Try to prevent Travis build failures
Update LiveReloadServerTests which seems to be failing intermittently on Travis.
This commit is contained in:
parent
aacf5d660f
commit
b76978ff7e
|
|
@ -83,9 +83,8 @@ public class LiveReloadServerTests {
|
||||||
@Test
|
@Test
|
||||||
public void triggerReload() throws Exception {
|
public void triggerReload() throws Exception {
|
||||||
LiveReloadWebSocketHandler handler = connect();
|
LiveReloadWebSocketHandler handler = connect();
|
||||||
handler.setExpectedMessageCount(1);
|
|
||||||
this.server.triggerReload();
|
this.server.triggerReload();
|
||||||
handler.awaitMessages();
|
Thread.sleep(200);
|
||||||
this.server.stop();
|
this.server.stop();
|
||||||
assertThat(handler.getMessages().get(0))
|
assertThat(handler.getMessages().get(0))
|
||||||
.contains("http://livereload.com/protocols/official-7");
|
.contains("http://livereload.com/protocols/official-7");
|
||||||
|
|
@ -208,8 +207,6 @@ public class LiveReloadServerTests {
|
||||||
|
|
||||||
private final CountDownLatch helloLatch = new CountDownLatch(2);
|
private final CountDownLatch helloLatch = new CountDownLatch(2);
|
||||||
|
|
||||||
private CountDownLatch messagesLatch;
|
|
||||||
|
|
||||||
private final List<String> messages = new ArrayList<String>();
|
private final List<String> messages = new ArrayList<String>();
|
||||||
|
|
||||||
private int pongCount;
|
private int pongCount;
|
||||||
|
|
@ -229,19 +226,12 @@ public class LiveReloadServerTests {
|
||||||
Thread.sleep(200);
|
Thread.sleep(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setExpectedMessageCount(int count) {
|
|
||||||
this.messagesLatch = new CountDownLatch(count);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handleTextMessage(WebSocketSession session, TextMessage message)
|
protected void handleTextMessage(WebSocketSession session, TextMessage message)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
if (message.getPayload().contains("hello")) {
|
if (message.getPayload().contains("hello")) {
|
||||||
this.helloLatch.countDown();
|
this.helloLatch.countDown();
|
||||||
}
|
}
|
||||||
if (this.messagesLatch != null) {
|
|
||||||
this.messagesLatch.countDown();
|
|
||||||
}
|
|
||||||
this.messages.add(message.getPayload());
|
this.messages.add(message.getPayload());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -265,10 +255,6 @@ public class LiveReloadServerTests {
|
||||||
this.session.close();
|
this.session.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void awaitMessages() throws InterruptedException {
|
|
||||||
this.messagesLatch.await(1, TimeUnit.MINUTES);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getMessages() {
|
public List<String> getMessages() {
|
||||||
return this.messages;
|
return this.messages;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue