@Test
public void testClientAndServerClose() throws Exception {
HttpServer server = new HttpServer(new MixedRequestHandler());
server.start();
HttpClient httpClient = new HttpClient();
IHttpResponse response = httpClient.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/"));
Assert.assertEquals(200, response.getStatus());
Assert.assertEquals("OK", response.getBody().toString());
IWebSocketConnection webSocketConnection = httpClient.openWebSocketConnection("ws://localhost:" + server.getLocalPort());
WebSocketMessage msg = webSocketConnection.readMessage();
Assert.assertTrue(msg.isTextMessage());
Assert.assertEquals("Hello you", msg.toString());
webSocketConnection.writeMessage(new TextMessage("01234567890"));
msg = webSocketConnection.readMessage();
Assert.assertEquals("01234567890", msg.toString("UTF-8"));
webSocketConnection.close();
Assert.assertFalse(webSocketConnection.isOpen());
QAUtil.sleep(500);
httpClient.close();
server.close();
}