Search in sources :

Example 1 with OpeningHandshakeException

use of com.neovisionaries.ws.client.OpeningHandshakeException in project ninja by ninjaframework.

the class ChatWebSocketTest method handshakeUnauthorized.

@Test
public void handshakeUnauthorized() throws IOException, WebSocketException {
    String url = withBaseWebSocketUrl("/chat?status=401");
    WebSocket ws = new WebSocketFactory().createSocket(url);
    try {
        ws.connect();
        fail("should have failed with a 401");
    } catch (OpeningHandshakeException e) {
        assertThat(e.getStatusLine().getStatusCode(), is(401));
    } finally {
        ws.disconnect(WebSocketCloseCode.NORMAL);
    }
}
Also used : OpeningHandshakeException(com.neovisionaries.ws.client.OpeningHandshakeException) WebSocketFactory(com.neovisionaries.ws.client.WebSocketFactory) WebSocket(com.neovisionaries.ws.client.WebSocket) Test(org.junit.Test)

Aggregations

OpeningHandshakeException (com.neovisionaries.ws.client.OpeningHandshakeException)1 WebSocket (com.neovisionaries.ws.client.WebSocket)1 WebSocketFactory (com.neovisionaries.ws.client.WebSocketFactory)1 Test (org.junit.Test)1