Skip to content

Commit

Permalink
WebSockets Next: attempt to diagnose BroadcastOnOpenTest
Browse files Browse the repository at this point in the history
  • Loading branch information
mkouba committed Mar 19, 2024
1 parent 08c418b commit 21ee978
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void assertBroadcast(URI testUri) throws Exception {
if (r.succeeded()) {
WebSocket ws = r.result();
ws.textMessageHandler(msg -> {
messages.add(msg);
messages.add(msg + ":fromC1");
if (msg.equals("c1")) {
c1MessageLatch.countDown();
} else if (msg.equals("c2")) {
Expand All @@ -79,7 +79,7 @@ public void assertBroadcast(URI testUri) throws Exception {
});
assertTrue(c1MessageLatch.await(5, TimeUnit.SECONDS));
assertEquals(1, messages.size());
assertEquals("c1", messages.get(0));
assertEquals("c1:fromC1", messages.get(0));
messages.clear();
// Now connect the second client
client2
Expand All @@ -88,7 +88,7 @@ public void assertBroadcast(URI testUri) throws Exception {
if (r.succeeded()) {
WebSocket ws = r.result();
ws.textMessageHandler(msg -> {
messages.add(msg);
messages.add(msg + ":fromC2");
c2MessageLatch.countDown();
});
} else {
Expand All @@ -98,8 +98,8 @@ public void assertBroadcast(URI testUri) throws Exception {
assertTrue(c2MessageLatch.await(5, TimeUnit.SECONDS), "Messages: " + messages);
// onOpen should be broadcasted to both clients
assertEquals(2, messages.size());
assertEquals("c2", messages.get(0));
assertEquals("c2", messages.get(1));
assertEquals("c2", messages.get(0).substring(0, 2));
assertEquals("c2", messages.get(1).substring(0, 2));
} finally {
client1.close().toCompletionStage().toCompletableFuture().get();
client2.close().toCompletionStage().toCompletableFuture().get();
Expand Down

0 comments on commit 21ee978

Please sign in to comment.