@Test(expected=RuntimeException.class) public void doWebSocketConnectMissingAttribute() throws ServletException { ServletContext servletContext = Mockito.mock(ServletContext.class); ServletConfig servletConfig = Mockito.mock(ServletConfig.class); Mockito.when(servletConfig.getServletContext()).thenReturn(servletContext); JettyXmppWebSocketServlet servlet = new JettyXmppWebSocketServlet(); servlet.init(servletConfig); }
@Override public void init() throws ServletException { super.init(); if (serverRuntimeContext == null) { serverRuntimeContext = (ServerRuntimeContext) getServletContext() .getAttribute(SERVER_RUNTIME_CONTEXT_ATTRIBUTE); if (serverRuntimeContext == null) { throw new RuntimeException("Failed to get Vysper ServerRuntimeContext from servlet context attribute \"" + SERVER_RUNTIME_CONTEXT_ATTRIBUTE + "\""); } } if (stanzaProcessor == null) { stanzaProcessor = (StanzaProcessor) getServletContext() .getAttribute(StanzaProcessor.class.getCanonicalName()); if (stanzaProcessor == null) { throw new RuntimeException("Failed to get Vysper StanzaProcessor from servlet context attribute \"" + StanzaProcessor.class.getCanonicalName() + "\""); } } }
JettyXmppWebSocketServlet extends WebSocketServlet { @Override public void init() throws ServletException { super.init(); if (serverRuntimeContext == null) { serverRuntimeContext = (ServerRuntimeContext) getServletContext() .getAttribute(SERVER_RUNTIME_CONTEXT_ATTRIBUTE); if (serverRuntimeContext == null) { throw new RuntimeException("Failed to get Vysper ServerRuntimeContext from servlet context attribute \"" + SERVER_RUNTIME_CONTEXT_ATTRIBUTE + "\""); } } if (stanzaProcessor == null) { stanzaProcessor = (StanzaProcessor) getServletContext() .getAttribute(StanzaProcessor.class.getCanonicalName()); if (stanzaProcessor == null) { throw new RuntimeException("Failed to get Vysper StanzaProcessor from servlet context attribute \"" + StanzaProcessor.class.getCanonicalName() + "\""); } } } }
JettyXmppWebSocketServlet extends WebSocketServlet { @Override public void init() throws ServletException { super.init(); if (serverRuntimeContext == null) { serverRuntimeContext = (ServerRuntimeContext) getServletContext() .getAttribute(SERVER_RUNTIME_CONTEXT_ATTRIBUTE); if (serverRuntimeContext == null) { throw new RuntimeException("Failed to get Vysper ServerRuntimeContext from servlet context attribute \"" + SERVER_RUNTIME_CONTEXT_ATTRIBUTE + "\""); } } if (stanzaProcessor == null) { stanzaProcessor = (StanzaProcessor) getServletContext() .getAttribute(StanzaProcessor.class.getCanonicalName()); if (stanzaProcessor == null) { throw new RuntimeException("Failed to get Vysper StanzaProcessor from servlet context attribute \"" + StanzaProcessor.class.getCanonicalName() + "\""); } } } JettyXmppWebSocketServlet();  JettyXmppWebSocketServlet(ServerRuntimeContext serverRuntimeContext, StanzaProcessor stanzaProcessor); }
JettyXmppWebSocketServlet extends WebSocketServlet { @Override public void init() throws ServletException { super.init(); if (serverRuntimeContext == null) { serverRuntimeContext = (ServerRuntimeContext) getServletContext() .getAttribute(SERVER_RUNTIME_CONTEXT_ATTRIBUTE); if (serverRuntimeContext == null) { throw new RuntimeException("Failed to get Vysper ServerRuntimeContext from servlet context attribute \"" + SERVER_RUNTIME_CONTEXT_ATTRIBUTE + "\""); } } if (stanzaProcessor == null) { stanzaProcessor = (StanzaProcessor) getServletContext() .getAttribute(StanzaProcessor.class.getCanonicalName()); if (stanzaProcessor == null) { throw new RuntimeException("Failed to get Vysper StanzaProcessor from servlet context attribute \"" + StanzaProcessor.class.getCanonicalName() + "\""); } } } JettyXmppWebSocketServlet();  JettyXmppWebSocketServlet(ServerRuntimeContext serverRuntimeContext, StanzaProcessor stanzaProcessor); @Override void init(); WebSocket doWebSocketConnect(HttpServletRequest request, String protocol); }
JettyXmppWebSocketServlet extends WebSocketServlet { @Override public void init() throws ServletException { super.init(); if (serverRuntimeContext == null) { serverRuntimeContext = (ServerRuntimeContext) getServletContext() .getAttribute(SERVER_RUNTIME_CONTEXT_ATTRIBUTE); if (serverRuntimeContext == null) { throw new RuntimeException("Failed to get Vysper ServerRuntimeContext from servlet context attribute \"" + SERVER_RUNTIME_CONTEXT_ATTRIBUTE + "\""); } } if (stanzaProcessor == null) { stanzaProcessor = (StanzaProcessor) getServletContext() .getAttribute(StanzaProcessor.class.getCanonicalName()); if (stanzaProcessor == null) { throw new RuntimeException("Failed to get Vysper StanzaProcessor from servlet context attribute \"" + StanzaProcessor.class.getCanonicalName() + "\""); } } } JettyXmppWebSocketServlet();  JettyXmppWebSocketServlet(ServerRuntimeContext serverRuntimeContext, StanzaProcessor stanzaProcessor); @Override void init(); WebSocket doWebSocketConnect(HttpServletRequest request, String protocol); static final String SERVER_RUNTIME_CONTEXT_ATTRIBUTE; }