use of spark.embeddedserver.jetty.websocket.WebSocketTestClient in project spark by perwendel.
the class GenericIntegrationTest method testWebSocketConversation.
@Test
public void testWebSocketConversation() throws Exception {
String uri = "ws://localhost:4567/ws";
WebSocketClient client = new WebSocketClient();
WebSocketTestClient ws = new WebSocketTestClient();
try {
client.start();
client.connect(ws, URI.create(uri), new ClientUpgradeRequest());
ws.awaitClose(30, TimeUnit.SECONDS);
} finally {
client.stop();
}
List<String> events = WebSocketTestHandler.events;
Assert.assertEquals(3, events.size(), 3);
Assert.assertEquals("onConnect", events.get(0));
Assert.assertEquals("onMessage: Hi Spark!", events.get(1));
Assert.assertEquals("onClose: 1000 Bye!", events.get(2));
}
Aggregations