Search in sources :

Example 1 with AnnotatedTextSocket

use of examples.AnnotatedTextSocket in project jetty.project by eclipse.

the class EventDriverTest method testAnnotated_Error.

@Test
public void testAnnotated_Error() throws Exception {
    AnnotatedTextSocket socket = new AnnotatedTextSocket();
    EventDriver driver = wrap(socket);
    try (LocalWebSocketSession conn = new CloseableLocalWebSocketSession(container, testname, driver)) {
        conn.open();
        driver.incomingError(new WebSocketException("oof"));
        driver.incomingFrame(new CloseInfo(StatusCode.NORMAL).asFrame());
        socket.capture.assertEventCount(3);
        socket.capture.pop().assertEventStartsWith("onConnect");
        socket.capture.pop().assertEventStartsWith("onError(WebSocketException: oof)");
        socket.capture.pop().assertEventStartsWith("onClose(1000,");
    }
}
Also used : LocalWebSocketSession(org.eclipse.jetty.websocket.common.io.LocalWebSocketSession) CloseableLocalWebSocketSession(org.eclipse.jetty.websocket.common.io.CloseableLocalWebSocketSession) WebSocketException(org.eclipse.jetty.websocket.api.WebSocketException) CloseableLocalWebSocketSession(org.eclipse.jetty.websocket.common.io.CloseableLocalWebSocketSession) AnnotatedTextSocket(examples.AnnotatedTextSocket) CloseInfo(org.eclipse.jetty.websocket.common.CloseInfo) Test(org.junit.Test)

Aggregations

AnnotatedTextSocket (examples.AnnotatedTextSocket)1 WebSocketException (org.eclipse.jetty.websocket.api.WebSocketException)1 CloseInfo (org.eclipse.jetty.websocket.common.CloseInfo)1 CloseableLocalWebSocketSession (org.eclipse.jetty.websocket.common.io.CloseableLocalWebSocketSession)1 LocalWebSocketSession (org.eclipse.jetty.websocket.common.io.LocalWebSocketSession)1 Test (org.junit.Test)1