ExtensionWebSocketListener implements WebSocketListener { public void close() { isClosed = true; } ExtensionWebSocketListener(ExtensionWebSocketClient client); void setHttpHandler(Handler<Response> httpHandler); void setPublishHandler(Handler<ExtensionServiceMessage> publishHandler); void setQueryHandler(Handler<ExtensionServiceMessage> queryHandler); void setConfigHandler(Handler<ExtensionServiceMessage> configHandler); void setAuthHandler(Handler<Response> authHandler); void setReconnectHandler(Handler<ExtensionServiceMessage> reconnectHandler); void close(); boolean isClosed(); @Override void onOpen(WebSocket webSocket, okhttp3.Response response); @Override void onMessage(ResponseBody body); void useHandlersFromListener(ExtensionWebSocketListener listener); void useHandlersFromListener(ExtensionWebSocketClient client); @Override void onClose(int code, String reason); @Override void onPong(Buffer payload); @Override void onFailure(IOException e, okhttp3.Response response);  }
@Test public void testClose() { connectToSource(srcName, null); listener.close(); ResponseBody body = TestListener.createReconnectMessage(srcName); listener.onMessage(body); assert rHandler.compareMessage(null); body = TestListener.createHttpMessage(new Response().status(200)); listener.onMessage(body); assert hHandler.compareMessage(null); aHandler.lastMessage = null; body = TestListener.createAuthenticationResponse(true); listener.onMessage(body); assert aHandler.compareMessage(null); body = TestListener.createQueryMessage(new LinkedHashMap(), srcName); listener.onMessage(body); assert qHandler.compareMessage(null); body = TestListener.createPublishMessage(new LinkedHashMap(), srcName); listener.onMessage(body); assert pHandler.compareMessage(null); cHandler.lastMessage = null; body = TestListener.createConfigResponse(new LinkedHashMap(), srcName); listener.onMessage(body); assert cHandler.compareMessage(null); }