Skip to content

Commit 81b1fea

Browse files
authored
test: improve reliability of mockwebserver websocket test (ws wait)
Signed-off-by: Marc Nuri <[email protected]>
1 parent 0543463 commit 81b1fea

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

junit/mockwebserver/src/test/groovy/io/fabric8/mockwebserver/DefaultMockServerWebSocketTest.groovy

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ class DefaultMockServerWebSocketTest extends Specification {
182182
given: "A WebSocket expectation"
183183
server.expect()
184184
.withPath("/websocket")
185-
.andUpgradeToWebSocket().open().done().always()
185+
.andUpgradeToWebSocket().open().waitFor(10L).andEmit("done").done().always()
186186
and:
187187
def future = new CompletableFuture()
188188
and: "A WebSocket request"
@@ -197,8 +197,9 @@ class DefaultMockServerWebSocketTest extends Specification {
197197
future.complete(ws.result().headers().get("sec-websocket-protocol"))
198198
}
199199
}
200-
if (wsReq.result() != null && wsReq.result().headers() != null) {
201-
future.complete(wsReq.result().headers().get("sec-websocket-protocol"))
200+
def currentResult = wsReq.result()
201+
if (currentResult != null && currentResult.headers() != null) {
202+
future.complete(currentResult.headers().get("sec-websocket-protocol"))
202203
}
203204
and: "An instance of AsyncConditions"
204205
def async = new AsyncConditions(1)

0 commit comments

Comments
 (0)