From 6fa855e85629434dec069c8011ededb3d3f0effd Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Mon, 26 Feb 2018 13:26:03 -0600 Subject: [PATCH] Fixes #2234 - Making assertion on reason phrase more resilient to race condition for Abnormal closure. --- .../websocket/client/ClientCloseTest.java | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ClientCloseTest.java b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ClientCloseTest.java index e522403538e..c90a8be9a28 100644 --- a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ClientCloseTest.java +++ b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ClientCloseTest.java @@ -18,6 +18,15 @@ package org.eclipse.jetty.websocket.client; +import static org.hamcrest.Matchers.allOf; +import static org.hamcrest.Matchers.anyOf; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.instanceOf; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; +import static org.hamcrest.Matchers.nullValue; +import static org.junit.Assert.assertThat; + import java.io.IOException; import java.lang.reflect.Field; import java.net.SocketTimeoutException; @@ -70,14 +79,6 @@ import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; -import static org.hamcrest.Matchers.allOf; -import static org.hamcrest.Matchers.containsString; -import static org.hamcrest.Matchers.instanceOf; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.notNullValue; -import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; - public class ClientCloseTest { private static final Logger LOG = Log.getLogger(ClientCloseTest.class); @@ -490,7 +491,11 @@ public class ClientCloseTest // client reads -1 (EOF) // client triggers close event on client ws-endpoint - clientSocket.assertReceivedCloseEvent(timeout,is(StatusCode.ABNORMAL),containsString("EOF")); + clientSocket.assertReceivedCloseEvent(timeout,is(StatusCode.ABNORMAL), + anyOf( + containsString("EOF"), + containsString("Disconnected") + )); } @Test