use of org.eclipse.jetty.websocket.common.CloseInfo 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,");
}
}
use of org.eclipse.jetty.websocket.common.CloseInfo in project jetty.project by eclipse.
the class EventDriverTest method testListenerEmptyPingPong.
@Test
public void testListenerEmptyPingPong() throws Exception {
ListenerPingPongSocket socket = new ListenerPingPongSocket();
EventDriver driver = wrap(socket);
try (LocalWebSocketSession conn = new CloseableLocalWebSocketSession(container, testname, driver)) {
conn.start();
conn.open();
driver.incomingFrame(new PingFrame());
driver.incomingFrame(new PongFrame());
driver.incomingFrame(new CloseInfo(StatusCode.NORMAL).asFrame());
socket.capture.assertEventCount(4);
socket.capture.pop().assertEventStartsWith("onWebSocketConnect");
socket.capture.pop().assertEventStartsWith("onWebSocketPing(");
socket.capture.pop().assertEventStartsWith("onWebSocketPong(");
socket.capture.pop().assertEventStartsWith("onWebSocketClose(1000,");
}
}
use of org.eclipse.jetty.websocket.common.CloseInfo in project jetty.project by eclipse.
the class EventDriverTest method testAdapter_ConnectClose.
@Test
public void testAdapter_ConnectClose() throws Exception {
AdapterConnectCloseSocket socket = new AdapterConnectCloseSocket();
EventDriver driver = wrap(socket);
try (LocalWebSocketSession conn = new CloseableLocalWebSocketSession(container, testname, driver)) {
conn.open();
driver.incomingFrame(new CloseInfo(StatusCode.NORMAL).asFrame());
socket.capture.assertEventCount(2);
socket.capture.pop().assertEventStartsWith("onWebSocketConnect");
socket.capture.pop().assertEventStartsWith("onWebSocketClose");
}
}
use of org.eclipse.jetty.websocket.common.CloseInfo in project jetty.project by eclipse.
the class EventDriverTest method testAnnotated_InputStream.
@Test
public void testAnnotated_InputStream() throws IOException, TimeoutException, InterruptedException {
AnnotatedBinaryStreamSocket socket = new AnnotatedBinaryStreamSocket();
EventDriver driver = wrap(socket);
try (LocalWebSocketSession conn = new CloseableLocalWebSocketSession(container, testname, driver)) {
conn.open();
driver.incomingFrame(makeBinaryFrame("Hello World", true));
driver.incomingFrame(new CloseInfo(StatusCode.NORMAL).asFrame());
socket.capture.assertEventCount(3);
socket.capture.pop().assertEventStartsWith("onConnect");
socket.capture.pop().assertEventRegex("^onBinary\\(.*InputStream.*");
socket.capture.pop().assertEventStartsWith("onClose(1000,");
}
}
use of org.eclipse.jetty.websocket.common.CloseInfo in project jetty.project by eclipse.
the class EventDriverTest method testListenerBasic_Text.
@Test
public void testListenerBasic_Text() throws Exception {
ListenerBasicSocket socket = new ListenerBasicSocket();
EventDriver driver = wrap(socket);
try (LocalWebSocketSession conn = new CloseableLocalWebSocketSession(container, testname, driver)) {
conn.start();
conn.open();
driver.incomingFrame(new TextFrame().setPayload("Hello World"));
driver.incomingFrame(new CloseInfo(StatusCode.NORMAL).asFrame());
socket.capture.assertEventCount(3);
socket.capture.pop().assertEventStartsWith("onWebSocketConnect");
socket.capture.pop().assertEventStartsWith("onWebSocketText(\"Hello World\")");
socket.capture.pop().assertEventStartsWith("onWebSocketClose(1000,");
}
}
Aggregations