use of examples.ListenerBasicSocket in project jetty.project by eclipse.
the class EventDriverFactoryTest method testListenerBasicSocket.
/**
* Test Case for no exceptions and 5 methods (implement WebSocketListener)
*/
@Test
public void testListenerBasicSocket() {
EventDriverFactory factory = new EventDriverFactory(new SimpleContainerScope(WebSocketPolicy.newClientPolicy()));
ListenerBasicSocket socket = new ListenerBasicSocket();
EventDriver driver = factory.wrap(socket);
String classId = ListenerBasicSocket.class.getSimpleName();
Assert.assertThat("EventDriver for " + classId, driver, instanceOf(JettyListenerEventDriver.class));
}
use of examples.ListenerBasicSocket 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