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