@Test public void test_socket_error() { final EngineIoServer engineIoServer = new EngineIoServer(); final SocketIoServer socketIoServer = new SocketIoServer(engineIoServer); final EngineIoWebSocket webSocket = Mockito.spy(new EngineIoWebSocketImpl()); final Emitter.Listener connectionListener = Mockito.mock(Emitter.Listener.class); Mockito.doAnswer(invocation -> { final Object[] args = invocation.getArguments(); final EngineIoSocket socket = Mockito.spy((EngineIoSocket) args[0]); final SocketIoClient client = new SocketIoClient(socketIoServer, socket); socket.emit("error", "parse error", null); Mockito.verify(socket, Mockito.times(1)) .close(); return null; }).when(connectionListener).call(Mockito.any()); engineIoServer.on("connection", connectionListener); engineIoServer.handleWebSocket(webSocket); Mockito.verify(connectionListener, Mockito.times(1)) .call(Mockito.any(EngineIoSocket.class)); }
private void close() { if (mConnection.getReadyState() == ReadyState.OPEN) { mConnection.close(); onClose("forced server close"); } }
SocketIoClient { private void close() { if (mConnection.getReadyState() == ReadyState.OPEN) { mConnection.close(); onClose("forced server close"); } } }
SocketIoClient { private void close() { if (mConnection.getReadyState() == ReadyState.OPEN) { mConnection.close(); onClose("forced server close"); } } SocketIoClient(SocketIoServer server, EngineIoSocket connection); }
SocketIoClient { private void close() { if (mConnection.getReadyState() == ReadyState.OPEN) { mConnection.close(); onClose("forced server close"); } } SocketIoClient(SocketIoServer server, EngineIoSocket connection);  }
SocketIoClient { private void close() { if (mConnection.getReadyState() == ReadyState.OPEN) { mConnection.close(); onClose("forced server close"); } } SocketIoClient(SocketIoServer server, EngineIoSocket connection);   }