Esempio n. 1
0
        public override void runTestCase(RemoteObjectAdapterPrx adapter, TestIntfPrx proxy)
        {
            Ice.Connection con = proxy.ice_getCachedConnection();

            try
            {
                con.setACM(-19, Ice.Util.None, Ice.Util.None);
                test(false);
            }
            catch (ArgumentException)
            {
            }

            Ice.ACM acm;
            acm = con.getACM();
            test(acm.timeout == 15);
            test(acm.close == Ice.ACMClose.CloseOnIdleForceful);
            test(acm.heartbeat == Ice.ACMHeartbeat.HeartbeatOff);

            con.setACM(Ice.Util.None, Ice.Util.None, Ice.Util.None);
            acm = con.getACM();
            test(acm.timeout == 15);
            test(acm.close == Ice.ACMClose.CloseOnIdleForceful);
            test(acm.heartbeat == Ice.ACMHeartbeat.HeartbeatOff);

            con.setACM(1,
                       Ice.ACMClose.CloseOnInvocationAndIdle,
                       Ice.ACMHeartbeat.HeartbeatAlways);
            acm = con.getACM();
            test(acm.timeout == 1);
            test(acm.close == Ice.ACMClose.CloseOnInvocationAndIdle);
            test(acm.heartbeat == Ice.ACMHeartbeat.HeartbeatAlways);

            proxy.startHeartbeatCount();
            proxy.waitForHeartbeatCount(2);

            var t1 = new TaskCompletionSource <object>();

            con.setCloseCallback(_ => { t1.SetResult(null); });

            con.close(Ice.ConnectionClose.Gracefully);
            test(t1.Task.Result == null);

            try
            {
                con.throwException();
                test(false);
            }
            catch (Ice.ConnectionManuallyClosedException)
            {
            }

            var t2 = new TaskCompletionSource <object>();

            con.setCloseCallback(_ => { t2.SetResult(null); });
            test(t2.Task.Result == null);

            con.setHeartbeatCallback(_ => { test(false); });
        }