Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.springframework.web.socket.handler.TextWebSocketHandler;

import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
Expand Down Expand Up @@ -88,19 +89,16 @@ void servesLivereloadJs() throws Exception {
void triggerReload() throws Exception {
LiveReloadWebSocketHandler handler = connect();
this.server.triggerReload();
Thread.sleep(200);
this.server.stop();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to keep this call to stop().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test class already has an @AfterEach which calls this.server.stop();.
I assumed the original author had written those 2 test cases first and only after that decided to have a general @AfterEach method (and maybe forgot to take the individual stop()s out).

I made sure that the tests run fine without them.
Do you think stop() should be kept nevertheless?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I'd missed that when reviewing the diffs in isolation. I agree there's no need to keep the stop() calls. To keep this change clean, I think it makes sense to remove the stop() calls separately. No need for you to do anything though. We can take care of it prior to merging this.

assertThat(handler.getMessages().get(0)).contains("http://livereload.com/protocols/official-7");
assertThat(handler.getMessages().get(1)).contains("command\":\"reload\"");
await().atMost(Duration.ofSeconds(1)).until(handler::getMessages,
(msgs) -> msgs.get(0).contains("http://livereload.com/protocols/official-7")
&& msgs.get(1).contains("command\":\"reload\""));
}

@Test
void pingPong() throws Exception {
LiveReloadWebSocketHandler handler = connect();
handler.sendMessage(new PingMessage());
Thread.sleep(200);
assertThat(handler.getPongCount()).isEqualTo(1);
this.server.stop();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to keep this call to stop().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same situation as above.

await().atMost(Duration.ofSeconds(1)).until(handler::getPongCount, is(1));
}

@Test
Expand All @@ -119,8 +117,7 @@ private void awaitClosedException() throws InterruptedException {
void serverClose() throws Exception {
LiveReloadWebSocketHandler handler = connect();
this.server.stop();
Thread.sleep(200);
assertThat(handler.getCloseStatus().getCode()).isEqualTo(1006);
await().atMost(Duration.ofSeconds(1)).until(() -> handler.getCloseStatus().getCode(), is(1006));
}

private LiveReloadWebSocketHandler connect() throws Exception {
Expand Down