示例#1
0
    private static void initializeTests(Configuration configuration, Test.BackgroundPrx background,
                                        Test.BackgroundControllerPrx ctl)
    {
        try
        {
            background.op();
        }
        catch (Ice.LocalException)
        {
            test(false);
        }
        background.ice_getConnection().close(false);

        for (int i = 0; i < 4; ++i)
        {
            if (i == 0 || i == 2)
            {
                configuration.initializeException(new Ice.SocketException());
            }
            else
            {
                continue;
            }
            BackgroundPrx prx = (i == 1 || i == 3) ? background : (BackgroundPrx)background.ice_oneway();

            try
            {
                prx.op();
                test(false);
            }
            catch (Ice.SocketException)
            {
            }

            Ice.AsyncResult r = prx.begin_op();
            test(!r.sentSynchronously());
            try
            {
                prx.end_op(r);
                test(false);
            }
            catch (Ice.Exception)
            {
            }
            test(r.IsCompleted);

            OpAMICallback cbEx = new OpAMICallback();
            r = prx.begin_op().whenCompleted(cbEx.exception);
            test(!r.sentSynchronously());
            cbEx.checkException(true);
            test(r.IsCompleted);

            if (i == 0 || i == 2)
            {
                configuration.initializeException(null);
            }
        }

        //
        // Now run the same tests with the server side.
        //

        try
        {
            ctl.initializeException(true);
            background.op();
            test(false);
        }
        catch (Ice.ConnectionLostException)
        {
            ctl.initializeException(false);
        }
        catch (Ice.SecurityException)
        {
            ctl.initializeException(false);
        }

        OpThread thread1 = new OpThread(background);
        OpThread thread2 = new OpThread(background);

        for (int i = 0; i < 5; i++)
        {
            try
            {
                background.ice_ping();
            }
            catch (Ice.LocalException)
            {
                test(false);
            }

            configuration.initializeException(new Ice.SocketException());
            background.ice_getCachedConnection().close(true);
            Thread.Sleep(10);
            configuration.initializeException(null);
            try
            {
                background.ice_ping();
            }
            catch (Ice.LocalException)
            {
            }
            try
            {
                background.ice_ping();
            }
            catch (Ice.LocalException)
            {
                test(false);
            }

            background.ice_getCachedConnection().close(true);
            background.ice_ping();

            ctl.initializeException(true);
            background.ice_getCachedConnection().close(true);
            Thread.Sleep(10);
            ctl.initializeException(false);
            try
            {
                background.ice_ping();
            }
            catch (Ice.LocalException)
            {
            }
            try
            {
                background.ice_ping();
            }
            catch (Ice.LocalException)
            {
                test(false);
            }

            try
            {
                background.ice_getCachedConnection().close(true);
                background.op();
            }
            catch (Ice.LocalException)
            {
                test(false);
            }
        }

        thread1.destroy();
        thread2.destroy();

        thread1.Join();
        thread2.Join();
    }
示例#2
0
    private static void connectTests(Configuration configuration, Test.BackgroundPrx background)
    {
        try
        {
            background.op();
        }
        catch (Ice.LocalException ex)
        {
            System.Console.Out.WriteLine(ex);
            test(false);
        }
        background.ice_getConnection().close(false);

        for (int i = 0; i < 4; ++i)
        {
            if (i == 0 || i == 2)
            {
                configuration.connectorsException(new Ice.DNSException());
            }
            else
            {
                configuration.connectException(new Ice.SocketException());
            }
            BackgroundPrx prx = (i == 1 || i == 3) ? background : (BackgroundPrx)background.ice_oneway();

            try
            {
                prx.op();
                test(false);
            }
            catch (Ice.Exception)
            {
            }

            Ice.AsyncResult r = prx.begin_op();
            test(!r.sentSynchronously());
            try
            {
                prx.end_op(r);
                test(false);
            }
            catch (Ice.Exception)
            {
            }
            test(r.IsCompleted);

            OpAMICallback cbEx = new OpAMICallback();
            r = prx.begin_op().whenCompleted(cbEx.exception);
            test(!r.sentSynchronously());
            cbEx.checkException(true);
            test(r.IsCompleted);

            if (i == 0 || i == 2)
            {
                configuration.connectorsException(null);
            }
            else
            {
                configuration.connectException(null);
            }
        }

        OpThread thread1 = new OpThread(background);
        OpThread thread2 = new OpThread(background);

        for (int i = 0; i < 5; i++)
        {
            try
            {
                background.ice_ping();
            }
            catch (Ice.LocalException)
            {
                test(false);
            }

            configuration.connectException(new Ice.SocketException());
            background.ice_getCachedConnection().close(true);
            Thread.Sleep(10);
            configuration.connectException(null);
            try
            {
                background.ice_ping();
            }
            catch (Ice.LocalException)
            {
            }
        }

        thread1.destroy();
        thread2.destroy();

        thread1.Join();
        thread2.Join();
    }
示例#3
0
    private static void initializeTests(Configuration configuration, BackgroundPrx background,
                                        BackgroundControllerPrx ctl)
    {
        try
        {
            background.op();
        }
        catch (LocalException)
        {
            test(false);
        }
        background.GetConnection().close(ConnectionClose.GracefullyWithWait);

        for (int i = 0; i < 4; ++i)
        {
            if (i == 0 || i == 2)
            {
                configuration.initializeException(new SocketException());
            }
            else
            {
                continue;
            }
            BackgroundPrx prx = (i == 1 || i == 3) ? background : background.Clone(oneway: true);

            try
            {
                prx.op();
                test(false);
            }
            catch (SocketException)
            {
            }

            bool sentSynchronously = false;
            var  t = prx.opAsync(progress: new Progress <bool>(value =>
            {
                sentSynchronously = value;
            }));
            test(!sentSynchronously);
            try
            {
                t.Wait();
                test(false);
            }
            catch (AggregateException ex) when(ex.InnerException is Ice.Exception)
            {
            }
            test(t.IsCompleted);

            OpAMICallback cbEx = new OpAMICallback();
            t = prx.opAsync(progress: new Progress <bool>(value =>
            {
                sentSynchronously = false;
            }));
            test(!sentSynchronously);
            try
            {
                t.Wait();
            }
            catch (AggregateException ex) when(ex.InnerException is Ice.Exception)
            {
                cbEx.exception((Ice.Exception)ex.InnerException);
            }
            cbEx.checkException(true);
            test(t.IsCompleted);

            if (i == 0 || i == 2)
            {
                configuration.initializeException(null);
            }
        }

        //
        // Now run the same tests with the server side.
        //

        try
        {
            ctl.initializeException(true);
            background.op();
            test(false);
        }
        catch (ConnectionLostException)
        {
            ctl.initializeException(false);
        }
        catch (SecurityException)
        {
            ctl.initializeException(false);
        }

        OpThread thread1 = new OpThread(background);
        OpThread thread2 = new OpThread(background);

        for (int i = 0; i < 5; i++)
        {
            try
            {
                background.IcePing();
            }
            catch (LocalException)
            {
                test(false);
            }

            configuration.initializeException(new SocketException());
            background.GetCachedConnection() !.close(ConnectionClose.Forcefully);
            Thread.Sleep(10);
            configuration.initializeException(null);
            try
            {
                background.IcePing();
            }
            catch (LocalException)
            {
            }
            try
            {
                background.IcePing();
            }
            catch (LocalException)
            {
                test(false);
            }

            background.GetCachedConnection() !.close(ConnectionClose.Forcefully);
            background.IcePing();

            ctl.initializeException(true);
            background.GetCachedConnection() !.close(ConnectionClose.Forcefully);
            Thread.Sleep(10);
            ctl.initializeException(false);
            try
            {
                background.IcePing();
            }
            catch (LocalException)
            {
            }
            try
            {
                background.IcePing();
            }
            catch (LocalException)
            {
                test(false);
            }

            try
            {
                background.GetCachedConnection() !.close(ConnectionClose.Forcefully);
                background.op();
            }
            catch (LocalException)
            {
                test(false);
            }
        }

        thread1.destroy();
        thread2.destroy();

        thread1.Join();
        thread2.Join();
    }
示例#4
0
    private static void connectTests(Configuration configuration, Test.BackgroundPrx background)
    {
        try
        {
            background.op();
        }
        catch (LocalException ex)
        {
            System.Console.Out.WriteLine(ex);
            test(false);
        }
        background.GetConnection().close(ConnectionClose.GracefullyWithWait);

        for (int i = 0; i < 4; ++i)
        {
            if (i == 0 || i == 2)
            {
                configuration.connectorsException(new DNSException());
            }
            else
            {
                configuration.connectException(new SocketException());
            }
            BackgroundPrx prx = (i == 1 || i == 3) ? background : background.Clone(oneway: true);

            try
            {
                prx.op();
                test(false);
            }
            catch (Ice.Exception)
            {
            }

            var sentSynchronously = false;
            var t = prx.opAsync(progress: new Progress <bool>(value =>
            {
                sentSynchronously = value;
            }));
            test(!sentSynchronously);
            try
            {
                t.Wait();
                test(false);
            }
            catch (AggregateException ex) when(ex.InnerException is Ice.Exception)
            {
            }
            test(t.IsCompleted);

            OpAMICallback cbEx = new OpAMICallback();
            t = prx.opAsync(progress: new Progress <bool>(value =>
            {
                sentSynchronously = value;
            }));
            test(!sentSynchronously);

            t.ContinueWith((Task p) =>
            {
                try
                {
                    p.Wait();
                }
                catch (AggregateException ex) when(ex.InnerException is Ice.Exception)
                {
                    cbEx.exception((Ice.Exception)ex.InnerException);
                }
            });
            cbEx.checkException(true);
            test(t.IsCompleted);

            if (i == 0 || i == 2)
            {
                configuration.connectorsException(null);
            }
            else
            {
                configuration.connectException(null);
            }
        }

        OpThread thread1 = new OpThread(background);
        OpThread thread2 = new OpThread(background);

        try
        {
            for (int i = 0; i < 5; i++)
            {
                try
                {
                    background.IcePing();
                }
                catch (LocalException)
                {
                    test(false);
                }

                configuration.connectException(new SocketException());
                background.GetCachedConnection() !.close(ConnectionClose.Forcefully);
                Thread.Sleep(10);
                configuration.connectException(null);
                try
                {
                    background.IcePing();
                }
                catch (LocalException)
                {
                }
            }
        }
        catch (System.Exception ex)
        {
            Console.Out.WriteLine(ex);
            test(false);
        }
        finally
        {
            thread1.destroy();
            thread2.destroy();

            thread1.Join();
            thread2.Join();
        }
    }
示例#5
0
    private static void initializeTests(Configuration configuration, Test.BackgroundPrx background,
                                        Test.BackgroundControllerPrx ctl)
    {
        try
        {
            background.op();
        }
        catch(Ice.LocalException)
        {
            test(false);
        }
        background.ice_getConnection().close(false);

        for(int i = 0; i < 4; ++i)
        {
            if(i == 0 || i == 2)
            {
                configuration.initializeException(new Ice.SocketException());
            }
            else
            {
                continue;
            }
            BackgroundPrx prx = (i == 1 || i == 3) ? background : (BackgroundPrx)background.ice_oneway();

            try
            {
                prx.op();
                test(false);
            }
            catch(Ice.SocketException)
            {
            }

            Ice.AsyncResult r = prx.begin_op();
            test(!r.sentSynchronously());
            try
            {
                prx.end_op(r);
                test(false);
            }
            catch(Ice.Exception)
            {
            }
            test(r.IsCompleted);

            OpAMICallback cbEx = new OpAMICallback();
            r = prx.begin_op().whenCompleted(cbEx.exception);
            test(!r.sentSynchronously());
            cbEx.checkException(true);
            test(r.IsCompleted);

            if(i == 0 || i == 2)
            {
                configuration.initializeException(null);
            }
        }

        //
        // Now run the same tests with the server side.
        //

        try
        {
            ctl.initializeException(true);
            background.op();
            test(false);
        }
        catch(Ice.ConnectionLostException)
        {
            ctl.initializeException(false);
        }
        catch(Ice.SecurityException)
        {
            ctl.initializeException(false);
        }

        OpThread thread1 = new OpThread(background);
        OpThread thread2 = new OpThread(background);

        for(int i = 0; i < 5; i++)
        {
            try
            {
                background.ice_ping();
            }
            catch(Ice.LocalException)
            {
                test(false);
            }

            configuration.initializeException(new Ice.SocketException());
            background.ice_getCachedConnection().close(true);
            Thread.Sleep(10);
            configuration.initializeException(null);
            try
            {
                background.ice_ping();
            }
            catch(Ice.LocalException)
            {
            }
            try
            {
                background.ice_ping();
            }
            catch(Ice.LocalException)
            {
                test(false);
            }

            background.ice_getCachedConnection().close(true);
            background.ice_ping();

            ctl.initializeException(true);
            background.ice_getCachedConnection().close(true);
            Thread.Sleep(10);
            ctl.initializeException(false);
            try
            {
                background.ice_ping();
            }
            catch(Ice.LocalException)
            {
            }
            try
            {
                background.ice_ping();
            }
            catch(Ice.LocalException)
            {
                test(false);
            }

            try
            {
                background.ice_getCachedConnection().close(true);
                background.op();
            }
            catch(Ice.LocalException)
            {
                test(false);
            }
        }

        thread1.destroy();
        thread2.destroy();

        thread1.Join();
        thread2.Join();
    }
示例#6
0
    private static void connectTests(Configuration configuration, Test.BackgroundPrx background)
    {
        try
        {
            background.op();
        }
        catch(Ice.LocalException ex)
        {
            System.Console.Out.WriteLine(ex);
            test(false);
        }
        background.ice_getConnection().close(false);

        for(int i = 0; i < 4; ++i)
        {
            if(i == 0 || i == 2)
            {
                configuration.connectorsException(new Ice.DNSException());
            }
            else
            {
                configuration.connectException(new Ice.SocketException());
            }
            BackgroundPrx prx = (i == 1 || i == 3) ? background : (BackgroundPrx)background.ice_oneway();

            try
            {
                prx.op();
                test(false);
            }
            catch(Ice.Exception)
            {
            }

            Ice.AsyncResult r = prx.begin_op();
            test(!r.sentSynchronously());
            try
            {
                prx.end_op(r);
                test(false);
            }
            catch(Ice.Exception)
            {
            }
            test(r.IsCompleted);

            OpAMICallback cbEx = new OpAMICallback();
            r = prx.begin_op().whenCompleted(cbEx.exception);
            test(!r.sentSynchronously());
            cbEx.checkException(true);
            test(r.IsCompleted);

            if(i == 0 || i == 2)
            {
                configuration.connectorsException(null);
            }
            else
            {
                configuration.connectException(null);
            }
        }

        OpThread thread1 = new OpThread(background);
        OpThread thread2 = new OpThread(background);

        for(int i = 0; i < 5; i++)
        {
            try
            {
                background.ice_ping();
            }
            catch(Ice.LocalException)
            {
                test(false);
            }

            configuration.connectException(new Ice.SocketException());
            background.ice_getCachedConnection().close(true);
            Thread.Sleep(10);
            configuration.connectException(null);
            try
            {
                background.ice_ping();
            }
            catch(Ice.LocalException)
            {
            }
        }

        thread1.destroy();
        thread2.destroy();

        thread1.Join();
        thread2.Join();
    }