use of org.eclipse.jetty.websocket.common.io.LocalWebSocketSession in project jetty.project by eclipse.
the class MessageWriterTest method setupSession.
@Before
public void setupSession() throws Exception {
policy = WebSocketPolicy.newServerPolicy();
policy.setInputBufferSize(1024);
policy.setMaxTextMessageBufferSize(1024);
// Container
WebSocketContainerScope containerScope = new SimpleContainerScope(policy, bufferPool);
// Event Driver factory
EventDriverFactory factory = new EventDriverFactory(containerScope);
// local socket
EventDriver driver = factory.wrap(new TrackingSocket("local"));
// remote socket
socket = new TrackingSocket("remote");
OutgoingFrames socketPipe = FramePipes.to(factory.wrap(socket));
session = new LocalWebSocketSession(containerScope, testname, driver);
session.setPolicy(policy);
// talk to our remote socket
session.setOutgoingHandler(socketPipe);
// start session
session.start();
// open connection
session.open();
}
use of org.eclipse.jetty.websocket.common.io.LocalWebSocketSession in project jetty.project by eclipse.
the class EventDriverTest method testAnnotated_ByteArray.
@Test
public void testAnnotated_ByteArray() throws Exception {
AnnotatedBinaryArraySocket socket = new AnnotatedBinaryArraySocket();
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().assertEvent("onBinary([11],0,11)");
socket.capture.pop().assertEventStartsWith("onClose(1000,");
}
}
use of org.eclipse.jetty.websocket.common.io.LocalWebSocketSession in project jetty.project by eclipse.
the class EventDriverTest method testListenerPingPong.
@Test
public void testListenerPingPong() 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().setPayload("PING"));
driver.incomingFrame(new PongFrame().setPayload("PONG"));
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.io.LocalWebSocketSession 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,");
}
}
use of org.eclipse.jetty.websocket.common.io.LocalWebSocketSession in project jetty.project by eclipse.
the class MessageOutputStreamTest method setupSession.
@Before
public void setupSession() throws Exception {
policy = WebSocketPolicy.newServerPolicy();
policy.setInputBufferSize(1024);
policy.setMaxBinaryMessageBufferSize(1024);
// Container
WebSocketContainerScope containerScope = new SimpleContainerScope(policy, bufferPool);
// Event Driver factory
EventDriverFactory factory = new EventDriverFactory(containerScope);
// local socket
EventDriver driver = factory.wrap(new TrackingSocket("local"));
// remote socket
socket = new TrackingSocket("remote");
OutgoingFrames socketPipe = FramePipes.to(factory.wrap(socket));
session = new LocalWebSocketSession(containerScope, testname, driver);
session.setPolicy(policy);
// talk to our remote socket
session.setOutgoingHandler(socketPipe);
// start session
session.start();
// open connection
session.open();
}
Aggregations