JettyXmppWebSocketServlet extends WebSocketServlet { public WebSocket doWebSocketConnect(HttpServletRequest request, String protocol) { if (SUB_PROTOCOL.equals(protocol)) { JettyXmppWebSocket sessionContext = new JettyXmppWebSocket(serverRuntimeContext, stanzaProcessor); return sessionContext; } else { LOG.warn("Unsupported WebSocket sub protocol, must be \"xmpp\""); return null; } } JettyXmppWebSocketServlet();  JettyXmppWebSocketServlet(ServerRuntimeContext serverRuntimeContext, StanzaProcessor stanzaProcessor); @Override void init(); WebSocket doWebSocketConnect(HttpServletRequest request, String protocol); static final String SERVER_RUNTIME_CONTEXT_ATTRIBUTE; }
@Test public void doWebSocketConnectWithDirectCstr() throws ServletException { JettyXmppWebSocketServlet servlet = new JettyXmppWebSocketServlet(serverRuntimeContext, stanzaProcessor); WebSocket webSocket = servlet.doWebSocketConnect(null, "xmpp"); Assert.assertTrue(webSocket instanceof JettyXmppWebSocket); }
@Test public void doWebSocketConnectWithInvalidSubprotocl() throws ServletException { JettyXmppWebSocketServlet servlet = new JettyXmppWebSocketServlet(serverRuntimeContext, stanzaProcessor); WebSocket webSocket = servlet.doWebSocketConnect(null, "dummy"); Assert.assertNull(webSocket); }