@Test
public void test_disconnect() {

    final EngineIoServer engineIoServer = new EngineIoServer();
    final SocketIoServer server = new SocketIoServer(engineIoServer);
    final SocketIoNamespace namespace = server.namespace("/");
    assertNotNull(namespace);
    final Emitter.Listener disconnectListener = Mockito.mock(Emitter.Listener.class);
    final Emitter.Listener connectionListener = Mockito.mock(Emitter.Listener.class);
    Mockito.doAnswer(invocation -> {
        final Object[] args = invocation.getArguments();
        final SocketIoSocket socket = (SocketIoSocket) args[0];
        socket.on("disconnect", disconnectListener);
        return null;
    }).when(connectionListener).call(Mockito.any());
    namespace.on("connect", connectionListener);
    final EngineIoWebSocket webSocket = new EngineIoWebSocket() {
        @Override
        public Map<String, String> getQuery() {
            return new HashMap<>();
        }
        @Override
        public void write(String message) {
        }
        @Override
        public void write(byte[] message) {
        }
        @Override
        public void close() {
        }
    };
    engineIoServer.handleWebSocket(webSocket);
    Mockito.verify(connectionListener, Mockito.times(1))
            .call(Mockito.any(SocketIoSocket.class));
    webSocket.emit("close", "client close", null);
    Mockito.verify(disconnectListener, Mockito.times(1))
            .call(Mockito.anyString());
}