Search in sources :

Example 1 with AnnotatedFramesSocket

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

the class EventDriverTest method testAnnotated_Frames.

@Test
public void testAnnotated_Frames() throws Exception {
    AnnotatedFramesSocket socket = new AnnotatedFramesSocket();
    EventDriver driver = wrap(socket);
    try (LocalWebSocketSession conn = new CloseableLocalWebSocketSession(container, testname, driver)) {
        conn.open();
        driver.incomingFrame(new PingFrame().setPayload("PING"));
        driver.incomingFrame(new TextFrame().setPayload("Text Me"));
        driver.incomingFrame(new BinaryFrame().setPayload("Hello Bin"));
        driver.incomingFrame(new CloseInfo(StatusCode.SHUTDOWN, "testcase").asFrame());
        socket.capture.assertEventCount(6);
        socket.capture.pop().assertEventStartsWith("onConnect(");
        socket.capture.pop().assertEventStartsWith("onFrame(PING[");
        socket.capture.pop().assertEventStartsWith("onFrame(TEXT[");
        socket.capture.pop().assertEventStartsWith("onFrame(BINARY[");
        socket.capture.pop().assertEventStartsWith("onFrame(CLOSE[");
        socket.capture.pop().assertEventStartsWith("onClose(1001,");
    }
}
Also used : AnnotatedFramesSocket(examples.AnnotatedFramesSocket) LocalWebSocketSession(org.eclipse.jetty.websocket.common.io.LocalWebSocketSession) CloseableLocalWebSocketSession(org.eclipse.jetty.websocket.common.io.CloseableLocalWebSocketSession) BinaryFrame(org.eclipse.jetty.websocket.common.frames.BinaryFrame) PingFrame(org.eclipse.jetty.websocket.common.frames.PingFrame) CloseableLocalWebSocketSession(org.eclipse.jetty.websocket.common.io.CloseableLocalWebSocketSession) TextFrame(org.eclipse.jetty.websocket.common.frames.TextFrame) CloseInfo(org.eclipse.jetty.websocket.common.CloseInfo) Test(org.junit.Test)

Aggregations

AnnotatedFramesSocket (examples.AnnotatedFramesSocket)1 CloseInfo (org.eclipse.jetty.websocket.common.CloseInfo)1 BinaryFrame (org.eclipse.jetty.websocket.common.frames.BinaryFrame)1 PingFrame (org.eclipse.jetty.websocket.common.frames.PingFrame)1 TextFrame (org.eclipse.jetty.websocket.common.frames.TextFrame)1 CloseableLocalWebSocketSession (org.eclipse.jetty.websocket.common.io.CloseableLocalWebSocketSession)1 LocalWebSocketSession (org.eclipse.jetty.websocket.common.io.LocalWebSocketSession)1 Test (org.junit.Test)1