From 3dabd694fa22029b00c7033f27f80aa17aaed8c4 Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Thu, 29 Aug 2024 11:19:33 +0200 Subject: [PATCH] test: improve reliability of mockwebserver websocket test Signed-off-by: Marc Nuri --- .../mockwebserver/DefaultMockServerWebSocketTest.groovy | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 107eba47ab6..85fdc3fbd57 100644 --- a/junit/mockwebserver/src/test/groovy/io/fabric8/mockwebserver/DefaultMockServerWebSocketTest.groovy +++ b/junit/mockwebserver/src/test/groovy/io/fabric8/mockwebserver/DefaultMockServerWebSocketTest.groovy @@ -193,7 +193,12 @@ class DefaultMockServerWebSocketTest extends Specification { .addSubProtocol("v4.channel.k8s.io")) and: "A WebSocket listener" wsReq.onComplete { ws -> - future.complete(ws.result().headers().get("sec-websocket-protocol")) + if (ws.result() != null && ws.result().headers() != null) { + 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")) } and: "An instance of AsyncConditions" def async = new AsyncConditions(1)