From b0407d07c25e4d7822de453d9946747446b4a056 Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Thu, 29 Aug 2024 14:15:57 +0200 Subject: [PATCH] test: improve reliability of mockwebserver websocket test (ws wait) Signed-off-by: Marc Nuri --- .../mockwebserver/DefaultMockServerWebSocketTest.groovy | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/junit/mockwebserver/src/test/groovy/io/fabric8/mockwebserver/DefaultMockServerWebSocketTest.groovy b/junit/mockwebserver/src/test/groovy/io/fabric8/mockwebserver/DefaultMockServerWebSocketTest.groovy index 85fdc3fbd57..614a71d7edf 100644 --- a/junit/mockwebserver/src/test/groovy/io/fabric8/mockwebserver/DefaultMockServerWebSocketTest.groovy +++ b/junit/mockwebserver/src/test/groovy/io/fabric8/mockwebserver/DefaultMockServerWebSocketTest.groovy @@ -182,7 +182,7 @@ class DefaultMockServerWebSocketTest extends Specification { given: "A WebSocket expectation" server.expect() .withPath("/websocket") - .andUpgradeToWebSocket().open().done().always() + .andUpgradeToWebSocket().open().waitFor(10L).andEmit("done").done().always() and: def future = new CompletableFuture() and: "A WebSocket request" @@ -197,8 +197,9 @@ class DefaultMockServerWebSocketTest extends Specification { future.complete(ws.result().headers().get("sec-websocket-protocol")) } } - if (wsReq.result() != null && wsReq.result().headers() != null) { - future.complete(wsReq.result().headers().get("sec-websocket-protocol")) + def currentResult = wsReq.result() + if (currentResult != null && currentResult.headers() != null) { + future.complete(currentResult.headers().get("sec-websocket-protocol")) } and: "An instance of AsyncConditions" def async = new AsyncConditions(1)