Skip to content

Commit f4a7881

Browse files
committed
Fix intermittent timeout in SockJSRawTransportTest
Use await() for WebSocket connect instead of an async callback to ensure the frame handler is set before any frames are processed. Signed-off-by: Thomas Segismont <tsegismont@gmail.com>
1 parent e8bed7f commit f4a7881

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

vertx-web/src/test/java/io/vertx/ext/web/tests/handler/sockjs/SockJSRawTransportTest.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package io.vertx.ext.web.tests.handler.sockjs;
1717

1818
import io.vertx.core.buffer.Buffer;
19+
import io.vertx.core.http.WebSocket;
1920
import io.vertx.core.http.WebSocketConnectOptions;
2021
import io.vertx.ext.web.handler.sockjs.SockJSHandlerOptions;
2122
import io.vertx.junit5.Checkpoint;
@@ -136,21 +137,20 @@ private void testWrite(boolean text, Checkpoint checkpoint) throws Exception {
136137
});
137138
};
138139
startServers(new SockJSHandlerOptions());
139-
wsClient.connect("/test/websocket").onComplete(TestUtils.onSuccess(ws -> {
140-
ws.frameHandler(frame -> {
141-
if (frame.isClose()) {
142-
//
140+
WebSocket ws = wsClient.connect("/test/websocket").await();
141+
ws.frameHandler(frame -> {
142+
if (frame.isClose()) {
143+
//
144+
} else {
145+
if (text) {
146+
assertTrue(frame.isText());
147+
assertEquals(expected, frame.textData());
143148
} else {
144-
if (text) {
145-
assertTrue(frame.isText());
146-
assertEquals(expected, frame.textData());
147-
} else {
148-
assertTrue(frame.isBinary());
149-
assertEquals(Buffer.buffer(expected), frame.binaryData());
150-
}
151-
ws.end();
149+
assertTrue(frame.isBinary());
150+
assertEquals(Buffer.buffer(expected), frame.binaryData());
152151
}
153-
});
154-
}));
152+
ws.end();
153+
}
154+
});
155155
}
156156
}

0 commit comments

Comments
 (0)