@Test
public void test_onDisconnect() {

    final EngineIoServer engineIoServer = new EngineIoServer();
    final SocketIoServer server = Mockito.spy(new SocketIoServer(engineIoServer));
    final SocketIoNamespace namespace = server.namespace("/");
    final Emitter.Listener connectionListener = Mockito.mock(Emitter.Listener.class);
    Mockito.doAnswer(invocation -> {
        final Object[] args = invocation.getArguments();
        final SocketIoSocket socket = (SocketIoSocket) args[0];
        final Emitter.Listener disconnectListener = Mockito.mock(Emitter.Listener.class);
        socket.on("disconnect", disconnectListener);
        Mockito.reset(disconnectListener);
        socket.onDisconnect();
        Mockito.verify(disconnectListener, Mockito.times(1))
                .call(Mockito.anyString());
        Mockito.reset(disconnectListener);
        socket.onDisconnect();
        Mockito.verify(disconnectListener, Mockito.times(0))
                .call(Mockito.anyString());
        return null;
    }).when(connectionListener).call(Mockito.any());
    namespace.on("connection", connectionListener);
    final EngineIoWebSocketImpl webSocket = new EngineIoWebSocketImpl();
    engineIoServer.handleWebSocket(webSocket);
    Mockito.verify(connectionListener, Mockito.times(1))
            .call(Mockito.any(SocketIoSocket.class));
}