@Test
public void test_sendPacket() {

    final EngineIoServer engineIoServer = new EngineIoServer();
    final SocketIoServer server = new SocketIoServer(engineIoServer);
    final SocketIoNamespaceImpl namespace = (SocketIoNamespaceImpl)server.namespace("/");
    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 SocketIoClient client = Mockito.spy(new SocketIoClient(server, (EngineIoSocket) args[0]));
        final SocketIoSocket socket = new SocketIoSocket(namespace, client);
        Mockito.doAnswer(invocationOnMock -> {
            final Packet packet = invocationOnMock.getArgument(0);
            assertNotNull(packet);
            assertEquals("/", packet.nsp);
            return null;
        }).when(client).sendPacket(Mockito.any(Packet.class));
        socket.sendPacket(new Packet(Parser.CONNECT));
        Mockito.verify(client, Mockito.times(1))
                .sendPacket(Mockito.any(Packet.class));
        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));
}