Example #1
0
    public static void allTests(Ice.Communicator communicator)
    {
        Console.Out.Write("testing stringToProxy... ");
        Console.Out.Flush();
        String rf = "test @ TestAdapter";
        Ice.ObjectPrx @base = communicator.stringToProxy(rf);
        test(@base != null);
        Console.Out.WriteLine("ok");

        Console.Out.Write("testing IceGrid.Locator is present... ");
        IceGrid.LocatorPrx locator = IceGrid.LocatorPrxHelper.uncheckedCast(@base);
        test(locator != null);
        Console.Out.WriteLine("ok");

        Console.Out.Write("testing checked cast... ");
        Console.Out.Flush();
        TestIntfPrx obj = TestIntfPrxHelper.checkedCast(@base);
        test(obj != null);
        test(obj.Equals(@base));
        Console.Out.WriteLine("ok");

        Console.Out.Write("pinging server... ");
        Console.Out.Flush();
        obj.ice_ping();
        Console.Out.WriteLine("ok");

        System.Console.Out.Write("shutting down server... ");
        System.Console.Out.Flush();
        obj.shutdown();
        System.Console.Out.WriteLine("ok");
    }
Example #2
0
    public static Test.MyClassPrx allTests(Ice.Communicator communicator, bool collocated)
#endif
    {
#if SILVERLIGHT
        bool collocated = false;
#endif
        Flush();
        string rf = "test:default -p 12010";
        Ice.ObjectPrx baseProxy = communicator.stringToProxy(rf);
        Test.MyClassPrx cl = Test.MyClassPrxHelper.checkedCast(baseProxy);

        Write("testing twoway operations... ");
        Flush();
        Twoways.twoways(communicator, cl);
        WriteLine("ok");

        if(!collocated)
        {
            Write("testing twoway operations with AMI... ");
            Flush();
            TwowaysAMI.twowaysAMI(communicator, cl);
            WriteLine("ok");

            Write("testing twoway operations with new AMI mapping... ");
            Flush();
            TwowaysNewAMI.twowaysAMI(communicator, cl);
            WriteLine("ok");
        }
#if SILVERLIGHT
        cl.shutdown();
#else
        return cl;
#endif
    }
Example #3
0
    public static void allTests(Ice.Communicator communicator)
    {
        string sref = "test:default -p 12010";
        Ice.ObjectPrx obj = communicator.stringToProxy(sref);
        test(obj != null);

        Test.TestIntfPrx p = Test.TestIntfPrxHelper.uncheckedCast(obj);

        sref = "testController:tcp -p 12011";
        obj = communicator.stringToProxy(sref);
        test(obj != null);

        Test.TestIntfControllerPrx testController = Test.TestIntfControllerPrxHelper.uncheckedCast(obj);

        Console.Out.Write("testing dispatcher... ");
        Console.Out.Flush();
        {
            p.op();

            Callback cb = new Callback();
            p.begin_op().whenCompleted(cb.response, cb.exception);
            cb.check();

            TestIntfPrx i = (TestIntfPrx)p.ice_adapterId("dummy");
            i.begin_op().whenCompleted(cb.exception);
            cb.check();

            testController.holdAdapter();
            Test.Callback_TestIntf_opWithPayload resp = cb.payload;
            Ice.ExceptionCallback excb = cb.ignoreEx;
            Ice.SentCallback scb = cb.sent;

            byte[] seq = new byte[10 * 1024];
            (new System.Random()).NextBytes(seq);
            Ice.AsyncResult r;
            while((r = p.begin_opWithPayload(seq).whenCompleted(resp, excb).whenSent(scb)).sentSynchronously());
            testController.resumeAdapter();
            r.waitForCompleted();
        }
        Console.Out.WriteLine("ok");

        p.shutdown();
    }
Example #4
0
 private static int run(string[] args, Ice.Communicator communicator)
 { 
     AllTests.allTests(communicator);
     
     //
     // Shutdown the IceBox server. 
     //
     Ice.ProcessPrxHelper.uncheckedCast(
         communicator.stringToProxy("DemoIceBox/admin -f Process:default -p 9996")).shutdown();
     return 0;
 }
Example #5
0
    public static Test.MyClassPrx allTests(Ice.Communicator communicator)
#endif
    {
        Flush();
        string rf = "test:default -p 12010";
        Ice.ObjectPrx baseProxy = communicator.stringToProxy(rf);
        Test.MyClassPrx cl = Test.MyClassPrxHelper.checkedCast(baseProxy);
        Test.MyDerivedClassPrx derivedProxy = Test.MyDerivedClassPrxHelper.checkedCast(cl);

        Write("testing twoway operations... ");
        Flush();
        Twoways.twoways(communicator, cl);
        Twoways.twoways(communicator, derivedProxy);
        derivedProxy.opDerived();
        WriteLine("ok");

        Write("testing oneway operations... ");
        Flush();
        Oneways.oneways(communicator, cl);
        WriteLine("ok");

        Write("testing twoway operations with AMI... ");
        Flush();
        TwowaysAMI.twowaysAMI(communicator, cl);
        TwowaysAMI.twowaysAMI(communicator, derivedProxy);
        WriteLine("ok");

        Write("testing oneway operations with AMI... ");
        Flush();
        OnewaysAMI.onewaysAMI(communicator, cl);
        WriteLine("ok");

        Write("testing batch oneway operations... ");
        Flush();
        BatchOneways.batchOneways(cl);
        BatchOneways.batchOneways(derivedProxy);
        WriteLine("ok");

        Write("testing batch AMI oneway operations... ");
        Flush();
        BatchOnewaysAMI.batchOneways(cl);
        BatchOnewaysAMI.batchOneways(derivedProxy);
        WriteLine("ok");
#if SILVERLIGHT
        cl.shutdown();
#else
        return cl;
#endif
    }
Example #6
0
    public static void allTests(Ice.Communicator communicator)
#endif
    {
        string sref = "test:default -p 12010";
        Ice.ObjectPrx obj = communicator.stringToProxy(sref);
        test(obj != null);

        Test.TestIntfPrx testPrx = Test.TestIntfPrxHelper.checkedCast(obj);
        test(testPrx != null);

        Write("testing connection... ");
        Flush();
        {
            testPrx.ice_ping();
        }
        WriteLine("ok");

        Write("testing connection information... ");
        Flush();
        {
            Ice.IPConnectionInfo info = (Ice.IPConnectionInfo)testPrx.ice_getConnection().getInfo();
            test(info.remotePort == 12030 || info.remotePort == 12031); // make sure we are connected to the proxy port.
        }
        WriteLine("ok");

        Write("shutting down server... ");
        Flush();
        {
            testPrx.shutdown();
        }
        WriteLine("ok");

        Write("testing connection failure... ");
        Flush();
        {
            try
            {
                testPrx.ice_ping();
                test(false);
            }
            catch(Ice.LocalException)
            {
            }
        }
        WriteLine("ok");
    }
Example #7
0
    public static void allTests(Ice.Communicator communicator)
    {
        string @ref = "communicator:default -p 12010";
        RemoteCommunicatorPrx com = RemoteCommunicatorPrxHelper.uncheckedCast(communicator.stringToProxy(@ref));

        List<TestCase> tests = new List<TestCase>();

        tests.Add(new InvocationHeartbeatTest(com));
        tests.Add(new InvocationHeartbeatOnHoldTest(com));
        tests.Add(new InvocationNoHeartbeatTest(com));
        tests.Add(new InvocationHeartbeatCloseOnIdleTest(com));

        tests.Add(new CloseOnIdleTest(com));
        tests.Add(new CloseOnInvocationTest(com));
        tests.Add(new CloseOnIdleAndInvocationTest(com));
        tests.Add(new ForcefulCloseOnIdleAndInvocationTest(com));

        tests.Add(new HeartbeatOnIdleTest(com));
        tests.Add(new HeartbeatAlwaysTest(com));
        tests.Add(new SetACMTest(com));

        foreach(TestCase test in tests)
        {
            test.init();
        }
        foreach(TestCase test in tests)
        {
            test.start();
        }
        foreach(TestCase test in tests)
        {
            test.join();
        }
        foreach(TestCase test in tests)
        {
            test.destroy();
        }

        Console.Out.Write("shutting down... ");
        Console.Out.Flush();
        com.shutdown();
        Console.WriteLine("ok");
    }
Example #8
0
    private static int run(string[] args, Ice.Communicator communicator)
    {
        AllTests.allTests(communicator);

        int num;
        try
        {
            num = args.Length == 1 ? System.Int32.Parse(args[0]) : 0;
        }
        catch(System.FormatException)
        {
            num = 0;
        }
        for(int i = 0; i < num; ++i)
        {
            TestIntfPrxHelper.uncheckedCast(communicator.stringToProxy("control:tcp -p " + (12010 + i))).shutdown();
        }
        return 0;
    }
Example #9
0
    public static Test.MyClassPrx allTests(Ice.Communicator communicator, bool collocated)
    {
        Flush();
        string rf = "test:default -p 12010";
        Ice.ObjectPrx baseProxy = communicator.stringToProxy(rf);
        Test.MyClassPrx cl = Test.MyClassPrxHelper.checkedCast(baseProxy);

        Write("testing twoway operations... ");
        Flush();
        Twoways.twoways(communicator, cl);
        WriteLine("ok");

        if(!collocated)
        {
            Write("testing twoway operations with AMI... ");
            Flush();
            TwowaysAMI.twowaysAMI(communicator, cl);
            WriteLine("ok");
        }
        return cl;
    }
Example #10
0
    private static int run(string[] args, Ice.Communicator communicator)
    {
        Console.Out.Write("testing server priority... ");
        Console.Out.Flush();
        Ice.ObjectPrx obj = communicator.stringToProxy("test:default -p 12010 -t 10000");
        Test.PriorityPrx priority = Test.PriorityPrxHelper.checkedCast(obj);

        try
        {
            test("AboveNormal".Equals(priority.getPriority()));
        }
        catch(Exception ex)
        {
            Console.Error.WriteLine(ex.ToString());
            test(false);
        }
        Console.Out.WriteLine("ok");

        priority.shutdown();
        return 0;
    }
Example #11
0
    public static TestIntfPrx allTests(Ice.Communicator communicator)
    {
        Console.Out.Write("testing stringToProxy... ");
        Console.Out.Flush();
        string @ref = "test:default -p 12010";
        Ice.ObjectPrx @base = communicator.stringToProxy(@ref);
        test(@base != null);
        Console.Out.WriteLine("ok");

        Console.Out.Write("testing checked cast... ");
        Console.Out.Flush();
        TestIntfPrx obj = TestIntfPrxHelper.checkedCast(@base);
        test(obj != null);
        test(obj.Equals(@base));
        Console.Out.WriteLine("ok");

        {
            Console.Out.Write("creating/destroying/recreating object adapter... ");
            Console.Out.Flush();
            Ice.ObjectAdapter adapter =
                communicator.createObjectAdapterWithEndpoints("TransientTestAdapter", "default");
            try
            {
                communicator.createObjectAdapterWithEndpoints("TransientTestAdapter", "default");
                test(false);
            }
            catch(Ice.AlreadyRegisteredException)
            {
            }
            adapter.destroy();

            //
            // Use a different port than the first adapter to avoid an "address already in use" error.
            //
            adapter = communicator.createObjectAdapterWithEndpoints("TransientTestAdapter", "default");
            adapter.destroy();
            Console.Out.WriteLine("ok");
        }

        Console.Out.Write("creating/activating/deactivating object adapter in one operation... ");
        Console.Out.Flush();
        obj.transient();
        Console.Out.WriteLine("ok");

        Console.Out.Write("deactivating object adapter in the server... ");
        Console.Out.Flush();
        obj.deactivate();
        Console.Out.WriteLine("ok");

        Console.Out.Write("testing whether server is gone... ");
        Console.Out.Flush();
        try
        {
            obj.ice_ping();
            throw new System.ApplicationException();
        }
        catch(Ice.LocalException)
        {
            Console.Out.WriteLine("ok");
        }

        return obj;
    }
Example #12
0
    allTests(Ice.Communicator communicator, bool collocated)
    {
        string rf = "test:default -p 12010";
        Ice.ObjectPrx baseProxy = communicator.stringToProxy(rf);
        test(baseProxy != null);

        Test.ChecksumPrx checksum = Test.ChecksumPrxHelper.checkedCast(baseProxy);
        test(checksum != null);

        //
        // Verify that no checksums are present for local types.
        //
        Console.Out.Write("testing checksums... ");
        Console.Out.Flush();
        foreach(KeyValuePair<string, string> entry in Ice.SliceChecksums.checksums)
        {
            string key = entry.Key;
            int pos = key.IndexOf("Local");
            test(pos == -1);
        }

        //
        // Get server's Slice checksums.
        //
        Dictionary<string, string> d = checksum.getSliceChecksums();

        //
        // Compare the checksums. For a type FooN whose name ends in an integer N,
        // we assume that the server's type does not change for N = 1, and does
        // change for N > 1.
        //
        char[] digits = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
        foreach(KeyValuePair<string, string> entry in d)
        {
            string key = entry.Key;
            int start = key.IndexOfAny(digits);
            if(start != -1)
            {
                int end = start;
                while(end < key.Length && Char.IsDigit(key[end]))
                {
                    end++;
                }
                int n = Int32.Parse(key.Substring(start, end - start));

                string value = (string)Ice.SliceChecksums.checksums[key];
                test(value != null);

                if(n <= 1)
                {
                    test(value.Equals(entry.Value));
                }
                else
                {
                    test(!value.Equals(entry.Value));
                }
            }
        }

        Console.Out.WriteLine("ok");

        return checksum;
    }
Example #13
0
    public static Test.TimeoutPrx allTests(Ice.Communicator communicator)
    {
        string sref = "timeout:default -p 12010";
        Ice.ObjectPrx obj = communicator.stringToProxy(sref);
        test(obj != null);

        Test.TimeoutPrx timeout = Test.TimeoutPrxHelper.checkedCast(obj);
        test(timeout != null);

        Write("testing connect timeout... ");
        Flush();
        {
            //
            // Expect ConnectTimeoutException.
            //
            Test.TimeoutPrx to = Test.TimeoutPrxHelper.uncheckedCast(obj.ice_timeout(100));
            timeout.holdAdapter(500);
            try
            {
                to.op();
                test(false);
            }
            catch(Ice.ConnectTimeoutException)
            {
                // Expected.
            }
        }
        {
            //
            // Expect success.
            //
            timeout.op(); // Ensure adapter is active.
            Test.TimeoutPrx to = Test.TimeoutPrxHelper.uncheckedCast(obj.ice_timeout(1000));
            timeout.holdAdapter(500);
            try
            {
                to.op();
            }
            catch(Ice.ConnectTimeoutException)
            {
                test(false);
            }
        }
        WriteLine("ok");

        // The sequence needs to be large enough to fill the write/recv buffers
        byte[] seq = new byte[2000000];

        Write("testing connection timeout... ");
        Flush();
        {
            //
            // Expect TimeoutException.
            //
            Test.TimeoutPrx to = Test.TimeoutPrxHelper.uncheckedCast(obj.ice_timeout(100));
            timeout.holdAdapter(500);
            try
            {
                to.sendData(seq);
                test(false);
            }
            catch(Ice.TimeoutException)
            {
                // Expected.
            }
        }
        {
            //
            // Expect success.
            //
            timeout.op(); // Ensure adapter is active.
            Test.TimeoutPrx to = Test.TimeoutPrxHelper.uncheckedCast(obj.ice_timeout(1000));
            timeout.holdAdapter(500);
            try
            {
                to.sendData(new byte[1000000]);
            }
            catch(Ice.TimeoutException)
            {
                test(false);
            }
        }
        WriteLine("ok");

        Write("testing invocation timeout... ");
        Flush();
        {
            Ice.Connection connection = obj.ice_getConnection();
            Test.TimeoutPrx to = Test.TimeoutPrxHelper.uncheckedCast(obj.ice_invocationTimeout(100));
            test(connection == to.ice_getConnection());
            try
            {
                to.sleep(750);
                test(false);
            }
            catch(Ice.InvocationTimeoutException)
            {
            }
            obj.ice_ping();
            to = Test.TimeoutPrxHelper.checkedCast(obj.ice_invocationTimeout(500));
            test(connection == to.ice_getConnection());
            try
            {
                to.sleep(250);
            }
            catch(Ice.InvocationTimeoutException)
            {
                test(false);
            }
            test(connection == to.ice_getConnection());
        }
        {
            //
            // Expect InvocationTimeoutException.
            //
            Test.TimeoutPrx to = Test.TimeoutPrxHelper.uncheckedCast(obj.ice_invocationTimeout(100));
            Callback cb = new Callback();
            to.begin_sleep(750).whenCompleted(
                () =>
                {
                    test(false);
                },
                (Ice.Exception ex) =>
                {
                    test(ex is Ice.InvocationTimeoutException);
                    cb.called();
                });
            cb.check();
            obj.ice_ping();
        }
        {
            //
            // Expect success.
            //
            Test.TimeoutPrx to = Test.TimeoutPrxHelper.uncheckedCast(obj.ice_invocationTimeout(500));
            Callback cb = new Callback();
            to.begin_sleep(250).whenCompleted(
                () =>
                {
                    cb.called();

                },
                (Ice.Exception ex) =>
                {
                    test(false);
                });
            cb.check();
        }
        {
            //
            // Backward compatible connection timeouts
            //
            Test.TimeoutPrx to = Test.TimeoutPrxHelper.uncheckedCast(obj.ice_invocationTimeout(-2).ice_timeout(100));
            Ice.Connection con = null;
            try
            {
                con = to.ice_getConnection();
                to.sleep(750);
                test(false);
            }
            catch(Ice.TimeoutException)
            {
                try
                {
                    con.getInfo();
                    test(false);
                }
                catch(Ice.TimeoutException)
                {
                    // Connection got closed as well.
                }
            }
            obj.ice_ping();

            try
            {
                con = to.ice_getConnection();
                to.end_sleep(to.begin_sleep(750));
                test(false);
            }
            catch(Ice.TimeoutException)
            {
                try
                {
                    con.getInfo();
                    test(false);
                }
                catch(Ice.TimeoutException)
                {
                    // Connection got closed as well.
                }
            }
            obj.ice_ping();
        }
        WriteLine("ok");

        Write("testing close timeout... ");
        Flush();
        {
            Test.TimeoutPrx to = Test.TimeoutPrxHelper.checkedCast(obj.ice_timeout(100));
            Ice.Connection connection = to.ice_getConnection();
            timeout.holdAdapter(500);
            connection.close(false);
            try
            {
                connection.getInfo(); // getInfo() doesn't throw in the closing state.
            }
            catch(Ice.LocalException)
            {
                test(false);
            }
            Thread.Sleep(500);
            try
            {
                connection.getInfo();
                test(false);
            }
            catch(Ice.CloseConnectionException)
            {
                // Expected.
            }
            timeout.op(); // Ensure adapter is active.
        }
        WriteLine("ok");

        Write("testing timeout overrides... ");
        Flush();
        {
            //
            // Test Ice.Override.Timeout. This property overrides all
            // endpoint timeouts.
            //
            string[] args = new string[0];
            Ice.InitializationData initData = new Ice.InitializationData();
            initData.properties = communicator.getProperties().ice_clone_();
            initData.properties.setProperty("Ice.Override.Timeout", "250");
            Ice.Communicator comm = Ice.Util.initialize(ref args, initData);
            Test.TimeoutPrx to = Test.TimeoutPrxHelper.checkedCast(comm.stringToProxy(sref));
            timeout.holdAdapter(700);
            try
            {
                to.sendData(seq);
                test(false);
            }
            catch(Ice.TimeoutException)
            {
                // Expected.
            }
            //
            // Calling ice_timeout() should have no effect.
            //
            timeout.op(); // Ensure adapter is active.
            to = Test.TimeoutPrxHelper.checkedCast(to.ice_timeout(1000));
            timeout.holdAdapter(500);
            try
            {
                to.sendData(seq);
                test(false);
            }
            catch(Ice.TimeoutException)
            {
                // Expected.
            }
            comm.destroy();
        }
        {
            //
            // Test Ice.Override.ConnectTimeout.
            //
            string[] args = new string[0];
            Ice.InitializationData initData = new Ice.InitializationData();
            initData.properties = communicator.getProperties().ice_clone_();
            initData.properties.setProperty("Ice.Override.ConnectTimeout", "250");
            Ice.Communicator comm = Ice.Util.initialize(ref args, initData);
            timeout.holdAdapter(750);
            Test.TimeoutPrx to = Test.TimeoutPrxHelper.uncheckedCast(comm.stringToProxy(sref));
            try
            {
                to.op();
                test(false);
            }
            catch(Ice.ConnectTimeoutException)
            {
                // Expected.
            }
            //
            // Calling ice_timeout() should have no effect on the connect timeout.
            //
            timeout.op(); // Ensure adapter is active.
            timeout.holdAdapter(750);
            to = Test.TimeoutPrxHelper.uncheckedCast(to.ice_timeout(1000));
            try
            {
                to.op();
                test(false);
            }
            catch(Ice.ConnectTimeoutException)
            {
                // Expected.
            }
            //
            // Verify that timeout set via ice_timeout() is still used for requests.
            //
            timeout.op(); // Ensure adapter is active.
            to = Test.TimeoutPrxHelper.uncheckedCast(to.ice_timeout(250));
            to.ice_getConnection(); // Establish connection.
            timeout.holdAdapter(750);
            try
            {
                to.sendData(seq);
                test(false);
            }
            catch(Ice.TimeoutException)
            {
                // Expected.
            }
            comm.destroy();
        }
        {
            //
            // Test Ice.Override.CloseTimeout.
            //
            Ice.InitializationData initData = new Ice.InitializationData();
            initData.properties = communicator.getProperties().ice_clone_();
            initData.properties.setProperty("Ice.Override.CloseTimeout", "100");
            Ice.Communicator comm = Ice.Util.initialize(initData);
            comm.stringToProxy(sref).ice_getConnection();
            timeout.holdAdapter(800);
            long begin = System.DateTime.Now.Ticks;
            comm.destroy();
            test(((long)new System.TimeSpan(System.DateTime.Now.Ticks - begin).TotalMilliseconds - begin) < 700);
        }
        WriteLine("ok");

        Write("testing invocation timeouts with collocated calls... ");
        Flush();
        {
            communicator.getProperties().setProperty("TimeoutCollocated.AdapterId", "timeoutAdapter");

            Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TimeoutCollocated");
            adapter.activate();

            Test.TimeoutPrx proxy = Test.TimeoutPrxHelper.uncheckedCast(adapter.addWithUUID(new TimeoutI()));
            proxy = (Test.TimeoutPrx)proxy.ice_invocationTimeout(100);
            try
            {
                proxy.sleep(500);
                test(false);
            }
            catch(Ice.InvocationTimeoutException)
            {
            }

            try
            {
                proxy.end_sleep(proxy.begin_sleep(500));
                test(false);
            }
            catch(Ice.InvocationTimeoutException)
            {
            }

            Test.TimeoutPrx batchTimeout = (Test.TimeoutPrx)proxy.ice_batchOneway();
            batchTimeout.ice_ping();
            batchTimeout.ice_ping();
            batchTimeout.ice_ping();

            ((Test.TimeoutPrx)proxy.ice_invocationTimeout(-1)).begin_sleep(300); // Keep the server thread pool busy.
            try
            {
                batchTimeout.ice_flushBatchRequests();
                test(false);
            }
            catch(Ice.InvocationTimeoutException)
            {
            }

            batchTimeout.ice_ping();
            batchTimeout.ice_ping();
            batchTimeout.ice_ping();

            ((Test.TimeoutPrx)proxy.ice_invocationTimeout(-1)).begin_sleep(300); // Keep the server thread pool busy.
            try
            {
                batchTimeout.end_ice_flushBatchRequests(batchTimeout.begin_ice_flushBatchRequests());
                test(false);
            }
            catch(Ice.InvocationTimeoutException)
            {
            }

            adapter.destroy();
        }
        WriteLine("ok");
        return timeout;
    }
Example #14
0
    public static void allTests(Ice.Communicator communicator)
    {
        string @ref = "DemoIceBox/admin:default -p 9996 -t 10000";
        Ice.ObjectPrx admin = communicator.stringToProxy(@ref);

        TestFacetPrx facet = null;

        Console.Out.Write("testing custom facet... ");
        Console.Out.Flush();
        {
            //
            // Test: Verify that the custom facet is present.
            //
            facet = TestFacetPrxHelper.checkedCast(admin, "TestFacet");
            facet.ice_ping();
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("testing properties facet... ");
        Console.Out.Flush();
        {
            Ice.PropertiesAdminPrx pa =
                Ice.PropertiesAdminPrxHelper.checkedCast(admin, "IceBox.Service.TestService.Properties");

            //
            // Test: PropertiesAdmin::getProperty()
            //
            test(pa.getProperty("Prop1").Equals("1"));
            test(pa.getProperty("Bogus").Equals(""));

            //
            // Test: PropertiesAdmin::getProperties()
            //
            Dictionary<string, string> pd = pa.getPropertiesForPrefix("");
            test(pd.Count == 6);
            test(pd["Prop1"].Equals("1"));
            test(pd["Prop2"].Equals("2"));
            test(pd["Prop3"].Equals("3"));
            test(pd["Ice.Config"].Equals("config.service"));
            test(pd["Ice.ProgramName"].Equals("IceBox-TestService"));
            test(pd["Ice.Admin.Enabled"].Equals("1"));

            Dictionary<string, string> changes;

            //
            // Test: PropertiesAdmin::setProperties()
            //
            Dictionary<string, string> setProps = new Dictionary<string, string>();
            setProps.Add("Prop1", "10"); // Changed
            setProps.Add("Prop2", "20"); // Changed
            setProps.Add("Prop3", ""); // Removed
            setProps.Add("Prop4", "4"); // Added
            setProps.Add("Prop5", "5"); // Added
            pa.setProperties(setProps);
            test(pa.getProperty("Prop1").Equals("10"));
            test(pa.getProperty("Prop2").Equals("20"));
            test(pa.getProperty("Prop3").Equals(""));
            test(pa.getProperty("Prop4").Equals("4"));
            test(pa.getProperty("Prop5").Equals("5"));
            changes = facet.getChanges();
            test(changes.Count == 5);
            test(changes["Prop1"].Equals("10"));
            test(changes["Prop2"].Equals("20"));
            test(changes["Prop3"].Equals(""));
            test(changes["Prop4"].Equals("4"));
            test(changes["Prop5"].Equals("5"));
            pa.setProperties(setProps);
            changes = facet.getChanges();
            test(changes.Count == 0);
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("testing metrics admin facet... ");
        Console.Out.Flush();
        {
            IceMX.MetricsAdminPrx ma = 
                IceMX.MetricsAdminPrxHelper.checkedCast(admin, "IceBox.Service.TestService.Metrics");

            Ice.PropertiesAdminPrx pa =
                Ice.PropertiesAdminPrxHelper.checkedCast(admin, "IceBox.Service.TestService.Properties");

            string[] views;
            string[] disabledViews;
            views = ma.getMetricsViewNames(out disabledViews);
            test(views.Length == 0);

            Dictionary<string, string> setProps = new Dictionary<string, string>();
            setProps.Add("IceMX.Metrics.Debug.GroupBy", "id");
            setProps.Add("IceMX.Metrics.All.GroupBy", "none");
            setProps.Add("IceMX.Metrics.Parent.GroupBy", "parent");
            pa.setProperties(setProps);
            pa.setProperties(new Dictionary<string, string>());

            views = ma.getMetricsViewNames(out disabledViews);
            test(views.Length == 3);
        
            // Make sure that the IceBox communicator metrics admin is a separate instance.
            test(IceMX.MetricsAdminPrxHelper.checkedCast(admin, 
                                                         "Metrics").getMetricsViewNames(out disabledViews).Length == 0);
        }
        Console.Out.WriteLine("ok");
    }
Example #15
0
    internal static void twoways(Ice.Communicator communicator, Test.MyClassPrx p)
    {
        {
            byte[] i = new byte[_length];
            for(int c = 0; c < _length; ++c)
            {
                i[c] = (byte)c;
            }
            byte[] o;
            byte[] r;

            r = p.opAByteS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            List<byte> i = new List<byte>(_length);
            for(int c = 0; c < _length; ++c)
            {
                i.Add((byte)c);
            }
            List<byte> o;
            List<byte> r;

            r = p.opLByteS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            LinkedList<byte> i = new LinkedList<byte>();
            for(int c = 0; c < _length; ++c)
            {
                i.AddLast((byte)c);
            }
            LinkedList<byte> o;
            LinkedList<byte> r;

            r = p.opKByteS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            Queue<byte> i = new Queue<byte>();
            for(int c = 0; c < _length; ++c)
            {
                i.Enqueue((byte)c);
            }
            Queue<byte> o;
            Queue<byte> r;

            r = p.opQByteS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            Stack<byte> i = new Stack<byte>();
            for(int c = 0; c < _length; ++c)
            {
                i.Push((byte)c);
            }
            Stack<byte> o;
            Stack<byte> r;

            r = p.opSByteS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            CByteS i = new CByteS(_length);
            for(int c = 0; c < _length; ++c)
            {
                i.Add((byte)c);
            }
            CByteS o;
            CByteS r;

            r = p.opCByteS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            bool[] i = new bool[_length];
            for(int c = 0; c < _length; ++c)
            {
                i[c] = c % 1 == 1;
            }
            bool[] o;
            bool[] r;

            r = p.opABoolS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            List<bool> i = new List<bool>(_length);
            for(int c = 0; c < _length; ++c)
            {
                i.Add(c % 1 == 1);
            }
            List<bool> o;
            List<bool> r;

            r = p.opLBoolS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            LinkedList<bool> i = new LinkedList<bool>();
            for(int c = 0; c < _length; ++c)
            {
                i.AddLast(c % 1 == 1);
            }
            LinkedList<bool> o;
            LinkedList<bool> r;

            r = p.opKBoolS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            Queue<bool> i = new Queue<bool>();
            for(int c = 0; c < _length; ++c)
            {
                i.Enqueue(c % 1 == 1);
            }
            Queue<bool> o;
            Queue<bool> r;

            r = p.opQBoolS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            Stack<bool> i = new Stack<bool>();
            for(int c = 0; c < _length; ++c)
            {
                i.Push(c % 1 == 1);
            }
            Stack<bool> o;
            Stack<bool> r;

            r = p.opSBoolS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            CBoolS i = new CBoolS(_length);
            for(int c = 0; c < _length; ++c)
            {
                i.Add(c % 1 == 1);
            }
            CBoolS o;
            CBoolS r;

            r = p.opCBoolS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            short[] i = new short[_length];
            for(int c = 0; c < _length; ++c)
            {
                i[c] = (short)c;
            }
            short[] o;
            short[] r;

            {
                r = p.opAShortS(i, out o);
            }
            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            List<short> i = new List<short>(_length);
            for(int c = 0; c < _length; ++c)
            {
                i.Add((short)c);
            }
            List<short> o;
            List<short> r;

            r = p.opLShortS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            LinkedList<short> i = new LinkedList<short>();
            for(int c = 0; c < _length; ++c)
            {
                i.AddLast((short)c);
            }
            LinkedList<short> o;
            LinkedList<short> r;

            r = p.opKShortS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            Queue<short> i = new Queue<short>();
            for(int c = 0; c < _length; ++c)
            {
                i.Enqueue((short)c);
            }
            Queue<short> o;
            Queue<short> r;

            r = p.opQShortS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            Stack<short> i = new Stack<short>();
            for(int c = 0; c < _length; ++c)
            {
                i.Push((short)c);
            }
            Stack<short> o;
            Stack<short> r;

            r = p.opSShortS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            CShortS i = new CShortS(_length);
            for(int c = 0; c < _length; ++c)
            {
                i.Add((short)c);
            }
            CShortS o;
            CShortS r;

            r = p.opCShortS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            int[] i = new int[_length];
            for(int c = 0; c < _length; ++c)
            {
                i[c] = (int)c;
            }
            int[] o;
            int[] r;

            r = p.opAIntS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            List<int> i = new List<int>(_length);
            for(int c = 0; c < _length; ++c)
            {
                i.Add((int)c);
            }
            List<int> o;
            List<int> r;

            r = p.opLIntS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            LinkedList<int> i = new LinkedList<int>();
            for(int c = 0; c < _length; ++c)
            {
                i.AddLast((int)c);
            }
            LinkedList<int> o;
            LinkedList<int> r;

            r = p.opKIntS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            Queue<int> i = new Queue<int>();
            for(int c = 0; c < _length; ++c)
            {
                i.Enqueue((int)c);
            }
            Queue<int> o;
            Queue<int> r;

            r = p.opQIntS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            Stack<int> i = new Stack<int>();
            for(int c = 0; c < _length; ++c)
            {
                i.Push((int)c);
            }
            Stack<int> o;
            Stack<int> r;

            r = p.opSIntS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            CIntS i = new CIntS(_length);
            for(int c = 0; c < _length; ++c)
            {
                i.Add((int)c);
            }
            CIntS o;
            CIntS r;

            r = p.opCIntS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            long[] i = new long[_length];
            for(int c = 0; c < _length; ++c)
            {
                i[c] = (long)c;
            }
            long[] o;
            long[] r;

            r = p.opALongS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            List<long> i = new List<long>(_length);
            for(int c = 0; c < _length; ++c)
            {
                i.Add((long)c);
            }
            List<long> o;
            List<long> r;

            r = p.opLLongS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            LinkedList<long> i = new LinkedList<long>();
            for(int c = 0; c < _length; ++c)
            {
                i.AddLast((long)c);
            }
            LinkedList<long> o;
            LinkedList<long> r;

            r = p.opKLongS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            Queue<long> i = new Queue<long>();
            for(int c = 0; c < _length; ++c)
            {
                i.Enqueue((long)c);
            }
            Queue<long> o;
            Queue<long> r;

            r = p.opQLongS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            Stack<long> i = new Stack<long>();
            for(int c = 0; c < _length; ++c)
            {
                i.Push((long)c);
            }
            Stack<long> o;
            Stack<long> r;

            r = p.opSLongS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            CLongS i = new CLongS(_length);
            for(int c = 0; c < _length; ++c)
            {
                i.Add((long)c);
            }
            CLongS o;
            CLongS r;

            r = p.opCLongS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            float[] i = new float[_length];
            for(int c = 0; c < _length; ++c)
            {
                i[c] = (float)c;
            }
            float[] o;
            float[] r;

            r = p.opAFloatS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            List<float> i = new List<float>(_length);
            for(int c = 0; c < _length; ++c)
            {
                i.Add((float)c);
            }
            List<float> o;
            List<float> r;

            r = p.opLFloatS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            LinkedList<float> i = new LinkedList<float>();
            for(int c = 0; c < _length; ++c)
            {
                i.AddLast((float)c);
            }
            LinkedList<float> o;
            LinkedList<float> r;

            r = p.opKFloatS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            Queue<float> i = new Queue<float>();
            for(int c = 0; c < _length; ++c)
            {
                i.Enqueue((float)c);
            }
            Queue<float> o;
            Queue<float> r;

            r = p.opQFloatS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            Stack<float> i = new Stack<float>();
            for(int c = 0; c < _length; ++c)
            {
                i.Push((float)c);
            }
            Stack<float> o;
            Stack<float> r;

            r = p.opSFloatS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            CFloatS i = new CFloatS(_length);
            for(int c = 0; c < _length; ++c)
            {
                i.Add((float)c);
            }
            CFloatS o;
            CFloatS r;

            r = p.opCFloatS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            double[] i = new double[_length];
            for(int c = 0; c < _length; ++c)
            {
                i[c] = (double)c;
            }
            double[] o;
            double[] r;

            r = p.opADoubleS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            List<double> i = new List<double>(_length);
            for(int c = 0; c < _length; ++c)
            {
                i.Add((double)c);
            }
            List<double> o;
            List<double> r;

            r = p.opLDoubleS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            LinkedList<double> i = new LinkedList<double>();
            for(int c = 0; c < _length; ++c)
            {
                i.AddLast((double)c);
            }
            LinkedList<double> o;
            LinkedList<double> r;

            r = p.opKDoubleS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            Queue<double> i = new Queue<double>();
            for(int c = 0; c < _length; ++c)
            {
                i.Enqueue((double)c);
            }
            Queue<double> o;
            Queue<double> r;

            r = p.opQDoubleS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            Stack<double> i = new Stack<double>();
            for(int c = 0; c < _length; ++c)
            {
                i.Push((double)c);
            }
            Stack<double> o;
            Stack<double> r;

            r = p.opSDoubleS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            CDoubleS i = new CDoubleS(_length);
            for(int c = 0; c < _length; ++c)
            {
                i.Add((double)c);
            }
            CDoubleS o;
            CDoubleS r;

            r = p.opCDoubleS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            string[] i = new string[_length];
            for(int c = 0; c < _length; ++c)
            {
                i[c] = c.ToString();
            }
            string[] o;
            string[] r;

            r = p.opAStringS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            List<string> i = new List<string>(_length);
            for(int c = 0; c < _length; ++c)
            {
                i.Add(c.ToString());
            }
            List<string> o;
            List<string> r;

            r = p.opLStringS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            LinkedList<string> i = new LinkedList<string>();
            for(int c = 0; c < _length; ++c)
            {
                i.AddLast(c.ToString());
            }
            LinkedList<string> o;
            LinkedList<string> r;

            r = p.opKStringS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            Queue<string> i = new Queue<string>();
            for(int c = 0; c < _length; ++c)
            {
                i.Enqueue(c.ToString());
            }
            Queue<string> o;
            Queue<string> r;

            r = p.opQStringS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            Stack<string> i = new Stack<string>();
            for(int c = 0; c < _length; ++c)
            {
                i.Push(c.ToString());
            }
            Stack<string> o;
            Stack<string> r;

            r = p.opSStringS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            CStringS i = new CStringS(_length);
            for(int c = 0; c < _length; ++c)
            {
                i.Add(c.ToString());
            }
            CStringS o;
            CStringS r;

            r = p.opCStringS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            Ice.Object[] i = new CV[_length];
            for(int c = 0; c < _length; ++c)
            {
                i[c] = new CV(c);
            }
            Ice.Object[] o;
            Ice.Object[] r;

            r = p.opAObjectS(i, out o);

            System.Collections.IEnumerator eo = o.GetEnumerator();
            System.Collections.IEnumerator er = r.GetEnumerator();
            foreach(CV obj in i)
            {
                eo.MoveNext();
                er.MoveNext();
                test(obj.i == ((CV)eo.Current).i);
                test(obj.i == ((CV)er.Current).i);
            }
        }

        {
            List<Ice.Object> i = new List<Ice.Object>(_length);
            for(int c = 0; c < _length; ++c)
            {
                i.Add(new CV(c));
            }
            List<Ice.Object> o;
            List<Ice.Object> r;

            r = p.opLObjectS(i, out o);

            IEnumerator<Ice.Object> eo = o.GetEnumerator();
            IEnumerator<Ice.Object> er = r.GetEnumerator();
            foreach(CV obj in i)
            {
                eo.MoveNext();
                er.MoveNext();
                test(obj.i == ((CV)eo.Current).i);
                test(obj.i == ((CV)er.Current).i);
            }
        }

        {
            CObjectS i = new CObjectS(_length);
            for(int c = 0; c < _length; ++c)
            {
                i.Add(new CV(c));
            }
            CObjectS o;
            CObjectS r;

            r = p.opCObjectS(i, out o);

            IEnumerator<Ice.Object> eo = (IEnumerator<Ice.Object>)o.GetEnumerator();
            IEnumerator<Ice.Object> er = (IEnumerator<Ice.Object>)r.GetEnumerator();
            foreach(CV obj in i)
            {
                eo.MoveNext();
                er.MoveNext();
                test(obj.i == ((CV)eo.Current).i);
                test(obj.i == ((CV)er.Current).i);
            }
        }

        {
            Ice.ObjectPrx[] i = new Ice.ObjectPrx[_length];
            for(int c = 0; c < _length; ++c)
            {
                i[c] = communicator.stringToProxy(c.ToString());
            }
            Ice.ObjectPrx[] o;
            Ice.ObjectPrx[] r;

            r = p.opAObjectPrxS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            List<Ice.ObjectPrx> i = new List<Ice.ObjectPrx>(_length);
            for(int c = 0; c < _length; ++c)
            {
                i.Add(communicator.stringToProxy(c.ToString()));
            }
            List<Ice.ObjectPrx> o;
            List<Ice.ObjectPrx> r;

            r = p.opLObjectPrxS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            LinkedList<Ice.ObjectPrx> i = new LinkedList<Ice.ObjectPrx>();
            for(int c = 0; c < _length; ++c)
            {
                i.AddLast(communicator.stringToProxy(c.ToString()));
            }
            LinkedList<Ice.ObjectPrx> o;
            LinkedList<Ice.ObjectPrx> r;

            r = p.opKObjectPrxS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            Queue<Ice.ObjectPrx> i = new Queue<Ice.ObjectPrx>();
            for(int c = 0; c < _length; ++c)
            {
                i.Enqueue(communicator.stringToProxy(c.ToString()));
            }
            Queue<Ice.ObjectPrx> o;
            Queue<Ice.ObjectPrx> r;

            r = p.opQObjectPrxS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            Stack<Ice.ObjectPrx> i = new Stack<Ice.ObjectPrx>();
            for(int c = 0; c < _length; ++c)
            {
                i.Push(communicator.stringToProxy(c.ToString()));
            }
            Stack<Ice.ObjectPrx> o;
            Stack<Ice.ObjectPrx> r;

            r = p.opSObjectPrxS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            CObjectPrxS i = new CObjectPrxS(_length);
            for(int c = 0; c < _length; ++c)
            {
                i.Add(communicator.stringToProxy(c.ToString()));
            }
            CObjectPrxS o;
            CObjectPrxS r;

            r = p.opCObjectPrxS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            S[] i = new S[_length];
            for(int c = 0; c < _length; ++c)
            {
                i[c].i = c;
            }
            S[] o;
            S[] r;

            r = p.opAStructS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            List<S> i = new List<S>(_length);
            for(int c = 0; c < _length; ++c)
            {
                i.Add(new S(c));
            }
            List<S> o;
            List<S> r;

            r = p.opLStructS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            LinkedList<S> i = new LinkedList<S>();
            for(int c = 0; c < _length; ++c)
            {
                i.AddLast(new S(c));
            }
            LinkedList<S> o;
            LinkedList<S> r;

            r = p.opKStructS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            Queue<S> i = new Queue<S>();
            for(int c = 0; c < _length; ++c)
            {
                i.Enqueue(new S(c));
            }
            Queue<S> o;
            Queue<S> r;

            r = p.opQStructS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            Stack<S> i = new Stack<S>();
            for(int c = 0; c < _length; ++c)
            {
                i.Push(new S(c));
            }
            Stack<S> o;
            Stack<S> r;


            r = p.opSStructS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            CStructS i = new CStructS(_length);
            for(int c = 0; c < _length; ++c)
            {
                i.Add(new S(c));
            }
            CStructS o;
            CStructS r;

            r = p.opCStructS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            SD[] i = new SD[_length];
            for(int c = 0; c < _length; ++c)
            {
                i[c] = new SD(c);
            }
            SD[] o;
            SD[] r;

            r = p.opAStructSD(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            List<SD> i = new List<SD>(_length);
            for(int c = 0; c < _length; ++c)
            {
                i.Add(new SD(c));
            }
            List<SD> o;
            List<SD> r;

            r = p.opLStructSD(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            LinkedList<SD> i = new LinkedList<SD>();
            for(int c = 0; c < _length; ++c)
            {
                i.AddLast(new SD(c));
            }
            LinkedList<SD> o;
            LinkedList<SD> r;

            r = p.opKStructSD(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            Queue<SD> i = new Queue<SD>();
            for(int c = 0; c < _length; ++c)
            {
                i.Enqueue(new SD(c));
            }
            Queue<SD> o;
            Queue<SD> r;

            r = p.opQStructSD(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            Stack<SD> i = new Stack<SD>();
            for(int c = 0; c < _length; ++c)
            {
                i.Push(new SD(c));
            }
            Stack<SD> o;
            Stack<SD> r;


            r = p.opSStructSD(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            CStructSD i = new CStructSD(_length);
            for(int c = 0; c < _length; ++c)
            {
                i.Add(new SD(c));
            }
            CStructSD o;
            CStructSD r;

            r = p.opCStructSD(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            CV[] i = new CV[_length];
            for(int c = 0; c < _length; ++c)
            {
                i[c] = new CV(c);
            }
            CV[] o;
            CV[] r;

            r = p.opACVS(i, out o);

            System.Collections.IEnumerator eo = o.GetEnumerator();
            System.Collections.IEnumerator er = r.GetEnumerator();
            foreach(CV obj in i)
            {
                eo.MoveNext();
                er.MoveNext();
                test(obj.i == ((CV)eo.Current).i);
                test(obj.i == ((CV)er.Current).i);
            }
        }

        {
            List<CV> i = new List<CV>(_length);
            for(int c = 0; c < _length; ++c)
            {
                i.Add(new CV(c));
            }
            List<CV> o;
            List<CV> r;

            r = p.opLCVS(i, out o);

            IEnumerator<CV> eo = o.GetEnumerator();
            IEnumerator<CV> er = r.GetEnumerator();
            foreach(CV obj in i)
            {
                eo.MoveNext();
                er.MoveNext();
                test(obj.i == eo.Current.i);
                test(obj.i == er.Current.i);
            }
        }

        {
            CCVS i = new CCVS(_length);
            for(int c = 0; c < _length; ++c)
            {
                i.Add(new CV(c));
            }
            CCVS o;
            CCVS r;

            r = p.opCCVS(i, out o);

            IEnumerator<CV> eo = (IEnumerator<CV>)o.GetEnumerator();
            IEnumerator<CV> er = (IEnumerator<CV>)r.GetEnumerator();
            foreach(CV obj in i)
            {
                eo.MoveNext();
                er.MoveNext();
                test(obj.i == eo.Current.i);
                test(obj.i == er.Current.i);
            }
        }

        {
            CR[] i = new CR[_length];
            for(int c = 0; c < _length; ++c)
            {
                i[c] = new CR(new CV(c));
            }
            CR[] o;
            CR[] r;

            r = p.opACRS(i, out o);

            System.Collections.IEnumerator eo = o.GetEnumerator();
            System.Collections.IEnumerator er = r.GetEnumerator();
            foreach(CR obj in i)
            {
                eo.MoveNext();
                er.MoveNext();
                test(obj.v.i == ((CR)eo.Current).v.i);
                test(obj.v.i == ((CR)er.Current).v.i);
            }
        }

        {
            List<CR> i = new List<CR>(_length);
            for(int c = 0; c < _length; ++c)
            {
                i.Add(new CR(new CV(c)));
            }
            List<CR> o;
            List<CR> r;

            r = p.opLCRS(i, out o);

            IEnumerator<CR> eo = o.GetEnumerator();
            IEnumerator<CR> er = r.GetEnumerator();
            foreach(CR obj in i)
            {
                eo.MoveNext();
                er.MoveNext();
                test(obj.v.i == eo.Current.v.i);
                test(obj.v.i == er.Current.v.i);
            }
        }

        {
            CCRS i = new CCRS(_length);
            for(int c = 0; c < _length; ++c)
            {
                i.Add(new CR(new CV(c)));
            }
            CCRS o;
            CCRS r;

            r = p.opCCRS(i, out o);

            IEnumerator<CR> eo = (IEnumerator<CR>)o.GetEnumerator();
            IEnumerator<CR> er = (IEnumerator<CR>)r.GetEnumerator();
            foreach(CR obj in i)
            {
                eo.MoveNext();
                er.MoveNext();
                test(obj.v.i == eo.Current.v.i);
                test(obj.v.i == er.Current.v.i);
            }
        }

        {
            En[] i = new En[_length];
            for(int c = 0; c < _length; ++c)
            {
                i[c] = (En)(c % 3);
            }
            En[] o;
            En[] r;

            r = p.opAEnS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            List<En> i = new List<En>(_length);
            for(int c = 0; c < _length; ++c)
            {
                i.Add((En)(c % 3));
            }
            List<En> o;
            List<En> r;

            r = p.opLEnS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            LinkedList<En> i = new LinkedList<En>();
            for(int c = 0; c < _length; ++c)
            {
                i.AddLast((En)(c % 3));
            }
            LinkedList<En> o;
            LinkedList<En> r;

            r = p.opKEnS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            Queue<En> i = new Queue<En>();
            for(int c = 0; c < _length; ++c)
            {
                i.Enqueue((En)(c % 3));
            }
            Queue<En> o;
            Queue<En> r;

            r = p.opQEnS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            Stack<En> i = new Stack<En>();
            for(int c = 0; c < _length; ++c)
            {
                i.Push((En)(c % 3));
            }
            Stack<En> o;
            Stack<En> r;

            r = p.opSEnS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            CEnS i = new CEnS(_length);
            for(int c = 0; c < _length; ++c)
            {
                i.Add((En)(c % 3));
            }
            CEnS o;
            CEnS r;

            r = p.opCEnS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            CVPrx[] i = new CVPrx[_length];
            for(int c = 0; c < _length; ++c)
            {
                i[c] = CVPrxHelper.uncheckedCast(communicator.stringToProxy(c.ToString()));
            }
            CVPrx[] o;
            CVPrx[] r;

            r = p.opACVPrxS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            List<CVPrx> i = new List<CVPrx>(_length);
            for(int c = 0; c < _length; ++c)
            {
                i.Add(CVPrxHelper.uncheckedCast(communicator.stringToProxy(c.ToString())));
            }
            List<CVPrx> o;
            List<CVPrx> r;

            r = p.opLCVPrxS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            LinkedList<CVPrx> i = new LinkedList<CVPrx>();
            for(int c = 0; c < _length; ++c)
            {
                i.AddLast(CVPrxHelper.uncheckedCast(communicator.stringToProxy(c.ToString())));
            }
            LinkedList<CVPrx> o;
            LinkedList<CVPrx> r;

            r = p.opKCVPrxS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            Queue<CVPrx> i = new Queue<CVPrx>();
            for(int c = 0; c < _length; ++c)
            {
                i.Enqueue(CVPrxHelper.uncheckedCast(communicator.stringToProxy(c.ToString())));
            }
            Queue<CVPrx> o;
            Queue<CVPrx> r;

            r = p.opQCVPrxS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            Stack<CVPrx> i = new Stack<CVPrx>();
            for(int c = 0; c < _length; ++c)
            {
                i.Push(CVPrxHelper.uncheckedCast(communicator.stringToProxy(c.ToString())));
            }
            Stack<CVPrx> o;
            Stack<CVPrx> r;

            r = p.opSCVPrxS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            CCVPrxS i = new CCVPrxS(_length);
            for(int c = 0; c < _length; ++c)
            {
                i.Add(CVPrxHelper.uncheckedCast(communicator.stringToProxy(c.ToString())));
            }
            CCVPrxS o;
            CCVPrxS r;

            r = p.opCCVPrxS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            Custom<int> i = new Custom<int>();
            for(int c = 0; c < _length; ++c)
            {
                i.Add(c);
            }
            Custom<int> o;
            Custom<int> r;

            r = p.opCustomIntS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            Custom<CV> i = new Custom<CV>();
            for(int c = 0; c < _length; ++c)
            {
                i.Add(new CV(c));
            }
            i.Add(null);
            Custom<CV> o;
            Custom<CV> r;

            r = p.opCustomCVS(i, out o);

            IEnumerator<CV> eo = (IEnumerator<CV>)o.GetEnumerator();
            IEnumerator<CV> er = (IEnumerator<CV>)r.GetEnumerator();
            foreach(CV obj in i)
            {
                eo.MoveNext();
                er.MoveNext();
                if(obj == null)
                {
                    test(eo.Current == null);
                    test(er.Current == null);
                }
                else
                {
                    test(obj.i == eo.Current.i);
                    test(obj.i == er.Current.i);
                }
            }
        }

        {
            Custom<Custom<int>> i = new Custom<Custom<int>>();
            for(int c = 0; c < _length; ++c)
            {
                Custom<int> inner = new Custom<int>();
                for(int j = 0; j < c; ++j)
                {
                    inner.Add(j);
                }
                i.Add(inner);
            }
            Custom<Custom<int>> o;
            Custom<Custom<int>> r;

            r = p.opCustomIntSS(i, out o);

            test(Ice.CollectionComparer.Equals(i, o));
            test(Ice.CollectionComparer.Equals(i, r));
        }

        {
            Custom<Custom<CV>> i = new Custom<Custom<CV>>();
            for(int c = 0; c < _length; ++c)
            {
                Custom<CV> inner = new Custom<CV>();
                for(int j = 0; j < c; ++j)
                {
                    inner.Add(new CV(j));
                }
                i.Add(inner);
            }
            Custom<Custom<CV>> o;
            Custom<Custom<CV>> r;

            r = p.opCustomCVSS(i, out o);

            IEnumerator<Custom<CV>> eo = (IEnumerator<Custom<CV>>)o.GetEnumerator();
            IEnumerator<Custom<CV>> er = (IEnumerator<Custom<CV>>)r.GetEnumerator();
            foreach(Custom<CV> s in i)
            {
                eo.MoveNext();
                er.MoveNext();
                IEnumerator<CV> io = (IEnumerator<CV>)eo.Current.GetEnumerator();
                IEnumerator<CV> ir = (IEnumerator<CV>)er.Current.GetEnumerator();
                foreach(CV obj in s)
                {
                    io.MoveNext();
                    ir.MoveNext();
                    if(obj == null)
                    {
                        test(io.Current == null);
                        test(ir.Current == null);
                    }
                    else
                    {
                        test(obj.i == io.Current.i);
                        test(obj.i == ir.Current.i);
                    }
                }
            }
        }

#if !COMPACT && !SILVERLIGHT
        {
            Serialize.Small i = null;
            Serialize.Small o;
            Serialize.Small r;

            r = p.opSerialSmallCSharp(i, out o);

            test(o == null);
            test(r == null);
        }

        {
            Serialize.Small i = new Serialize.Small();
            i.i = 99;
            Serialize.Small o;
            Serialize.Small r;

            try
            {
                r = p.opSerialSmallCSharp(i, out o);

                test(o.i == 99);
                test(r.i == 99);
            }
            catch(Ice.OperationNotExistException)
            {
                // OK, talking to non-C# server.
            }
        }

        {
            Serialize.Large i = new Serialize.Large();
            i.d1 = 1.0;
            i.d2 = 2.0;
            i.d3 = 3.0;
            i.d4 = 4.0;
            i.d5 = 5.0;
            i.d6 = 6.0;
            i.d7 = 7.0;
            i.d8 = 8.0;
            i.d9 = 9.0;
            i.d10 = 10.0;
            Serialize.Large o;
            Serialize.Large r;

            try
            {
                r = p.opSerialLargeCSharp(i, out o);

                test(o.d1 == 1.0);
                test(o.d2 == 2.0);
                test(o.d3 == 3.0);
                test(o.d4 == 4.0);
                test(o.d5 == 5.0);
                test(o.d6 == 6.0);
                test(o.d7 == 7.0);
                test(o.d8 == 8.0);
                test(o.d9 == 9.0);
                test(o.d10 == 10.0);
                test(r.d1 == 1.0);
                test(r.d2 == 2.0);
                test(r.d3 == 3.0);
                test(r.d4 == 4.0);
                test(r.d5 == 5.0);
                test(r.d6 == 6.0);
                test(r.d7 == 7.0);
                test(r.d8 == 8.0);
                test(r.d9 == 9.0);
                test(r.d10 == 10.0);
            }
            catch(Ice.OperationNotExistException)
            {
                // OK, talking to non-C# server.
            }
        }

        {
            Serialize.Struct i = new Serialize.Struct();
            i.o = null;
            i.o2 = i;
            i.s = null;
            i.s2 = "Hello";
            Serialize.Struct o;
            Serialize.Struct r;

            try
            {
                r = p.opSerialStructCSharp(i, out o);

                test(o.o == null);
                test(o.o2 != null);
                test(((Serialize.Struct)(o.o2)).o == null);
                test(((Serialize.Struct)(o.o2)).o2 == o.o2);
                test(o.s == null);
                test(o.s2.Equals("Hello"));
                test(r.o == null);
                test(r.o2 != null);
                test(((Serialize.Struct)(r.o2)).o == null);
                test(((Serialize.Struct)(r.o2)).o2 == r.o2);
                test(r.s == null);
                test(r.s2.Equals("Hello"));
            }
            catch(Ice.OperationNotExistException)
            {
                // OK, talking to non-C# server.
            }
        }
#endif
    }
Example #16
0
    public static void allTests(Ice.Communicator communicator)
    {
        Write("testing communicator operations... ");
        Flush();
        {
            //
            // Test: Exercise addAdminFacet, findAdminFacet, removeAdminFacet with a typical configuration.
            //
            Ice.InitializationData init = new Ice.InitializationData();
            init.properties = Ice.Util.createProperties();
            init.properties.setProperty("Ice.Admin.Endpoints", "tcp -h 127.0.0.1");
            init.properties.setProperty("Ice.Admin.InstanceName", "Test");
            Ice.Communicator com = Ice.Util.initialize(init);
            testFacets(com, true);
            com.destroy();
        }
        {
            //
            // Test: Verify that the operations work correctly in the presence of facet filters.
            //
            Ice.InitializationData init = new Ice.InitializationData();
            init.properties = Ice.Util.createProperties();
            init.properties.setProperty("Ice.Admin.Endpoints", "tcp -h 127.0.0.1");
            init.properties.setProperty("Ice.Admin.InstanceName", "Test");
            init.properties.setProperty("Ice.Admin.Facets", "Properties");
            Ice.Communicator com = Ice.Util.initialize(init);
            testFacets(com, false);
            com.destroy();
        }
        {
            //
            // Test: Verify that the operations work correctly with the Admin object disabled.
            //
            Ice.Communicator com = Ice.Util.initialize();
            testFacets(com, false);
            com.destroy();
        }
        {
            //
            // Test: Verify that the operations work correctly with Ice.Admin.Enabled=1
            //
            Ice.InitializationData init = new Ice.InitializationData();
            init.properties = Ice.Util.createProperties();
            init.properties.setProperty("Ice.Admin.Enabled", "1");
            Ice.Communicator com = Ice.Util.initialize(init);
            test(com.getAdmin() == null);
            Ice.Identity id = Ice.Util.stringToIdentity("test-admin");
            try
            {
                com.createAdmin(null, id);
                test(false);
            }
            catch(Ice.InitializationException)
            {
            }

            Ice.ObjectAdapter adapter = com.createObjectAdapter("");
            test(com.createAdmin(adapter, id) != null);
            test(com.getAdmin() != null);

            testFacets(com, true);
            com.destroy();
        }
        {
            //
            // Test: Verify that the operations work correctly when creation of the Admin object is delayed.
            //
            Ice.InitializationData init = new Ice.InitializationData();
            init.properties = Ice.Util.createProperties();
            init.properties.setProperty("Ice.Admin.Endpoints", "tcp -h 127.0.0.1");
            init.properties.setProperty("Ice.Admin.InstanceName", "Test");
            init.properties.setProperty("Ice.Admin.DelayCreation", "1");
            Ice.Communicator com = Ice.Util.initialize(init);
            testFacets(com, true);
            com.getAdmin();
            testFacets(com, true);
            com.destroy();
        }
        WriteLine("ok");

        string @ref = "factory:default -p 12010 -t 10000";
        RemoteCommunicatorFactoryPrx factory =
            RemoteCommunicatorFactoryPrxHelper.uncheckedCast(communicator.stringToProxy(@ref));

        Write("testing process facet... ");
        Flush();
        {
            //
            // Test: Verify that Process::shutdown() operation shuts down the communicator.
            //
            Dictionary<string, string> props = new Dictionary<string, string>();
            props.Add("Ice.Admin.Endpoints", "tcp -h 127.0.0.1");
            props.Add("Ice.Admin.InstanceName", "Test");
            RemoteCommunicatorPrx com = factory.createCommunicator(props);
            Ice.ObjectPrx obj = com.getAdmin();
            Ice.ProcessPrx proc = Ice.ProcessPrxHelper.checkedCast(obj, "Process");
            proc.shutdown();
            com.waitForShutdown();
            com.destroy();
        }
        WriteLine("ok");

        Write("testing properties facet... ");
        Flush();
        {
            Dictionary<string, string> props = new Dictionary<string, string>();
            props.Add("Ice.Admin.Endpoints", "tcp -h 127.0.0.1");
            props.Add("Ice.Admin.InstanceName", "Test");
            props.Add("Prop1", "1");
            props.Add("Prop2", "2");
            props.Add("Prop3", "3");
            RemoteCommunicatorPrx com = factory.createCommunicator(props);
            Ice.ObjectPrx obj = com.getAdmin();
            Ice.PropertiesAdminPrx pa = Ice.PropertiesAdminPrxHelper.checkedCast(obj, "Properties");

            //
            // Test: PropertiesAdmin::getProperty()
            //
            test(pa.getProperty("Prop2").Equals("2"));
            test(pa.getProperty("Bogus").Equals(""));

            //
            // Test: PropertiesAdmin::getProperties()
            //
            Dictionary<string, string> pd = pa.getPropertiesForPrefix("");
            test(pd.Count == 5);
            test(pd["Ice.Admin.Endpoints"].Equals("tcp -h 127.0.0.1"));
            test(pd["Ice.Admin.InstanceName"].Equals("Test"));
            test(pd["Prop1"].Equals("1"));
            test(pd["Prop2"].Equals("2"));
            test(pd["Prop3"].Equals("3"));

            Dictionary<string, string> changes;

            //
            // Test: PropertiesAdmin::setProperties()
            //
            Dictionary<string, string> setProps = new Dictionary<string, string>();
            setProps.Add("Prop1", "10"); // Changed
            setProps.Add("Prop2", "20"); // Changed
            setProps.Add("Prop3", ""); // Removed
            setProps.Add("Prop4", "4"); // Added
            setProps.Add("Prop5", "5"); // Added
            pa.setProperties(setProps);
            test(pa.getProperty("Prop1").Equals("10"));
            test(pa.getProperty("Prop2").Equals("20"));
            test(pa.getProperty("Prop3").Equals(""));
            test(pa.getProperty("Prop4").Equals("4"));
            test(pa.getProperty("Prop5").Equals("5"));
            changes = com.getChanges();
            test(changes.Count == 5);
            test(changes["Prop1"].Equals("10"));
            test(changes["Prop2"].Equals("20"));
            test(changes["Prop3"].Equals(""));
            test(changes["Prop4"].Equals("4"));
            test(changes["Prop5"].Equals("5"));
            pa.setProperties(setProps);
            changes = com.getChanges();
            test(changes.Count == 0);

            com.destroy();
        }
        WriteLine("ok");

        Write("testing logger facet... ");
        Flush();
        {
            Dictionary<String, String> props = new Dictionary<String, String>();
            props.Add("Ice.Admin.Endpoints", "tcp -h 127.0.0.1");
            props.Add("Ice.Admin.InstanceName", "Test");
            props.Add("NullLogger", "1");
            RemoteCommunicatorPrx com = factory.createCommunicator(props);

            com.trace("testCat", "trace");
            com.warning("warning");
            com.error("error");
            com.print("print");

            Ice.ObjectPrx obj = com.getAdmin();
            Ice.LoggerAdminPrx logger = Ice.LoggerAdminPrxHelper.checkedCast(obj, "Logger");
            test(logger != null);

            string prefix = null;

            //
            // Get all
            //
            Ice.LogMessage[] logMessages = logger.getLog(null, null, -1, out prefix);

            test(logMessages.Length == 4);
            test(prefix.Equals("NullLogger"));
            test(logMessages[0].traceCategory.Equals("testCat") && logMessages[0].message.Equals("trace"));
            test(logMessages[1].message.Equals("warning"));
            test(logMessages[2].message.Equals("error"));
            test(logMessages[3].message.Equals("print"));

            //
            // Get only errors and warnings
            //
            com.error("error2");
            com.print("print2");
            com.trace("testCat", "trace2");
            com.warning("warning2");

            Ice.LogMessageType[] messageTypes = {Ice.LogMessageType.ErrorMessage, Ice.LogMessageType.WarningMessage};

            logMessages = logger.getLog(messageTypes, null, -1, out prefix);

            test(logMessages.Length == 4);
            test(prefix.Equals("NullLogger"));

            foreach(var msg in logMessages)
            {
                test(msg.type == Ice.LogMessageType.ErrorMessage || msg.type == Ice.LogMessageType.WarningMessage);
            }

            //
            // Get only errors and traces with Cat = "testCat"
            //
            com.trace("testCat2", "A");
            com.trace("testCat", "trace3");
            com.trace("testCat2", "B");

            messageTypes = new Ice.LogMessageType[]{Ice.LogMessageType.ErrorMessage, Ice.LogMessageType.TraceMessage};
            string[] categories = {"testCat"};
            logMessages = logger.getLog(messageTypes, categories, -1, out prefix);
            test(logMessages.Length == 5);
            test(prefix.Equals("NullLogger"));

            foreach(var msg in logMessages)
            {
                test(msg.type == Ice.LogMessageType.ErrorMessage ||
                     (msg.type == Ice.LogMessageType.TraceMessage && msg.traceCategory.Equals("testCat")));
            }

            //
            // Same, but limited to last 2 messages (trace3 + error3)
            //
            com.error("error3");

            logMessages = logger.getLog(messageTypes, categories, 2, out prefix);
            test(logMessages.Length == 2);
            test(prefix.Equals("NullLogger"));

            test(logMessages[0].message.Equals("trace3"));
            test(logMessages[1].message.Equals("error3"));

            //
            // Now, test RemoteLogger
            //
            Ice.ObjectAdapter adapter =
                communicator.createObjectAdapterWithEndpoints("RemoteLoggerAdapter", "tcp -h localhost");

            RemoteLoggerI remoteLogger = new RemoteLoggerI();

            Ice.RemoteLoggerPrx myProxy = Ice.RemoteLoggerPrxHelper.uncheckedCast(adapter.addWithUUID(remoteLogger));

            adapter.activate();

            //
            // No filtering
            //
            logMessages = logger.getLog(null, null, -1, out prefix);
            remoteLogger.checkNextInit(prefix, logMessages);

            logger.attachRemoteLogger(myProxy, null, null, -1);
            remoteLogger.wait(1);

            remoteLogger.checkNextLog(Ice.LogMessageType.TraceMessage, "rtrace", "testCat");
            remoteLogger.checkNextLog(Ice.LogMessageType.WarningMessage, "rwarning", "");
            remoteLogger.checkNextLog(Ice.LogMessageType.ErrorMessage, "rerror", "");
            remoteLogger.checkNextLog(Ice.LogMessageType.PrintMessage, "rprint", "");

            com.trace("testCat", "rtrace");
            com.warning("rwarning");
            com.error("rerror");
            com.print("rprint");

            remoteLogger.wait(4);

            test(logger.detachRemoteLogger(myProxy));
            test(!logger.detachRemoteLogger(myProxy));

            //
            // Use Error + Trace with "traceCat" filter with 4 limit
            //
            logMessages = logger.getLog(messageTypes, categories, 4, out prefix);
            test(logMessages.Length == 4);
            remoteLogger.checkNextInit(prefix, logMessages);

            logger.attachRemoteLogger(myProxy, messageTypes, categories, 4);
            remoteLogger.wait(1);

            remoteLogger.checkNextLog(Ice.LogMessageType.TraceMessage, "rtrace2", "testCat");
            remoteLogger.checkNextLog(Ice.LogMessageType.ErrorMessage, "rerror2", "");

            com.warning("rwarning2");
            com.trace("testCat", "rtrace2");
            com.warning("rwarning3");
            com.error("rerror2");
            com.print("rprint2");

            remoteLogger.wait(2);

            //
            // Attempt reconnection with slightly different proxy
            //
            try
            {
                logger.attachRemoteLogger(Ice.RemoteLoggerPrxHelper.uncheckedCast(myProxy.ice_oneway()),
                                          messageTypes, categories, 4);
                test(false);
            }
            catch(Ice.RemoteLoggerAlreadyAttachedException)
            {
                // expected
            }

            com.destroy();
        }
        WriteLine("ok");

        Write("testing custom facet... ");
        Flush();
        {
            //
            // Test: Verify that the custom facet is present.
            //
            Dictionary<string, string> props = new Dictionary<string, string>();
            props.Add("Ice.Admin.Endpoints", "tcp -h 127.0.0.1");
            props.Add("Ice.Admin.InstanceName", "Test");
            RemoteCommunicatorPrx com = factory.createCommunicator(props);
            Ice.ObjectPrx obj = com.getAdmin();
            TestFacetPrx tf = TestFacetPrxHelper.checkedCast(obj, "TestFacet");
            tf.op();
            com.destroy();
        }
        WriteLine("ok");

        Write("testing facet filtering... ");
        Flush();
        {
            //
            // Test: Set Ice.Admin.Facets to expose only the Properties facet,
            // meaning no other facet is available.
            //
            Dictionary<string, string> props = new Dictionary<string, string>();
            props.Add("Ice.Admin.Endpoints", "tcp -h 127.0.0.1");
            props.Add("Ice.Admin.InstanceName", "Test");
            props.Add("Ice.Admin.Facets", "Properties");
            RemoteCommunicatorPrx com = factory.createCommunicator(props);
            Ice.ObjectPrx obj = com.getAdmin();
            Ice.ProcessPrx proc = Ice.ProcessPrxHelper.checkedCast(obj, "Process");
            test(proc == null);
            TestFacetPrx tf = TestFacetPrxHelper.checkedCast(obj, "TestFacet");
            test(tf == null);
            com.destroy();
        }
        {
            //
            // Test: Set Ice.Admin.Facets to expose only the Process facet,
            // meaning no other facet is available.
            //
            Dictionary<string, string> props = new Dictionary<string, string>();
            props.Add("Ice.Admin.Endpoints", "tcp -h 127.0.0.1");
            props.Add("Ice.Admin.InstanceName", "Test");
            props.Add("Ice.Admin.Facets", "Process");
            RemoteCommunicatorPrx com = factory.createCommunicator(props);
            Ice.ObjectPrx obj = com.getAdmin();
            Ice.PropertiesAdminPrx pa = Ice.PropertiesAdminPrxHelper.checkedCast(obj, "Properties");
            test(pa == null);
            TestFacetPrx tf = TestFacetPrxHelper.checkedCast(obj, "TestFacet");
            test(tf == null);
            com.destroy();
        }
        {
            //
            // Test: Set Ice.Admin.Facets to expose only the TestFacet facet,
            // meaning no other facet is available.
            //
            Dictionary<string, string> props = new Dictionary<string, string>();
            props.Add("Ice.Admin.Endpoints", "tcp -h 127.0.0.1");
            props.Add("Ice.Admin.InstanceName", "Test");
            props.Add("Ice.Admin.Facets", "TestFacet");
            RemoteCommunicatorPrx com = factory.createCommunicator(props);
            Ice.ObjectPrx obj = com.getAdmin();
            Ice.PropertiesAdminPrx pa = Ice.PropertiesAdminPrxHelper.checkedCast(obj, "Properties");
            test(pa == null);
            Ice.ProcessPrx proc = Ice.ProcessPrxHelper.checkedCast(obj, "Process");
            test(proc == null);
            com.destroy();
        }
        {
            //
            // Test: Set Ice.Admin.Facets to expose two facets. Use whitespace to separate the
            // facet names.
            //
            Dictionary<string, string> props = new Dictionary<string, string>();
            props.Add("Ice.Admin.Endpoints", "tcp -h 127.0.0.1");
            props.Add("Ice.Admin.InstanceName", "Test");
            props.Add("Ice.Admin.Facets", "Properties TestFacet");
            RemoteCommunicatorPrx com = factory.createCommunicator(props);
            Ice.ObjectPrx obj = com.getAdmin();
            Ice.PropertiesAdminPrx pa = Ice.PropertiesAdminPrxHelper.checkedCast(obj, "Properties");
            test(pa.getProperty("Ice.Admin.InstanceName").Equals("Test"));
            TestFacetPrx tf = TestFacetPrxHelper.checkedCast(obj, "TestFacet");
            tf.op();
            Ice.ProcessPrx proc = Ice.ProcessPrxHelper.checkedCast(obj, "Process");
            test(proc == null);
            com.destroy();
        }
        {
            //
            // Test: Set Ice.Admin.Facets to expose two facets. Use a comma to separate the
            // facet names.
            //
            Dictionary<string, string> props = new Dictionary<string, string>();
            props.Add("Ice.Admin.Endpoints", "tcp -h 127.0.0.1");
            props.Add("Ice.Admin.InstanceName", "Test");
            props.Add("Ice.Admin.Facets", "TestFacet, Process");
            RemoteCommunicatorPrx com = factory.createCommunicator(props);
            Ice.ObjectPrx obj = com.getAdmin();
            Ice.PropertiesAdminPrx pa = Ice.PropertiesAdminPrxHelper.checkedCast(obj, "Properties");
            test(pa == null);
            TestFacetPrx tf = TestFacetPrxHelper.checkedCast(obj, "TestFacet");
            tf.op();
            Ice.ProcessPrx proc = Ice.ProcessPrxHelper.checkedCast(obj, "Process");
            proc.shutdown();
            com.waitForShutdown();
            com.destroy();
        }
        WriteLine("ok");

        factory.shutdown();
    }
Example #17
0
    public static InitialPrx allTests(Ice.Communicator communicator)
#endif

    {
        Write("testing stringToProxy... ");
        Flush();
        string ref_Renamed = "initial:default -p 12010";
        Ice.ObjectPrx @base = communicator.stringToProxy(ref_Renamed);
        test(@base != null);
        WriteLine("ok");
        
        Write("testing checked cast... ");
        Flush();
        InitialPrx initial = InitialPrxHelper.checkedCast(@base);
        test(initial != null);
        test(initial.Equals(@base));
        WriteLine("ok");
        
        Write("getting proxies for class hierarchy... ");
        Flush();
        Test.MA.CAPrx ca = initial.caop();
        Test.MB.CBPrx cb = initial.cbop();
        Test.MA.CCPrx cc = initial.ccop();
        Test.MA.CDPrx cd = initial.cdop();
        test(ca != cb);
        test(ca != cc);
        test(ca != cd);
        test(cb != cc);
        test(cb != cd);
        test(cc != cd);
        WriteLine("ok");
        
        Write("getting proxies for interface hierarchy... ");
        Flush();
        Test.MA.IAPrx ia = initial.iaop();
        Test.MB.IB1Prx ib1 = initial.ib1op();
        Test.MB.IB2Prx ib2 = initial.ib2op();
        Test.MA.ICPrx ic = initial.icop();
        test(ia != ib1);
        test(ia != ib2);
        test(ia != ic);
        test(ib1 != ic);
        test(ib2 != ic);
        WriteLine("ok");
        
        Write("invoking proxy operations on class hierarchy... ");
        Flush();
        Test.MA.CAPrx cao;
        Test.MB.CBPrx cbo;
        Test.MA.CCPrx cco;
        
        cao = ca.caop(ca);
        test(cao.Equals(ca));
        cao = ca.caop(cb);
        test(cao.Equals(cb));
        cao = ca.caop(cc);
        test(cao.Equals(cc));
        cao = cb.caop(ca);
        test(cao.Equals(ca));
        cao = cb.caop(cb);
        test(cao.Equals(cb));
        cao = cb.caop(cc);
        test(cao.Equals(cc));
        cao = cc.caop(ca);
        test(cao.Equals(ca));
        cao = cc.caop(cb);
        test(cao.Equals(cb));
        cao = cc.caop(cc);
        test(cao.Equals(cc));
        
        cao = cb.cbop(cb);
        test(cao.Equals(cb));
        cbo = cb.cbop(cb);
        test(cbo.Equals(cb));
        cao = cb.cbop(cc);
        test(cao.Equals(cc));
        cbo = cb.cbop(cc);
        test(cbo.Equals(cc));
        cao = cc.cbop(cb);
        test(cao.Equals(cb));
        cbo = cc.cbop(cb);
        test(cbo.Equals(cb));
        cao = cc.cbop(cc);
        test(cao.Equals(cc));
        cbo = cc.cbop(cc);
        test(cbo.Equals(cc));
        
        cao = cc.ccop(cc);
        test(cao.Equals(cc));
        cbo = cc.ccop(cc);
        test(cbo.Equals(cc));
        cco = cc.ccop(cc);
        test(cco.Equals(cc));
        WriteLine("ok");
        
        Write("ditto, but for interface hierarchy... ");
        Flush();
        Test.MA.IAPrx iao;
        Test.MB.IB1Prx ib1o;
        Test.MB.IB2Prx ib2o;
        Test.MA.ICPrx ico;
        
        iao = ia.iaop(ia);
        test(iao.Equals(ia));
        iao = ia.iaop(ib1);
        test(iao.Equals(ib1));
        iao = ia.iaop(ib2);
        test(iao.Equals(ib2));
        iao = ia.iaop(ic);
        test(iao.Equals(ic));
        iao = ib1.iaop(ia);
        test(iao.Equals(ia));
        iao = ib1.iaop(ib1);
        test(iao.Equals(ib1));
        iao = ib1.iaop(ib2);
        test(iao.Equals(ib2));
        iao = ib1.iaop(ic);
        test(iao.Equals(ic));
        iao = ib2.iaop(ia);
        test(iao.Equals(ia));
        iao = ib2.iaop(ib1);
        test(iao.Equals(ib1));
        iao = ib2.iaop(ib2);
        test(iao.Equals(ib2));
        iao = ib2.iaop(ic);
        test(iao.Equals(ic));
        iao = ic.iaop(ia);
        test(iao.Equals(ia));
        iao = ic.iaop(ib1);
        test(iao.Equals(ib1));
        iao = ic.iaop(ib2);
        test(iao.Equals(ib2));
        iao = ic.iaop(ic);
        test(iao.Equals(ic));
        
        iao = ib1.ib1op(ib1);
        test(iao.Equals(ib1));
        ib1o = ib1.ib1op(ib1);
        test(ib1o.Equals(ib1));
        iao = ib1.ib1op(ic);
        test(iao.Equals(ic));
        ib1o = ib1.ib1op(ic);
        test(ib1o.Equals(ic));
        iao = ic.ib1op(ib1);
        test(iao.Equals(ib1));
        ib1o = ic.ib1op(ib1);
        test(ib1o.Equals(ib1));
        iao = ic.ib1op(ic);
        test(iao.Equals(ic));
        ib1o = ic.ib1op(ic);
        test(ib1o.Equals(ic));
        
        iao = ib2.ib2op(ib2);
        test(iao.Equals(ib2));
        ib2o = ib2.ib2op(ib2);
        test(ib2o.Equals(ib2));
        iao = ib2.ib2op(ic);
        test(iao.Equals(ic));
        ib2o = ib2.ib2op(ic);
        test(ib2o.Equals(ic));
        iao = ic.ib2op(ib2);
        test(iao.Equals(ib2));
        ib2o = ic.ib2op(ib2);
        test(ib2o.Equals(ib2));
        iao = ic.ib2op(ic);
        test(iao.Equals(ic));
        ib2o = ic.ib2op(ic);
        test(ib2o.Equals(ic));
        
        iao = ic.icop(ic);
        test(iao.Equals(ic));
        ib1o = ic.icop(ic);
        test(ib1o.Equals(ic));
        ib2o = ic.icop(ic);
        test(ib2o.Equals(ic));
        ico = ic.icop(ic);
        test(ico.Equals(ic));
        WriteLine("ok");
        
        Write("ditto, but for class implementing interfaces... ");
        Flush();
        
        cao = cd.caop(cd);
        test(cao.Equals(cd));
        cbo = cd.cbop(cd);
        test(cbo.Equals(cd));
        cco = cd.ccop(cd);
        test(cco.Equals(cd));
        
        iao = cd.iaop(cd);
        test(iao.Equals(cd));
        ib1o = cd.ib1op(cd);
        test(ib1o.Equals(cd));
        ib2o = cd.ib2op(cd);
        test(ib2o.Equals(cd));
        
        cao = cd.cdop(cd);
        test(cao.Equals(cd));
        cbo = cd.cdop(cd);
        test(cbo.Equals(cd));
        cco = cd.cdop(cd);
        test(cco.Equals(cd));
        
        iao = cd.cdop(cd);
        test(iao.Equals(cd));
        ib1o = cd.cdop(cd);
        test(ib1o.Equals(cd));
        ib2o = cd.cdop(cd);
        test(ib2o.Equals(cd));
        WriteLine("ok");
        
#if SILVERLIGHT
        initial.shutdown();
#else
        return initial;
#endif
    }
Example #18
0
    public static TestIntfPrx allTests(Ice.Communicator communicator)
#endif
    {
        string sref = "test:default -p 12010";
        Ice.ObjectPrx obj = communicator.stringToProxy(sref);
        test(obj != null);
        TestIntfPrx proxy = TestIntfPrxHelper.uncheckedCast(obj);
        test(proxy != null);

        Console.Out.Write("testing enum values... ");
        Console.Out.Flush();

        test((int)ByteEnum.benum1 == 0);
        test((int)ByteEnum.benum2 == 1);
        test((int)ByteEnum.benum3 == ByteConst1.value);
        test((int)ByteEnum.benum4 == ByteConst1.value + 1);
        test((int)ByteEnum.benum5 == ShortConst1.value);
        test((int)ByteEnum.benum6 == ShortConst1.value + 1);
        test((int)ByteEnum.benum7 == IntConst1.value);
        test((int)ByteEnum.benum8 == IntConst1.value + 1);
        test((int)ByteEnum.benum9 == LongConst1.value);
        test((int)ByteEnum.benum10 == LongConst1.value + 1);
        test((int)ByteEnum.benum11 == ByteConst2.value);

        test((int)ShortEnum.senum1 == 3);
        test((int)ShortEnum.senum2 == 4);
        test((int)ShortEnum.senum3 == ByteConst1.value);
        test((int)ShortEnum.senum4 == ByteConst1.value + 1);
        test((int)ShortEnum.senum5 == ShortConst1.value);
        test((int)ShortEnum.senum6 == ShortConst1.value + 1);
        test((int)ShortEnum.senum7 == IntConst1.value);
        test((int)ShortEnum.senum8 == IntConst1.value + 1);
        test((int)ShortEnum.senum9 == LongConst1.value);
        test((int)ShortEnum.senum10 == LongConst1.value + 1);
        test((int)ShortEnum.senum11 == ShortConst2.value);

        test((int)IntEnum.ienum1 == 0);
        test((int)IntEnum.ienum2 == 1);
        test((int)IntEnum.ienum3 == ByteConst1.value);
        test((int)IntEnum.ienum4 == ByteConst1.value + 1);
        test((int)IntEnum.ienum5 == ShortConst1.value);
        test((int)IntEnum.ienum6 == ShortConst1.value + 1);
        test((int)IntEnum.ienum7 == IntConst1.value);
        test((int)IntEnum.ienum8 == IntConst1.value + 1);
        test((int)IntEnum.ienum9 == LongConst1.value);
        test((int)IntEnum.ienum10 == LongConst1.value + 1);
        test((int)IntEnum.ienum11 == IntConst2.value);
        test((int)IntEnum.ienum12 == LongConst2.value);

        test((int)SimpleEnum.red == 0);
        test((int)SimpleEnum.green == 1);
        test((int)SimpleEnum.blue == 2);

        Console.Out.WriteLine("ok");

        Console.Out.Write("testing enum streaming... ");
        Console.Out.Flush();

        Ice.OutputStream ostr;
        byte[] bytes;

        bool encoding_1_0 = communicator.getProperties().getProperty("Ice.Default.EncodingVersion").Equals("1.0");

        ostr = new Ice.OutputStream(communicator);
        ostr.writeEnum((int)ByteEnum.benum11, (int)ByteEnum.benum11);
        bytes = ostr.finished();
        test(bytes.Length == 1); // ByteEnum should require one byte

        ostr = new Ice.OutputStream(communicator);
        ostr.writeEnum((int)ShortEnum.senum11, (int)ShortEnum.senum11);
        bytes = ostr.finished();
        test(bytes.Length == (encoding_1_0 ? 2 : 5));

        ostr = new Ice.OutputStream(communicator);
        ostr.writeEnum((int)IntEnum.ienum11, (int)IntEnum.ienum12);
        bytes = ostr.finished();
        test(bytes.Length == (encoding_1_0 ? 4 : 5));

        ostr = new Ice.OutputStream(communicator);
        ostr.writeEnum((int)SimpleEnum.blue, (int)SimpleEnum.blue);
        bytes = ostr.finished();
        test(bytes.Length == 1); // SimpleEnum should require one byte

        Console.Out.WriteLine("ok");

        Console.Out.Write("testing enum operations... ");
        Console.Out.Flush();

        ByteEnum byteEnum;
        test(proxy.opByte(ByteEnum.benum1, out byteEnum) == ByteEnum.benum1);
        test(byteEnum == ByteEnum.benum1);
        test(proxy.opByte(ByteEnum.benum11, out byteEnum) == ByteEnum.benum11);
        test(byteEnum == ByteEnum.benum11);

        ShortEnum shortEnum;
        test(proxy.opShort(ShortEnum.senum1, out shortEnum) == ShortEnum.senum1);
        test(shortEnum == ShortEnum.senum1);
        test(proxy.opShort(ShortEnum.senum11, out shortEnum) == ShortEnum.senum11);
        test(shortEnum == ShortEnum.senum11);

        IntEnum intEnum;
        test(proxy.opInt(IntEnum.ienum1, out intEnum) == IntEnum.ienum1);
        test(intEnum == IntEnum.ienum1);
        test(proxy.opInt(IntEnum.ienum11, out intEnum) == IntEnum.ienum11);
        test(intEnum == IntEnum.ienum11);
        test(proxy.opInt(IntEnum.ienum12, out intEnum) == IntEnum.ienum12);
        test(intEnum == IntEnum.ienum12);

        SimpleEnum s;
        test(proxy.opSimple(SimpleEnum.green, out s) == SimpleEnum.green);
        test(s == SimpleEnum.green);

        Console.Out.WriteLine("ok");

        Console.Out.Write("testing enum sequences operations... ");
        Console.Out.Flush();

        {
            ByteEnum[] b1 = new ByteEnum[11]
                    { ByteEnum.benum1, ByteEnum.benum2, ByteEnum.benum3, ByteEnum.benum4, ByteEnum.benum5,
                      ByteEnum.benum6, ByteEnum.benum7, ByteEnum.benum8, ByteEnum.benum9, ByteEnum.benum10,
                      ByteEnum.benum11};

            ByteEnum[] b2;
            ByteEnum[] b3 = proxy.opByteSeq(b1, out b2);

            for(int i = 0; i < b1.Length; ++i)
            {
                test(b1[i] == b2[i]);
                test(b1[i] == b3[i]);
            }
        }

        {
            ShortEnum[] s1 = new ShortEnum[11]
                    { ShortEnum.senum1, ShortEnum.senum2, ShortEnum.senum3, ShortEnum.senum4, ShortEnum.senum5,
                      ShortEnum.senum6, ShortEnum.senum7, ShortEnum.senum8, ShortEnum.senum9, ShortEnum.senum10,
                      ShortEnum.senum11};

            ShortEnum[] s2;
            ShortEnum[] s3 = proxy.opShortSeq(s1, out s2);

            for(int i = 0; i < s1.Length; ++i)
            {
                test(s1[i] == s2[i]);
                test(s1[i] == s3[i]);
            }
        }

        {
            IntEnum[] i1 = new IntEnum[11]
                    { IntEnum.ienum1, IntEnum.ienum2, IntEnum.ienum3, IntEnum.ienum4, IntEnum.ienum5,
                      IntEnum.ienum6, IntEnum.ienum7, IntEnum.ienum8, IntEnum.ienum9, IntEnum.ienum10,
                      IntEnum.ienum11};

            IntEnum[] i2;
            IntEnum[] i3 = proxy.opIntSeq(i1, out i2);

            for(int i = 0; i < i1.Length; ++i)
            {
                test(i1[i] == i2[i]);
                test(i1[i] == i3[i]);
            }
        }

        {
            SimpleEnum[] s1 = new SimpleEnum[3]
                    { SimpleEnum.red, SimpleEnum.green, SimpleEnum.blue };

            SimpleEnum[] s2;
            SimpleEnum[] s3 = proxy.opSimpleSeq(s1, out s2);

            for(int i = 0; i < s1.Length; ++i)
            {
                test(s1[i] == s2[i]);
                test(s1[i] == s3[i]);
            }
        }

        Console.Out.WriteLine("ok");
#if SILVERLIGHT
        proxy.shutdown();
#else
        return proxy;
#endif
    }
Example #19
0
    internal static void twowaysAMI(Ice.Communicator communicator, Test.MyClassPrx p)
    {
        {
            byte[] i = new byte[_length];
            for(int c = 0; c < _length; ++c)
            {
                i[c] = (byte)c;
            }

            AMI_MyClass_opAByteSI cb = new AMI_MyClass_opAByteSI(i);
            p.opAByteS_async(cb, i);
            cb.check();
        }

        {
            List<byte> i = new List<byte>();
            for(int c = 0; c < _length; ++c)
            {
                i.Add((byte)c);
            }

            AMI_MyClass_opLByteSI cb = new AMI_MyClass_opLByteSI(i);
            p.opLByteS_async(cb, i);
            cb.check();
        }

        {
            LinkedList<byte> i = new LinkedList<byte>();
            for(int c = 0; c < _length; ++c)
            {
                i.AddLast((byte)c);
            }

            AMI_MyClass_opKByteSI cb = new AMI_MyClass_opKByteSI(i);
            p.opKByteS_async(cb, i);
            cb.check();
        }

        {
            Queue<byte> i = new Queue<byte>();
            for(int c = 0; c < _length; ++c)
            {
                i.Enqueue((byte)c);
            }

            AMI_MyClass_opQByteSI cb = new AMI_MyClass_opQByteSI(i);
            p.opQByteS_async(cb, i);
            cb.check();
        }

        {
            Stack<byte> i = new Stack<byte>();
            for(int c = 0; c < _length; ++c)
            {
                i.Push((byte)c);
            }

            AMI_MyClass_opSByteSI cb = new AMI_MyClass_opSByteSI(i);
            p.opSByteS_async(cb, i);
            cb.check();
        }

        {
            CByteS i = new CByteS();
            for(int c = 0; c < _length; ++c)
            {
                i.Add((byte)c);
            }

            AMI_MyClass_opCByteSI cb = new AMI_MyClass_opCByteSI(i);
            p.opCByteS_async(cb, i);
            cb.check();
        }

        {
            bool[] i = new bool[_length];
            for(int c = 0; c < _length; ++c)
            {
                i[c] = c % 1 == 1;
            }

            AMI_MyClass_opABoolSI cb = new AMI_MyClass_opABoolSI(i);
            p.opABoolS_async(cb, i);
            cb.check();
        }

        {
            List<bool> i = new List<bool>();
            for(int c = 0; c < _length; ++c)
            {
                i.Add(c % 1 == 1);
            }

            AMI_MyClass_opLBoolSI cb = new AMI_MyClass_opLBoolSI(i);
            p.opLBoolS_async(cb, i);
            cb.check();
        }

        {
            LinkedList<bool> i = new LinkedList<bool>();
            for(int c = 0; c < _length; ++c)
            {
                i.AddLast(c % 1 == 1);
            }

            AMI_MyClass_opKBoolSI cb = new AMI_MyClass_opKBoolSI(i);
            p.opKBoolS_async(cb, i);
            cb.check();
        }

        {
            Queue<bool> i = new Queue<bool>();
            for(int c = 0; c < _length; ++c)
            {
                i.Enqueue(c % 1 == 1);
            }

            AMI_MyClass_opQBoolSI cb = new AMI_MyClass_opQBoolSI(i);
            p.opQBoolS_async(cb, i);
            cb.check();
        }

        {
            Stack<bool> i = new Stack<bool>();
            for(int c = 0; c < _length; ++c)
            {
                i.Push(c % 1 == 1);
            }

            AMI_MyClass_opSBoolSI cb = new AMI_MyClass_opSBoolSI(i);
            p.opSBoolS_async(cb, i);
            cb.check();
        }

        {
            CBoolS i = new CBoolS();
            for(int c = 0; c < _length; ++c)
            {
                i.Add(c % 1 == 1);
            }

            AMI_MyClass_opCBoolSI cb = new AMI_MyClass_opCBoolSI(i);
            p.opCBoolS_async(cb, i);
            cb.check();
        }

        {
            short[] i = new short[_length];
            for(int c = 0; c < _length; ++c)
            {
                i[c] = (short)c;
            }

            AMI_MyClass_opAShortSI cb = new AMI_MyClass_opAShortSI(i);
            p.opAShortS_async(cb, i);
            cb.check();
        }

        {
            List<short> i = new List<short>();
            for(int c = 0; c < _length; ++c)
            {
                i.Add((short)c);
            }

            AMI_MyClass_opLShortSI cb = new AMI_MyClass_opLShortSI(i);
            p.opLShortS_async(cb, i);
            cb.check();
        }

        {
            LinkedList<short> i = new LinkedList<short>();
            for(int c = 0; c < _length; ++c)
            {
                i.AddLast((short)c);
            }

            AMI_MyClass_opKShortSI cb = new AMI_MyClass_opKShortSI(i);
            p.opKShortS_async(cb, i);
            cb.check();
        }

        {
            Queue<short> i = new Queue<short>();
            for(int c = 0; c < _length; ++c)
            {
                i.Enqueue((short)c);
            }

            AMI_MyClass_opQShortSI cb = new AMI_MyClass_opQShortSI(i);
            p.opQShortS_async(cb, i);
            cb.check();
        }

        {
            Stack<short> i = new Stack<short>();
            for(int c = 0; c < _length; ++c)
            {
                i.Push((short)c);
            }

            AMI_MyClass_opSShortSI cb = new AMI_MyClass_opSShortSI(i);
            p.opSShortS_async(cb, i);
            cb.check();
        }

        {
            CShortS i = new CShortS();
            for(int c = 0; c < _length; ++c)
            {
                i.Add((short)c);
            }

            AMI_MyClass_opCShortSI cb = new AMI_MyClass_opCShortSI(i);
            p.opCShortS_async(cb, i);
            cb.check();
        }

        {
            int[] i = new int[_length];
            for(int c = 0; c < _length; ++c)
            {
                i[c] = (int)c;
            }

            AMI_MyClass_opAIntSI cb = new AMI_MyClass_opAIntSI(i);
            p.opAIntS_async(cb, i);
            cb.check();
        }

        {
            List<int> i = new List<int>();
            for(int c = 0; c < _length; ++c)
            {
                i.Add((int)c);
            }

            AMI_MyClass_opLIntSI cb = new AMI_MyClass_opLIntSI(i);
            p.opLIntS_async(cb, i);
            cb.check();
        }

        {
            LinkedList<int> i = new LinkedList<int>();
            for(int c = 0; c < _length; ++c)
            {
                i.AddLast((int)c);
            }

            AMI_MyClass_opKIntSI cb = new AMI_MyClass_opKIntSI(i);
            p.opKIntS_async(cb, i);
            cb.check();
        }

        {
            Queue<int> i = new Queue<int>();
            for(int c = 0; c < _length; ++c)
            {
                i.Enqueue((int)c);
            }

            AMI_MyClass_opQIntSI cb = new AMI_MyClass_opQIntSI(i);
            p.opQIntS_async(cb, i);
            cb.check();
        }

        {
            Stack<int> i = new Stack<int>();
            for(int c = 0; c < _length; ++c)
            {
                i.Push((int)c);
            }

            AMI_MyClass_opSIntSI cb = new AMI_MyClass_opSIntSI(i);
            p.opSIntS_async(cb, i);
            cb.check();
        }

        {
            CIntS i = new CIntS();
            for(int c = 0; c < _length; ++c)
            {
                i.Add((int)c);
            }

            AMI_MyClass_opCIntSI cb = new AMI_MyClass_opCIntSI(i);
            p.opCIntS_async(cb, i);
            cb.check();
        }

        {
            long[] i = new long[_length];
            for(int c = 0; c < _length; ++c)
            {
                i[c] = (long)c;
            }

            AMI_MyClass_opALongSI cb = new AMI_MyClass_opALongSI(i);
            p.opALongS_async(cb, i);
            cb.check();
        }

        {
            List<long> i = new List<long>();
            for(int c = 0; c < _length; ++c)
            {
                i.Add((long)c);
            }

            AMI_MyClass_opLLongSI cb = new AMI_MyClass_opLLongSI(i);
            p.opLLongS_async(cb, i);
            cb.check();
        }

        {
            LinkedList<long> i = new LinkedList<long>();
            for(int c = 0; c < _length; ++c)
            {
                i.AddLast((long)c);
            }

            AMI_MyClass_opKLongSI cb = new AMI_MyClass_opKLongSI(i);
            p.opKLongS_async(cb, i);
            cb.check();
        }

        {
            Queue<long> i = new Queue<long>();
            for(int c = 0; c < _length; ++c)
            {
                i.Enqueue((long)c);
            }

            AMI_MyClass_opQLongSI cb = new AMI_MyClass_opQLongSI(i);
            p.opQLongS_async(cb, i);
            cb.check();
        }

        {
            Stack<long> i = new Stack<long>();
            for(int c = 0; c < _length; ++c)
            {
                i.Push((long)c);
            }

            AMI_MyClass_opSLongSI cb = new AMI_MyClass_opSLongSI(i);
            p.opSLongS_async(cb, i);
            cb.check();
        }

        {
            CLongS i = new CLongS();
            for(int c = 0; c < _length; ++c)
            {
                i.Add((long)c);
            }

            AMI_MyClass_opCLongSI cb = new AMI_MyClass_opCLongSI(i);
            p.opCLongS_async(cb, i);
            cb.check();
        }

        {
            float[] i = new float[_length];
            for(int c = 0; c < _length; ++c)
            {
                i[c] = (float)c;
            }

            AMI_MyClass_opAFloatSI cb = new AMI_MyClass_opAFloatSI(i);
            p.opAFloatS_async(cb, i);
            cb.check();
        }

        {
            List<float> i = new List<float>();
            for(int c = 0; c < _length; ++c)
            {
                i.Add((float)c);
            }

            AMI_MyClass_opLFloatSI cb = new AMI_MyClass_opLFloatSI(i);
            p.opLFloatS_async(cb, i);
            cb.check();
        }

        {
            LinkedList<float> i = new LinkedList<float>();
            for(int c = 0; c < _length; ++c)
            {
                i.AddLast((float)c);
            }

            AMI_MyClass_opKFloatSI cb = new AMI_MyClass_opKFloatSI(i);
            p.opKFloatS_async(cb, i);
            cb.check();
        }

        {
            Queue<float> i = new Queue<float>();
            for(int c = 0; c < _length; ++c)
            {
                i.Enqueue((float)c);
            }

            AMI_MyClass_opQFloatSI cb = new AMI_MyClass_opQFloatSI(i);
            p.opQFloatS_async(cb, i);
            cb.check();
        }

        {
            Stack<float> i = new Stack<float>();
            for(int c = 0; c < _length; ++c)
            {
                i.Push((float)c);
            }

            AMI_MyClass_opSFloatSI cb = new AMI_MyClass_opSFloatSI(i);
            p.opSFloatS_async(cb, i);
            cb.check();
        }

        {
            CFloatS i = new CFloatS();
            for(int c = 0; c < _length; ++c)
            {
                i.Add((float)c);
            }

            AMI_MyClass_opCFloatSI cb = new AMI_MyClass_opCFloatSI(i);
            p.opCFloatS_async(cb, i);
            cb.check();
        }

        {
            double[] i = new double[_length];
            for(int c = 0; c < _length; ++c)
            {
                i[c] = (double)c;
            }

            AMI_MyClass_opADoubleSI cb = new AMI_MyClass_opADoubleSI(i);
            p.opADoubleS_async(cb, i);
            cb.check();
        }

        {
            List<double> i = new List<double>();
            for(int c = 0; c < _length; ++c)
            {
                i.Add((double)c);
            }

            AMI_MyClass_opLDoubleSI cb = new AMI_MyClass_opLDoubleSI(i);
            p.opLDoubleS_async(cb, i);
            cb.check();
        }

        {
            LinkedList<double> i = new LinkedList<double>();
            for(int c = 0; c < _length; ++c)
            {
                i.AddLast((double)c);
            }

            AMI_MyClass_opKDoubleSI cb = new AMI_MyClass_opKDoubleSI(i);
            p.opKDoubleS_async(cb, i);
            cb.check();
        }

        {
            Queue<double> i = new Queue<double>();
            for(int c = 0; c < _length; ++c)
            {
                i.Enqueue((double)c);
            }

            AMI_MyClass_opQDoubleSI cb = new AMI_MyClass_opQDoubleSI(i);
            p.opQDoubleS_async(cb, i);
            cb.check();
        }

        {
            Stack<double> i = new Stack<double>();
            for(int c = 0; c < _length; ++c)
            {
                i.Push((double)c);
            }

            AMI_MyClass_opSDoubleSI cb = new AMI_MyClass_opSDoubleSI(i);
            p.opSDoubleS_async(cb, i);
            cb.check();
        }

        {
            CDoubleS i = new CDoubleS();
            for(int c = 0; c < _length; ++c)
            {
                i.Add((double)c);
            }

            AMI_MyClass_opCDoubleSI cb = new AMI_MyClass_opCDoubleSI(i);
            p.opCDoubleS_async(cb, i);
            cb.check();
        }

        {
            string[] i = new string[_length];
            for(int c = 0; c < _length; ++c)
            {
                i[c] = c.ToString();
            }

            AMI_MyClass_opAStringSI cb = new AMI_MyClass_opAStringSI(i);
            p.opAStringS_async(cb, i);
            cb.check();
        }

        {
            List<string> i = new List<string>();
            for(int c = 0; c < _length; ++c)
            {
                i.Add(c.ToString());
            }

            AMI_MyClass_opLStringSI cb = new AMI_MyClass_opLStringSI(i);
            p.opLStringS_async(cb, i);
            cb.check();
        }

        {
            LinkedList<string> i = new LinkedList<string>();
            for(int c = 0; c < _length; ++c)
            {
                i.AddLast(c.ToString());
            }

            AMI_MyClass_opKStringSI cb = new AMI_MyClass_opKStringSI(i);
            p.opKStringS_async(cb, i);
            cb.check();
        }

        {
            Queue<string> i = new Queue<string>();
            for(int c = 0; c < _length; ++c)
            {
                i.Enqueue(c.ToString());
            }

            AMI_MyClass_opQStringSI cb = new AMI_MyClass_opQStringSI(i);
            p.opQStringS_async(cb, i);
            cb.check();
        }

        {
            Stack<string> i = new Stack<string>();
            for(int c = 0; c < _length; ++c)
            {
                i.Push(c.ToString());
            }

            AMI_MyClass_opSStringSI cb = new AMI_MyClass_opSStringSI(i);
            p.opSStringS_async(cb, i);
            cb.check();
        }

        {
            CStringS i = new CStringS();
            for(int c = 0; c < _length; ++c)
            {
                i.Add(c.ToString());
            }

            AMI_MyClass_opCStringSI cb = new AMI_MyClass_opCStringSI(i);
            p.opCStringS_async(cb, i);
            cb.check();
        }

        {
            Ice.Object[] i = new Ice.Object[_length];
            for(int c = 0; c < _length; ++c)
            {
                i[c] = new CV(c);
            }

            AMI_MyClass_opAObjectSI cb = new AMI_MyClass_opAObjectSI(i);
            p.opAObjectS_async(cb, i);
            cb.check();
        }

        {
            List<Ice.Object> i = new List<Ice.Object>();
            for(int c = 0; c < _length; ++c)
            {
                i.Add(new CV(c));
            }

            AMI_MyClass_opLObjectSI cb = new AMI_MyClass_opLObjectSI(i);
            p.opLObjectS_async(cb, i);
            cb.check();
        }

        {
            CObjectS i = new CObjectS();
            for(int c = 0; c < _length; ++c)
            {
                i.Add(new CV(c));
            }

            AMI_MyClass_opCObjectSI cb = new AMI_MyClass_opCObjectSI(i);
            p.opCObjectS_async(cb, i);
            cb.check();
        }

        {
            Ice.ObjectPrx[] i = new Ice.ObjectPrx[_length];
            for(int c = 0; c < _length; ++c)
            {
                i[c] = communicator.stringToProxy(c.ToString());
            }

            AMI_MyClass_opAObjectPrxSI cb = new AMI_MyClass_opAObjectPrxSI(i);
            p.opAObjectPrxS_async(cb, i);
            cb.check();
        }

        {
            List<Ice.ObjectPrx> i = new List<Ice.ObjectPrx>();
            for(int c = 0; c < _length; ++c)
            {
                i.Add(communicator.stringToProxy(c.ToString()));
            }

            AMI_MyClass_opLObjectPrxSI cb = new AMI_MyClass_opLObjectPrxSI(i);
            p.opLObjectPrxS_async(cb, i);
            cb.check();
        }

        {
            LinkedList<Ice.ObjectPrx> i = new LinkedList<Ice.ObjectPrx>();
            for(int c = 0; c < _length; ++c)
            {
                i.AddLast(communicator.stringToProxy(c.ToString()));
            }

            AMI_MyClass_opKObjectPrxSI cb = new AMI_MyClass_opKObjectPrxSI(i);
            p.opKObjectPrxS_async(cb, i);
            cb.check();
        }

        {
            Queue<Ice.ObjectPrx> i = new Queue<Ice.ObjectPrx>();
            for(int c = 0; c < _length; ++c)
            {
                i.Enqueue(communicator.stringToProxy(c.ToString()));
            }

            AMI_MyClass_opQObjectPrxSI cb = new AMI_MyClass_opQObjectPrxSI(i);
            p.opQObjectPrxS_async(cb, i);
            cb.check();
        }

        {
            Stack<Ice.ObjectPrx> i = new Stack<Ice.ObjectPrx>();
            for(int c = 0; c < _length; ++c)
            {
                i.Push(communicator.stringToProxy(c.ToString()));
            }

            AMI_MyClass_opSObjectPrxSI cb = new AMI_MyClass_opSObjectPrxSI(i);
            p.opSObjectPrxS_async(cb, i);
            cb.check();
        }

        {
            CObjectPrxS i = new CObjectPrxS();
            for(int c = 0; c < _length; ++c)
            {
                i.Add(communicator.stringToProxy(c.ToString()));
            }

            AMI_MyClass_opCObjectPrxSI cb = new AMI_MyClass_opCObjectPrxSI(i);
            p.opCObjectPrxS_async(cb, i);
            cb.check();
        }

        {
            S[] i = new S[_length];
            for(int c = 0; c < _length; ++c)
            {
                i[c].i = c;
            }

            AMI_MyClass_opAStructSI cb = new AMI_MyClass_opAStructSI(i);
            p.opAStructS_async(cb, i);
            cb.check();
        }

        {
            List<S> i = new List<S>();
            for(int c = 0; c < _length; ++c)
            {
                i.Add(new S(c));
            }

            AMI_MyClass_opLStructSI cb = new AMI_MyClass_opLStructSI(i);
            p.opLStructS_async(cb, i);
            cb.check();
        }

        {
            LinkedList<S> i = new LinkedList<S>();
            for(int c = 0; c < _length; ++c)
            {
                i.AddLast(new S(c));
            }

            AMI_MyClass_opKStructSI cb = new AMI_MyClass_opKStructSI(i);
            p.opKStructS_async(cb, i);
            cb.check();
        }

        {
            Queue<S> i = new Queue<S>();
            for(int c = 0; c < _length; ++c)
            {
                i.Enqueue(new S(c));
            }

            AMI_MyClass_opQStructSI cb = new AMI_MyClass_opQStructSI(i);
            p.opQStructS_async(cb, i);
            cb.check();
        }

        {
            Stack<S> i = new Stack<S>();
            for(int c = 0; c < _length; ++c)
            {
                i.Push(new S(c));
            }

            AMI_MyClass_opSStructSI cb = new AMI_MyClass_opSStructSI(i);
            p.opSStructS_async(cb, i);
            cb.check();
        }

        {
            CStructS i = new CStructS();
            for(int c = 0; c < _length; ++c)
            {
                i.Add(new S(c));
            }

            AMI_MyClass_opCStructSI cb = new AMI_MyClass_opCStructSI(i);
            p.opCStructS_async(cb, i);
            cb.check();
        }

        {
            SD[] i = new SD[_length];
            for(int c = 0; c < _length; ++c)
            {
                i[c] = new SD(c);
            }

            AMI_MyClass_opAStructSDI cb = new AMI_MyClass_opAStructSDI(i);
            p.opAStructSD_async(cb, i);
            cb.check();
        }

        {
            List<SD> i = new List<SD>();
            for(int c = 0; c < _length; ++c)
            {
                i.Add(new SD(c));
            }

            AMI_MyClass_opLStructSDI cb = new AMI_MyClass_opLStructSDI(i);
            p.opLStructSD_async(cb, i);
            cb.check();
        }

        {
            LinkedList<SD> i = new LinkedList<SD>();
            for(int c = 0; c < _length; ++c)
            {
                i.AddLast(new SD(c));
            }

            AMI_MyClass_opKStructSDI cb = new AMI_MyClass_opKStructSDI(i);
            p.opKStructSD_async(cb, i);
            cb.check();
        }

        {
            Queue<SD> i = new Queue<SD>();
            for(int c = 0; c < _length; ++c)
            {
                i.Enqueue(new SD(c));
            }

            AMI_MyClass_opQStructSDI cb = new AMI_MyClass_opQStructSDI(i);
            p.opQStructSD_async(cb, i);
            cb.check();
        }

        {
            Stack<SD> i = new Stack<SD>();
            for(int c = 0; c < _length; ++c)
            {
                i.Push(new SD(c));
            }

            AMI_MyClass_opSStructSDI cb = new AMI_MyClass_opSStructSDI(i);
            p.opSStructSD_async(cb, i);
            cb.check();
        }

        {
            CStructSD i = new CStructSD();
            for(int c = 0; c < _length; ++c)
            {
                i.Add(new SD(c));
            }

            AMI_MyClass_opCStructSDI cb = new AMI_MyClass_opCStructSDI(i);
            p.opCStructSD_async(cb, i);
            cb.check();
        }

        {
            CV[] i = new CV[_length];
            for(int c = 0; c < _length; ++c)
            {
                i[c] = new CV(c);
            }

            AMI_MyClass_opACVSI cb = new AMI_MyClass_opACVSI(i);
            p.opACVS_async(cb, i);
            cb.check();
        }

        {
            List<CV> i = new List<CV>();
            for(int c = 0; c < _length; ++c)
            {
                i.Add(new CV(c));
            }

            AMI_MyClass_opLCVSI cb = new AMI_MyClass_opLCVSI(i);
            p.opLCVS_async(cb, i);
            cb.check();
        }

        {
            CCVS i = new CCVS();
            for(int c = 0; c < _length; ++c)
            {
                i.Add(new CV(c));
            }

            AMI_MyClass_opCCVSI cb = new AMI_MyClass_opCCVSI(i);
            p.opCCVS_async(cb, i);
            cb.check();
        }

        {
            CVPrx[] i = new CVPrx[_length];
            for(int c = 0; c < _length; ++c)
            {
                i[c] = CVPrxHelper.uncheckedCast(communicator.stringToProxy(c.ToString()));
            }

            AMI_MyClass_opACVPrxSI cb = new AMI_MyClass_opACVPrxSI(i);
            p.opACVPrxS_async(cb, i);
            cb.check();
        }

        {
            List<CVPrx> i = new List<CVPrx>();
            for(int c = 0; c < _length; ++c)
            {
                i.Add(CVPrxHelper.uncheckedCast(communicator.stringToProxy(c.ToString())));
            }

            AMI_MyClass_opLCVPrxSI cb = new AMI_MyClass_opLCVPrxSI(i);
            p.opLCVPrxS_async(cb, i);
            cb.check();
        }

        {
            LinkedList<CVPrx> i = new LinkedList<CVPrx>();
            for(int c = 0; c < _length; ++c)
            {
                i.AddLast(CVPrxHelper.uncheckedCast(communicator.stringToProxy(c.ToString())));
            }

            AMI_MyClass_opKCVPrxSI cb = new AMI_MyClass_opKCVPrxSI(i);
            p.opKCVPrxS_async(cb, i);
            cb.check();
        }

        {
            Queue<CVPrx> i = new Queue<CVPrx>();
            for(int c = 0; c < _length; ++c)
            {
                i.Enqueue(CVPrxHelper.uncheckedCast(communicator.stringToProxy(c.ToString())));
            }

            AMI_MyClass_opQCVPrxSI cb = new AMI_MyClass_opQCVPrxSI(i);
            p.opQCVPrxS_async(cb, i);
            cb.check();
        }

        {
            Stack<CVPrx> i = new Stack<CVPrx>();
            for(int c = 0; c < _length; ++c)
            {
                i.Push(CVPrxHelper.uncheckedCast(communicator.stringToProxy(c.ToString())));
            }

            AMI_MyClass_opSCVPrxSI cb = new AMI_MyClass_opSCVPrxSI(i);
            p.opSCVPrxS_async(cb, i);
            cb.check();
        }

        {
            CCVPrxS i = new CCVPrxS();
            for(int c = 0; c < _length; ++c)
            {
                i.Add(CVPrxHelper.uncheckedCast(communicator.stringToProxy(c.ToString())));
            }

            AMI_MyClass_opCCVPrxSI cb = new AMI_MyClass_opCCVPrxSI(i);
            p.opCCVPrxS_async(cb, i);
            cb.check();
        }

        {
            CR[] i = new CR[_length];
            for(int c = 0; c < _length; ++c)
            {
                i[c] = new CR(new CV(c));
            }

            AMI_MyClass_opACRSI cb = new AMI_MyClass_opACRSI(i);
            p.opACRS_async(cb, i);
            cb.check();
        }

        {
            List<CR> i = new List<CR>();
            for(int c = 0; c < _length; ++c)
            {
                i.Add(new CR(new CV(c)));
            }

            AMI_MyClass_opLCRSI cb = new AMI_MyClass_opLCRSI(i);
            p.opLCRS_async(cb, i);
            cb.check();
        }

        {
            CCRS i = new CCRS();
            for(int c = 0; c < _length; ++c)
            {
                i.Add(new CR(new CV(c)));
            }

            AMI_MyClass_opCCRSI cb = new AMI_MyClass_opCCRSI(i);
            p.opCCRS_async(cb, i);
            cb.check();
        }

        {
            En[] i = new En[_length];
            for(int c = 0; c < _length; ++c)
            {
                i[c] = (En)(c % 3);
            }

            AMI_MyClass_opAEnSI cb = new AMI_MyClass_opAEnSI(i);
            p.opAEnS_async(cb, i);
            cb.check();
        }

        {
            List<En> i = new List<En>();
            for(int c = 0; c < _length; ++c)
            {
                i.Add((En)(c % 3));
            }

            AMI_MyClass_opLEnSI cb = new AMI_MyClass_opLEnSI(i);
            p.opLEnS_async(cb, i);
            cb.check();
        }

        {
            LinkedList<En> i = new LinkedList<En>();
            for(int c = 0; c < _length; ++c)
            {
                i.AddLast((En)(c % 3));
            }

            AMI_MyClass_opKEnSI cb = new AMI_MyClass_opKEnSI(i);
            p.opKEnS_async(cb, i);
            cb.check();
        }

        {
            Queue<En> i = new Queue<En>();
            for(int c = 0; c < _length; ++c)
            {
                i.Enqueue((En)(c % 3));
            }

            AMI_MyClass_opQEnSI cb = new AMI_MyClass_opQEnSI(i);
            p.opQEnS_async(cb, i);
            cb.check();
        }

        {
            Stack<En> i = new Stack<En>();
            for(int c = 0; c < _length; ++c)
            {
                i.Push((En)(c % 3));
            }

            AMI_MyClass_opSEnSI cb = new AMI_MyClass_opSEnSI(i);
            p.opSEnS_async(cb, i);
            cb.check();
        }

        {
            CEnS i = new CEnS();
            for(int c = 0; c < _length; ++c)
            {
                i.Add((En)(c % 3));
            }

            AMI_MyClass_opCEnSI cb = new AMI_MyClass_opCEnSI(i);
            p.opCEnS_async(cb, i);
            cb.check();
        }

        {
            Custom<int> i = new Custom<int>();
            for(int c = 0; c < _length; ++c)
            {
                i.Add(c);
            }

            AMI_MyClass_opCustomIntSI cb = new AMI_MyClass_opCustomIntSI(i);
            p.opCustomIntS_async(cb, i);
            cb.check();
        }

        {
            Custom<CV> i = new Custom<CV>();
            for(int c = 0; c < _length; ++c)
            {
                i.Add(new CV(c));
            }

            AMI_MyClass_opCustomCVSI cb = new AMI_MyClass_opCustomCVSI(i);
            p.opCustomCVS_async(cb, i);
            cb.check();
        }

        {
            Custom<Custom<int>> i = new Custom<Custom<int>>();
            for(int c = 0; c < _length; ++c)
            {
                Custom<int> inner = new Custom<int>();
                for(int j = 0; j < c; ++j)
                {
                    inner.Add(j);
                }
                i.Add(inner);
            }

            AMI_MyClass_opCustomIntSSI cb = new AMI_MyClass_opCustomIntSSI(i);
            p.opCustomIntSS_async(cb, i);
            cb.check();
        }

        {
            Custom<Custom<CV>> i = new Custom<Custom<CV>>();
            for(int c = 0; c < _length; ++c)
            {
                Custom<CV> inner = new Custom<CV>();
                for(int j = 0; j < c; ++j)
                {
                    inner.Add(new CV(j));
                }
                i.Add(inner);
            }

            AMI_MyClass_opCustomCVSSI cb = new AMI_MyClass_opCustomCVSSI(i);
            p.opCustomCVSS_async(cb, i);
            cb.check();
        }

#if !COMPACT && !SILVERLIGHT
        {
            Serialize.Small i = null;

            AMI_MyClass_opSerialSmallCSharpNull cb = new AMI_MyClass_opSerialSmallCSharpNull();
            p.opSerialSmallCSharp_async(cb, i);
            cb.check();
        }

        {
            Serialize.Small i = new Serialize.Small();
            i.i = 99;

            AMI_MyClass_opSerialSmallCSharp cb = new AMI_MyClass_opSerialSmallCSharp();
            p.opSerialSmallCSharp_async(cb, i);
            cb.check();
        }

        {
            Serialize.Large i = new Serialize.Large();
            i.d1 = 1.0;
            i.d2 = 2.0;
            i.d3 = 3.0;
            i.d4 = 4.0;
            i.d5 = 5.0;
            i.d6 = 6.0;
            i.d7 = 7.0;
            i.d8 = 8.0;
            i.d9 = 9.0;
            i.d10 = 10.0;

            AMI_MyClass_opSerialLargeCSharp cb = new AMI_MyClass_opSerialLargeCSharp();
            p.opSerialLargeCSharp_async(cb, i);
            cb.check();
        }

        {
            Serialize.Struct i = new Serialize.Struct();
            i.o = null;
            i.o2 = i;
            i.s = null;
            i.s2 = "Hello";

            AMI_MyClass_opSerialStructCSharp cb = new AMI_MyClass_opSerialStructCSharp();
            p.opSerialStructCSharp_async(cb, i);
            cb.check();
        }
#endif
    }
Example #20
0
    public static TestIntfPrx allTests(Ice.Communicator communicator, bool collocated)
    {
        Console.Out.Write("testing stringToProxy... ");
        Console.Out.Flush();
        string r = "Test:default -p 12010 -t 2000";
        Ice.ObjectPrx basePrx = communicator.stringToProxy(r);
        test(basePrx != null);
        Console.Out.WriteLine("ok");

        Console.Out.Write("testing checked cast... ");
        Console.Out.Flush();
        TestIntfPrx testPrx = TestIntfPrxHelper.checkedCast(basePrx);
        test(testPrx != null);
        test(testPrx.Equals(basePrx));
        Console.Out.WriteLine("ok");

        Console.Out.Write("base as Object... ");
        Console.Out.Flush();
        {
            Ice.Object o;
            SBase sb = null;
            try
            {
                o = testPrx.SBaseAsObject();
                test(o != null);
                test(o.ice_id().Equals("::Test::SBase"));
                sb = (SBase) o;
            }
            catch(Exception)
            {
                test(false);
            }
            test(sb != null);
            test(sb.sb.Equals("SBase.sb"));
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("base as Object (AMI)... ");
        Console.Out.Flush();
        {
            AsyncCallback cb = new AsyncCallback();
            testPrx.begin_SBaseAsObject().whenCompleted(cb.response_SBaseAsObject, cb.exception);
            cb.check();
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("base as base... ");
        Console.Out.Flush();
        {
            SBase sb;
            try
            {
                sb = testPrx.SBaseAsSBase();
                test(sb.sb.Equals("SBase.sb"));
            }
            catch(Exception)
            {
                test(false);
            }
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("base as base (AMI)... ");
        Console.Out.Flush();
        {
            AsyncCallback cb = new AsyncCallback();
            testPrx.begin_SBaseAsSBase().whenCompleted(cb.response_SBaseAsSBase, cb.exception);
            cb.check();
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("base with known derived as base... ");
        Console.Out.Flush();
        {
            SBase sb;
            SBSKnownDerived sbskd = null;
            try
            {
                sb = testPrx.SBSKnownDerivedAsSBase();
                test(sb.sb.Equals("SBSKnownDerived.sb"));
                sbskd = (SBSKnownDerived) sb;
            }
            catch(Exception)
            {
                test(false);
            }
            test(sbskd != null);
            test(sbskd.sbskd.Equals("SBSKnownDerived.sbskd"));
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("base with known derived as base (AMI)... ");
        Console.Out.Flush();
        {
            AsyncCallback cb = new AsyncCallback();
            testPrx.begin_SBSKnownDerivedAsSBase().whenCompleted(cb.response_SBSKnownDerivedAsSBase, cb.exception);
            cb.check();
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("base with known derived as known derived... ");
        Console.Out.Flush();
        {
            SBSKnownDerived sbskd;
            try
            {
                sbskd = testPrx.SBSKnownDerivedAsSBSKnownDerived();
                test(sbskd.sbskd.Equals("SBSKnownDerived.sbskd"));
            }
            catch(Exception)
            {
                test(false);
            }
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("base with known derived as known derived (AMI)... ");
        Console.Out.Flush();
        {
            AsyncCallback cb = new AsyncCallback();
            testPrx.begin_SBSKnownDerivedAsSBSKnownDerived().whenCompleted(
                        cb.response_SBSKnownDerivedAsSBSKnownDerived, cb.exception);
            cb.check();
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("base with unknown derived as base... ");
        Console.Out.Flush();
        {
            SBase sb;
            try
            {
                sb = testPrx.SBSUnknownDerivedAsSBase();
                test(sb.sb.Equals("SBSUnknownDerived.sb"));
            }
            catch(Exception)
            {
                test(false);
            }
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("base with unknown derived as base (AMI)... ");
        Console.Out.Flush();
        {
            AsyncCallback cb = new AsyncCallback();
            testPrx.begin_SBSUnknownDerivedAsSBase().whenCompleted(
                        cb.response_SBSUnknownDerivedAsSBase, cb.exception);
            cb.check();
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("unknown with Object as Object... ");
        Console.Out.Flush();
        {
            try
            {
                testPrx.SUnknownAsObject();
                test(false);
            }
            catch(Ice.NoObjectFactoryException)
            {
            }
            catch(Exception)
            {
                test(false);
            }
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("unknown with Object as Object (AMI)... ");
        Console.Out.Flush();
        {
            try
            {
                AsyncCallback cb = new AsyncCallback();
                testPrx.begin_SUnknownAsObject().whenCompleted(
                        cb.response_SUnknownAsObject, cb.exception_SUnknownAsObject);
                cb.check();
            }
            catch(Exception)
            {
                test(false);
            }
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("one-element cycle... ");
        Console.Out.Flush();
        {
            try
            {
                B b = testPrx.oneElementCycle();
                test(b != null);
                test(b.ice_id().Equals("::Test::B"));
                test(b.sb.Equals("B1.sb"));
                test(b.pb == b);
            }
            catch(Exception)
            {
                test(false);
            }
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("one-element cycle (AMI)... ");
        Console.Out.Flush();
        {
            AsyncCallback cb = new AsyncCallback();
            testPrx.begin_oneElementCycle().whenCompleted(
                        cb.response_oneElementCycle, cb.exception);
            cb.check();
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("two-element cycle... ");
        Console.Out.Flush();
        {
            try
            {
                B b1 = testPrx.twoElementCycle();
                test(b1 != null);
                test(b1.ice_id().Equals("::Test::B"));
                test(b1.sb.Equals("B1.sb"));

                B b2 = b1.pb;
                test(b2 != null);
                test(b2.ice_id().Equals("::Test::B"));
                test(b2.sb.Equals("B2.sb"));
                test(b2.pb == b1);
            }
            catch(Exception)
            {
                test(false);
            }
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("two-element cycle (AMI)... ");
        Console.Out.Flush();
        {
            AsyncCallback cb = new AsyncCallback();
            testPrx.begin_twoElementCycle().whenCompleted(
                        cb.response_twoElementCycle, cb.exception);
            cb.check();
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("known derived pointer slicing as base... ");
        Console.Out.Flush();
        {
            try
            {
                B b1;
                b1 = testPrx.D1AsB();
                test(b1 != null);
                test(b1.ice_id().Equals("::Test::D1"));
                test(b1.sb.Equals("D1.sb"));
                test(b1.pb != null);
                test(b1.pb != b1);
                D1 d1 = (D1) b1;
                test(d1 != null);
                test(d1.sd1.Equals("D1.sd1"));
                test(d1.pd1 != null);
                test(d1.pd1 != b1);
                test(b1.pb == d1.pd1);

                B b2 = b1.pb;
                test(b2 != null);
                test(b2.pb == b1);
                test(b2.sb.Equals("D2.sb"));
                test(b2.ice_id().Equals("::Test::B"));
            }
            catch(Exception)
            {
                test(false);
            }
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("known derived pointer slicing as base (AMI)... ");
        Console.Out.Flush();
        {
            AsyncCallback cb = new AsyncCallback();
            testPrx.begin_D1AsB().whenCompleted(cb.response_D1AsB, cb.exception);
            cb.check();
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("known derived pointer slicing as derived... ");
        Console.Out.Flush();
        {
            try
            {
                D1 d1;
                d1 = testPrx.D1AsD1();
                test(d1 != null);
                test(d1.ice_id().Equals("::Test::D1"));
                test(d1.sb.Equals("D1.sb"));
                test(d1.pb != null);
                test(d1.pb != d1);

                B b2 = d1.pb;
                test(b2 != null);
                test(b2.ice_id().Equals("::Test::B"));
                test(b2.sb.Equals("D2.sb"));
                test(b2.pb == d1);
            }
            catch(Exception)
            {
                test(false);
            }
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("known derived pointer slicing as derived (AMI)... ");
        Console.Out.Flush();
        {
            AsyncCallback cb = new AsyncCallback();
            testPrx.begin_D1AsD1().whenCompleted(cb.response_D1AsD1, cb.exception);
            cb.check();
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("unknown derived pointer slicing as base... ");
        Console.Out.Flush();
        {
            try
            {
                B b2;
                b2 = testPrx.D2AsB();
                test(b2 != null);
                test(b2.ice_id().Equals("::Test::B"));
                test(b2.sb.Equals("D2.sb"));
                test(b2.pb != null);
                test(b2.pb != b2);

                B b1 = b2.pb;
                test(b1 != null);
                test(b1.ice_id().Equals("::Test::D1"));
                test(b1.sb.Equals("D1.sb"));
                test(b1.pb == b2);
                D1 d1 = (D1) b1;
                test(d1 != null);
                test(d1.sd1.Equals("D1.sd1"));
                test(d1.pd1 == b2);
            }
            catch(Exception)
            {
                test(false);
            }
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("unknown derived pointer slicing as base (AMI)... ");
        Console.Out.Flush();
        {
            AsyncCallback cb = new AsyncCallback();
            testPrx.begin_D2AsB().whenCompleted(cb.response_D2AsB, cb.exception);
            cb.check();
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("param ptr slicing with known first... ");
        Console.Out.Flush();
        {
            try
            {
                B b1;
                B b2;
                testPrx.paramTest1(out b1, out b2);

                test(b1 != null);
                test(b1.ice_id().Equals("::Test::D1"));
                test(b1.sb.Equals("D1.sb"));
                test(b1.pb == b2);
                D1 d1 = (D1) b1;
                test(d1 != null);
                test(d1.sd1.Equals("D1.sd1"));
                test(d1.pd1 == b2);

                test(b2 != null);
                test(b2.ice_id().Equals("::Test::B")); // No factory, must be sliced
                test(b2.sb.Equals("D2.sb"));
                test(b2.pb == b1);
            }
            catch(Exception)
            {
                test(false);
            }
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("param ptr slicing with known first (AMI)... ");
        Console.Out.Flush();
        {
            AsyncCallback cb = new AsyncCallback();
            testPrx.begin_paramTest1().whenCompleted(cb.response_paramTest1, cb.exception);
            cb.check();
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("param ptr slicing with unknown first... ");
        Console.Out.Flush();
        {
            try
            {
                B b2;
                B b1;
                testPrx.paramTest2(out b2, out b1);

                test(b1 != null);
                test(b1.ice_id().Equals("::Test::D1"));
                test(b1.sb.Equals("D1.sb"));
                test(b1.pb == b2);
                D1 d1 = (D1) b1;
                test(d1 != null);
                test(d1.sd1.Equals("D1.sd1"));
                test(d1.pd1 == b2);

                test(b2 != null);
                test(b2.ice_id().Equals("::Test::B")); // No factory, must be sliced
                test(b2.sb.Equals("D2.sb"));
                test(b2.pb == b1);
            }
            catch(Exception)
            {
                test(false);
            }
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("param ptr slicing with unknown first (AMI)... ");
        Console.Out.Flush();
        {
            AsyncCallback cb = new AsyncCallback();
            testPrx.begin_paramTest2().whenCompleted(cb.response_paramTest2, cb.exception);
            cb.check();
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("return value identity with known first... ");
        Console.Out.Flush();
        {
            try
            {
                B p1;
                B p2;
                B ret = testPrx.returnTest1(out p1, out p2);
                test(ret == p1);
            }
            catch(Exception)
            {
                test(false);
            }
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("return value identity with known first (AMI)... ");
        Console.Out.Flush();
        {
            AsyncCallback cb = new AsyncCallback();
            testPrx.begin_returnTest1().whenCompleted(cb.response_returnTest1, cb.exception);
            cb.check();
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("return value identity with unknown first... ");
        Console.Out.Flush();
        {
            try
            {
                B p1;
                B p2;
                B ret = testPrx.returnTest2(out p1, out p2);
                test(ret == p1);
            }
            catch(Exception)
            {
                test(false);
            }
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("return value identity with unknown first (AMI)... ");
        Console.Out.Flush();
        {
            AsyncCallback cb = new AsyncCallback();
            testPrx.begin_returnTest2().whenCompleted(cb.response_returnTest2, cb.exception);
            cb.check();
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("return value identity for input params known first... ");
        Console.Out.Flush();
        {
            try
            {
                D1 d1 = new D1();
                d1.sb = "D1.sb";
                d1.sd1 = "D1.sd1";
                D3 d3 = new D3();
                d3.pb = d1;
                d3.sb = "D3.sb";
                d3.sd3 = "D3.sd3";
                d3.pd3 = d1;
                d1.pb = d3;
                d1.pd1 = d3;

                B b1 = testPrx.returnTest3(d1, d3);

                test(b1 != null);
                test(b1.sb.Equals("D1.sb"));
                test(b1.ice_id().Equals("::Test::D1"));
                D1 p1 = (D1) b1;
                test(p1 != null);
                test(p1.sd1.Equals("D1.sd1"));
                test(p1.pd1 == b1.pb);

                B b2 = b1.pb;
                test(b2 != null);
                test(b2.sb.Equals("D3.sb"));
                test(b2.ice_id().Equals("::Test::B")); // Sliced by server
                test(b2.pb == b1);
                try
                {
                    D3 p3 = (D3) b2;
                    test(false);
                    D3 tmp = p3; p3 = tmp; // Stop compiler warning about unused variable.
                }
                catch(InvalidCastException)
                {
                }

                test(b1 != d1);
                test(b1 != d3);
                test(b2 != d1);
                test(b2 != d3);
            }
            catch(Exception)
            {
                test(false);
            }
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("return value identity for input params known first (AMI)... ");
        Console.Out.Flush();
        {
            D1 d1 = new D1();
            d1.sb = "D1.sb";
            d1.sd1 = "D1.sd1";
            D3 d3 = new D3();
            d3.pb = d1;
            d3.sb = "D3.sb";
            d3.sd3 = "D3.sd3";
            d3.pd3 = d1;
            d1.pb = d3;
            d1.pd1 = d3;

            AsyncCallback cb = new AsyncCallback();
            testPrx.begin_returnTest3(d1, d3).whenCompleted(cb.response_returnTest3, cb.exception);
            cb.check();
            B b1 = cb.rb;

            test(b1 != null);
            test(b1.sb.Equals("D1.sb"));
            test(b1.ice_id().Equals("::Test::D1"));
            D1 p1 = (D1) b1;
            test(p1 != null);
            test(p1.sd1.Equals("D1.sd1"));
            test(p1.pd1 == b1.pb);

            B b2 = b1.pb;
            test(b2 != null);
            test(b2.sb.Equals("D3.sb"));
            test(b2.ice_id().Equals("::Test::B")); // Sliced by server
            test(b2.pb == b1);
            try
            {
                D3 p3 = (D3) b2;
                test(false);
                D3 tmp = p3; p3 = tmp; // Stop compiler warning about unused variable.
            }
            catch(InvalidCastException)
            {
            }

            test(b1 != d1);
            test(b1 != d3);
            test(b2 != d1);
            test(b2 != d3);
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("return value identity for input params unknown first... ");
        Console.Out.Flush();
        {
            try
            {
                D1 d1 = new D1();
                d1.sb = "D1.sb";
                d1.sd1 = "D1.sd1";
                D3 d3 = new D3();
                d3.pb = d1;
                d3.sb = "D3.sb";
                d3.sd3 = "D3.sd3";
                d3.pd3 = d1;
                d1.pb = d3;
                d1.pd1 = d3;

                B b1 = testPrx.returnTest3(d3, d1);

                test(b1 != null);
                test(b1.sb.Equals("D3.sb"));
                test(b1.ice_id().Equals("::Test::B")); // Sliced by server

                try
                {
                    D3 p1 = (D3) b1;
                    test(false);
                    D3 tmp = p1; p1 = tmp; // Stop compiler warning about unused variable.
                }
                catch(InvalidCastException)
                {
                }

                B b2 = b1.pb;
                test(b2 != null);
                test(b2.sb.Equals("D1.sb"));
                test(b2.ice_id().Equals("::Test::D1"));
                test(b2.pb == b1);
                D1 p3 = (D1) b2;
                test(p3 != null);
                test(p3.sd1.Equals("D1.sd1"));
                test(p3.pd1 == b1);

                test(b1 != d1);
                test(b1 != d3);
                test(b2 != d1);
                test(b2 != d3);
            }
            catch(Exception)
            {
                test(false);
            }
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("return value identity for input params unknown first (AMI)... ");
        Console.Out.Flush();
        {
            D1 d1 = new D1();
            d1.sb = "D1.sb";
            d1.sd1 = "D1.sd1";
            D3 d3 = new D3();
            d3.pb = d1;
            d3.sb = "D3.sb";
            d3.sd3 = "D3.sd3";
            d3.pd3 = d1;
            d1.pb = d3;
            d1.pd1 = d3;

            AsyncCallback cb = new AsyncCallback();
            testPrx.begin_returnTest3(d3, d1).whenCompleted(cb.response_returnTest3, cb.exception);
            cb.check();
            B b1 = cb.rb;

            test(b1 != null);
            test(b1.sb.Equals("D3.sb"));
            test(b1.ice_id().Equals("::Test::B")); // Sliced by server

            try
            {
                D3 p1 = (D3) b1;
                test(false);
                D3 tmp = p1; p1 = tmp; // Stop compiler warning about unused variable.
            }
            catch(InvalidCastException)
            {
            }

            B b2 = b1.pb;
            test(b2 != null);
            test(b2.sb.Equals("D1.sb"));
            test(b2.ice_id().Equals("::Test::D1"));
            test(b2.pb == b1);
            D1 p3 = (D1) b2;
            test(p3 != null);
            test(p3.sd1.Equals("D1.sd1"));
            test(p3.pd1 == b1);

            test(b1 != d1);
            test(b1 != d3);
            test(b2 != d1);
            test(b2 != d3);
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("remainder unmarshaling (3 instances)... ");
        Console.Out.Flush();
        {
            try
            {
                B p1;
                B p2;
                B ret = testPrx.paramTest3(out p1, out p2);

                test(p1 != null);
                test(p1.sb.Equals("D2.sb (p1 1)"));
                test(p1.pb == null);
                test(p1.ice_id().Equals("::Test::B"));

                test(p2 != null);
                test(p2.sb.Equals("D2.sb (p2 1)"));
                test(p2.pb == null);
                test(p2.ice_id().Equals("::Test::B"));

                test(ret != null);
                test(ret.sb.Equals("D1.sb (p2 2)"));
                test(ret.pb == null);
                test(ret.ice_id().Equals("::Test::D1"));
            }
            catch(Exception)
            {
                test(false);
            }
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("remainder unmarshaling (3 instances) (AMI)... ");
        Console.Out.Flush();
        {
            AsyncCallback cb = new AsyncCallback();
            testPrx.begin_paramTest3().whenCompleted(cb.response_paramTest3, cb.exception);
            cb.check();
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("remainder unmarshaling (4 instances)... ");
        Console.Out.Flush();
        {
            try
            {
                B b;
                B ret = testPrx.paramTest4(out b);

                test(b != null);
                test(b.sb.Equals("D4.sb (1)"));
                test(b.pb == null);
                test(b.ice_id().Equals("::Test::B"));

                test(ret != null);
                test(ret.sb.Equals("B.sb (2)"));
                test(ret.pb == null);
                test(ret.ice_id().Equals("::Test::B"));
            }
            catch(Exception)
            {
                test(false);
            }
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("remainder unmarshaling (4 instances) (AMI)... ");
        Console.Out.Flush();
        {
            AsyncCallback cb = new AsyncCallback();
            testPrx.begin_paramTest4().whenCompleted(cb.response_paramTest4, cb.exception);
            cb.check();
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("param ptr slicing, instance marshaled in unknown derived as base... ");
        Console.Out.Flush();
        {
            try
            {
                B b1 = new B();
                b1.sb = "B.sb(1)";
                b1.pb = b1;

                D3 d3 = new D3();
                d3.sb = "D3.sb";
                d3.pb = d3;
                d3.sd3 = "D3.sd3";
                d3.pd3 = b1;

                B b2 = new B();
                b2.sb = "B.sb(2)";
                b2.pb = b1;

                B ret = testPrx.returnTest3(d3, b2);

                test(ret != null);
                test(ret.ice_id().Equals("::Test::B"));
                test(ret.sb.Equals("D3.sb"));
                test(ret.pb == ret);
            }
            catch(Exception)
            {
                test(false);
            }
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("param ptr slicing, instance marshaled in unknown derived as base (AMI)... ");
        Console.Out.Flush();
        {
            B b1 = new B();
            b1.sb = "B.sb(1)";
            b1.pb = b1;

            D3 d3 = new D3();
            d3.sb = "D3.sb";
            d3.pb = d3;
            d3.sd3 = "D3.sd3";
            d3.pd3 = b1;

            B b2 = new B();
            b2.sb = "B.sb(2)";
            b2.pb = b1;

            AsyncCallback cb = new AsyncCallback();
            testPrx.begin_returnTest3(d3, b2).whenCompleted(cb.response_returnTest3, cb.exception);
            cb.check();
            B rv = cb.rb;

            test(rv != null);
            test(rv.ice_id().Equals("::Test::B"));
            test(rv.sb.Equals("D3.sb"));
            test(rv.pb == rv);
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("param ptr slicing, instance marshaled in unknown derived as derived... ");
        Console.Out.Flush();
        {
            try
            {
                D1 d11 = new D1();
                d11.sb = "D1.sb(1)";
                d11.pb = d11;
                d11.sd1 = "D1.sd1(1)";

                D3 d3 = new D3();
                d3.sb = "D3.sb";
                d3.pb = d3;
                d3.sd3 = "D3.sd3";
                d3.pd3 = d11;

                D1 d12 = new D1();
                d12.sb = "D1.sb(2)";
                d12.pb = d12;
                d12.sd1 = "D1.sd1(2)";
                d12.pd1 = d11;

                B ret = testPrx.returnTest3(d3, d12);
                test(ret != null);
                test(ret.ice_id().Equals("::Test::B"));
                test(ret.sb.Equals("D3.sb"));
                test(ret.pb == ret);
            }
            catch(Exception)
            {
                test(false);
            }
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("param ptr slicing, instance marshaled in unknown derived as derived (AMI)... ");
        Console.Out.Flush();
        {
            D1 d11 = new D1();
            d11.sb = "D1.sb(1)";
            d11.pb = d11;
            d11.sd1 = "D1.sd1(1)";

            D3 d3 = new D3();
            d3.sb = "D3.sb";
            d3.pb = d3;
            d3.sd3 = "D3.sd3";
            d3.pd3 = d11;

            D1 d12 = new D1();
            d12.sb = "D1.sb(2)";
            d12.pb = d12;
            d12.sd1 = "D1.sd1(2)";
            d12.pd1 = d11;

            AsyncCallback cb = new AsyncCallback();
            testPrx.begin_returnTest3(d3, d12).whenCompleted(cb.response_returnTest3, cb.exception);
            cb.check();
            B rv = cb.rb;

            test(rv != null);
            test(rv.ice_id().Equals("::Test::B"));
            test(rv.sb.Equals("D3.sb"));
            test(rv.pb == rv);
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("sequence slicing... ");
        Console.Out.Flush();
        {
            try
            {
                SS ss;
                {
                    B ss1b = new B();
                    ss1b.sb = "B.sb";
                    ss1b.pb = ss1b;

                    D1 ss1d1 = new D1();
                    ss1d1.sb = "D1.sb";
                    ss1d1.sd1 = "D1.sd1";
                    ss1d1.pb = ss1b;

                    D3 ss1d3 = new D3();
                    ss1d3.sb = "D3.sb";
                    ss1d3.sd3 = "D3.sd3";
                    ss1d3.pb = ss1b;

                    B ss2b = new B();
                    ss2b.sb = "B.sb";
                    ss2b.pb = ss1b;

                    D1 ss2d1 = new D1();
                    ss2d1.sb = "D1.sb";
                    ss2d1.sd1 = "D1.sd1";
                    ss2d1.pb = ss2b;

                    D3 ss2d3 = new D3();
                    ss2d3.sb = "D3.sb";
                    ss2d3.sd3 = "D3.sd3";
                    ss2d3.pb = ss2b;

                    ss1d1.pd1 = ss2b;
                    ss1d3.pd3 = ss2d1;

                    ss2d1.pd1 = ss1d3;
                    ss2d3.pd3 = ss1d1;

                    SS1 ss1 = new SS1();
                    ss1.s = new BSeq(3);
                    ss1.s.Add(ss1b);
                    ss1.s.Add(ss1d1);
                    ss1.s.Add(ss1d3);

                    SS2 ss2 = new SS2();
                    ss2.s = new BSeq(3);
                    ss2.s.Add(ss2b);
                    ss2.s.Add(ss2d1);
                    ss2.s.Add(ss2d3);

                    ss = testPrx.sequenceTest(ss1, ss2);
                }

                test(ss.c1 != null);
                B ss1b2 = ss.c1.s[0];
                B ss1d2 = ss.c1.s[1];
                test(ss.c2 != null);
                B ss1d4 = ss.c1.s[2];

                test(ss.c2 != null);
                B ss2b2 = ss.c2.s[0];
                B ss2d2 = ss.c2.s[1];
                B ss2d4 = ss.c2.s[2];

                test(ss1b2.pb == ss1b2);
                test(ss1d2.pb == ss1b2);
                test(ss1d4.pb == ss1b2);

                test(ss2b2.pb == ss1b2);
                test(ss2d2.pb == ss2b2);
                test(ss2d4.pb == ss2b2);

                test(ss1b2.ice_id().Equals("::Test::B"));
                test(ss1d2.ice_id().Equals("::Test::D1"));
                test(ss1d4.ice_id().Equals("::Test::B"));

                test(ss2b2.ice_id().Equals("::Test::B"));
                test(ss2d2.ice_id().Equals("::Test::D1"));
                test(ss2d4.ice_id().Equals("::Test::B"));
            }
            catch(Exception)
            {
                test(false);
            }
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("sequence slicing (AMI)... ");
        Console.Out.Flush();
        {
            SS ss;
            {
                B ss1b = new B();
                ss1b.sb = "B.sb";
                ss1b.pb = ss1b;

                D1 ss1d1 = new D1();
                ss1d1.sb = "D1.sb";
                ss1d1.sd1 = "D1.sd1";
                ss1d1.pb = ss1b;

                D3 ss1d3 = new D3();
                ss1d3.sb = "D3.sb";
                ss1d3.sd3 = "D3.sd3";
                ss1d3.pb = ss1b;

                B ss2b = new B();
                ss2b.sb = "B.sb";
                ss2b.pb = ss1b;

                D1 ss2d1 = new D1();
                ss2d1.sb = "D1.sb";
                ss2d1.sd1 = "D1.sd1";
                ss2d1.pb = ss2b;

                D3 ss2d3 = new D3();
                ss2d3.sb = "D3.sb";
                ss2d3.sd3 = "D3.sd3";
                ss2d3.pb = ss2b;

                ss1d1.pd1 = ss2b;
                ss1d3.pd3 = ss2d1;

                ss2d1.pd1 = ss1d3;
                ss2d3.pd3 = ss1d1;

                SS1 ss1 = new SS1();
                ss1.s = new BSeq();
                ss1.s.Add(ss1b);
                ss1.s.Add(ss1d1);
                ss1.s.Add(ss1d3);

                SS2 ss2 = new SS2();
                ss2.s = new BSeq();
                ss2.s.Add(ss2b);
                ss2.s.Add(ss2d1);
                ss2.s.Add(ss2d3);

                AsyncCallback cb = new AsyncCallback();
                testPrx.begin_sequenceTest(ss1, ss2).whenCompleted(cb.response_sequenceTest, cb.exception);
                cb.check();
                ss = cb.rss;
            }
            test(ss.c1 != null);
            B ss1b3 = ss.c1.s[0];
            B ss1d5 = ss.c1.s[1];
            test(ss.c2 != null);
            B ss1d6 = ss.c1.s[2];

            test(ss.c2 != null);
            B ss2b3 = ss.c2.s[0];
            B ss2d5 = ss.c2.s[1];
            B ss2d6 = ss.c2.s[2];

            test(ss1b3.pb == ss1b3);
            test(ss1d6.pb == ss1b3);
            test(ss1d6.pb == ss1b3);

            test(ss2b3.pb == ss1b3);
            test(ss2d6.pb == ss2b3);
            test(ss2d6.pb == ss2b3);

            test(ss1b3.ice_id().Equals("::Test::B"));
            test(ss1d5.ice_id().Equals("::Test::D1"));
            test(ss1d6.ice_id().Equals("::Test::B"));

            test(ss2b3.ice_id().Equals("::Test::B"));
            test(ss2d5.ice_id().Equals("::Test::D1"));
            test(ss2d6.ice_id().Equals("::Test::B"));
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("dictionary slicing... ");
        Console.Out.Flush();
        {
            try
            {
                Dictionary<int, B> bin = new Dictionary<int, B>();
                Dictionary<int, B> bout;
                Dictionary<int, B> ret;
                int i;
                for(i = 0; i < 10; ++i)
                {
                    string s = "D1." + i.ToString();
                    D1 d1 = new D1();
                    d1.sb = s;
                    d1.pb = d1;
                    d1.sd1 = s;
                    bin[i] = d1;
                }

                ret = testPrx.dictionaryTest(bin, out bout);

                test(bout.Count == 10);
                for(i = 0; i < 10; ++i)
                {
                    B b = bout[i * 10];
                    test(b != null);
                    string s = "D1." + i.ToString();
                    test(b.sb.Equals(s));
                    test(b.pb != null);
                    test(b.pb != b);
                    test(b.pb.sb.Equals(s));
                    test(b.pb.pb == b.pb);
                }

                test(ret.Count == 10);
                for(i = 0; i < 10; ++i)
                {
                    B b = ret[i * 20];
                    test(b != null);
                    string s = "D1." + (i * 20).ToString();
                    test(b.sb.Equals(s));
                    test(b.pb == (i == 0 ? (B)null : ret[(i - 1) * 20]));
                    D1 d1 = (D1) b;
                    test(d1 != null);
                    test(d1.sd1.Equals(s));
                    test(d1.pd1 == d1);
                }
            }
            catch(Exception)
            {
                test(false);
            }
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("dictionary slicing (AMI)... ");
        Console.Out.Flush();
        {
            Dictionary<int, B> bin = new Dictionary<int, B>();
            Dictionary<int, B> bout;
            Dictionary<int, B> rv;
            int i;
            for(i = 0; i < 10; ++i)
            {
                string s = "D1." + i.ToString();
                D1 d1 = new D1();
                d1.sb = s;
                d1.pb = d1;
                d1.sd1 = s;
                bin[i] = d1;
            }

            AsyncCallback cb = new AsyncCallback();
            testPrx.begin_dictionaryTest(bin).whenCompleted(cb.response_dictionaryTest, cb.exception);
            cb.check();
            bout = cb.obdict;
            rv = cb.rbdict;

            test(bout.Count == 10);
            for(i = 0; i < 10; ++i)
            {
                B b = bout[i * 10];
                test(b != null);
                string s = "D1." + i.ToString();
                test(b.sb.Equals(s));
                test(b.pb != null);
                test(b.pb != b);
                test(b.pb.sb.Equals(s));
                test(b.pb.pb == b.pb);
            }

            test(rv.Count == 10);
            for(i = 0; i < 10; ++i)
            {
                B b = rv[i * 20];
                test(b != null);
                string s = "D1." + (i * 20).ToString();
                test(b.sb.Equals(s));
                test(b.pb == (i == 0 ? (B)null : rv[(i - 1) * 20]));
                D1 d1 = (D1) b;
                test(d1 != null);
                test(d1.sd1.Equals(s));
                test(d1.pd1 == d1);
            }
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("base exception thrown as base exception... ");
        Console.Out.Flush();
        {
            try
            {
                testPrx.throwBaseAsBase();
                test(false);
            }
            catch(BaseException e)
            {
                test(e.GetType().FullName.Equals("Test.BaseException"));
                test(e.sbe.Equals("sbe"));
                test(e.pb != null);
                test(e.pb.sb.Equals("sb"));
                test(e.pb.pb == e.pb);
            }
            catch(Exception)
            {
                test(false);
            }
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("base exception thrown as base exception (AMI)... ");
        Console.Out.Flush();
        {
            AsyncCallback cb = new AsyncCallback();
            testPrx.begin_throwBaseAsBase().whenCompleted(cb.response, cb.exception_throwBaseAsBase);
            cb.check();
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("derived exception thrown as base exception... ");
        Console.Out.Flush();
        {
            try
            {
                testPrx.throwDerivedAsBase();
                test(false);
            }
            catch(DerivedException e)
            {
                test(e.GetType().FullName.Equals("Test.DerivedException"));
                test(e.sbe.Equals("sbe"));
                test(e.pb != null);
                test(e.pb.sb.Equals("sb1"));
                test(e.pb.pb == e.pb);
                test(e.sde.Equals("sde1"));
                test(e.pd1 != null);
                test(e.pd1.sb.Equals("sb2"));
                test(e.pd1.pb == e.pd1);
                test(e.pd1.sd1.Equals("sd2"));
                test(e.pd1.pd1 == e.pd1);
            }
            catch(Exception)
            {
                test(false);
            }
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("derived exception thrown as base exception (AMI)... ");
        Console.Out.Flush();
        {
            AsyncCallback cb = new AsyncCallback();
            testPrx.begin_throwDerivedAsBase().whenCompleted(cb.response, cb.exception_throwDerivedAsBase);
            cb.check();
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("derived exception thrown as derived exception... ");
        Console.Out.Flush();
        {
            try
            {
                testPrx.throwDerivedAsDerived();
                test(false);
            }
            catch(DerivedException e)
            {
                test(e.GetType().FullName.Equals("Test.DerivedException"));
                test(e.sbe.Equals("sbe"));
                test(e.pb != null);
                test(e.pb.sb.Equals("sb1"));
                test(e.pb.pb == e.pb);
                test(e.sde.Equals("sde1"));
                test(e.pd1 != null);
                test(e.pd1.sb.Equals("sb2"));
                test(e.pd1.pb == e.pd1);
                test(e.pd1.sd1.Equals("sd2"));
                test(e.pd1.pd1 == e.pd1);
            }
            catch(Exception)
            {
                test(false);
            }
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("derived exception thrown as derived exception (AMI)... ");
        Console.Out.Flush();
        {
            AsyncCallback cb = new AsyncCallback();
            testPrx.begin_throwDerivedAsDerived().whenCompleted(cb.response, cb.exception_throwDerivedAsDerived);
            cb.check();
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("unknown derived exception thrown as base exception... ");
        Console.Out.Flush();
        {
            try
            {
                testPrx.throwUnknownDerivedAsBase();
                test(false);
            }
            catch(BaseException e)
            {
                test(e.GetType().FullName.Equals("Test.BaseException"));
                test(e.sbe.Equals("sbe"));
                test(e.pb != null);
                test(e.pb.sb.Equals("sb d2"));
                test(e.pb.pb == e.pb);
            }
            catch(Exception)
            {
                test(false);
            }
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("unknown derived exception thrown as base exception (AMI)... ");
        Console.Out.Flush();
        {
            AsyncCallback cb = new AsyncCallback();
            testPrx.begin_throwUnknownDerivedAsBase().whenCompleted(
                        cb.response, cb.exception_throwUnknownDerivedAsBase);
            cb.check();
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("forward-declared class... ");
        Console.Out.Flush();
        {
            try
            {
                Forward f;
                testPrx.useForward(out f);
                test(f != null);
            }
            catch(Exception)
            {
                test(false);
            }
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("forward-declared class (AMI)... ");
        Console.Out.Flush();
        {
            AsyncCallback cb = new AsyncCallback();
            testPrx.begin_useForward().whenCompleted(cb.response_useForward, cb.exception);
            cb.check();
        }
        Console.Out.WriteLine("ok");

        return testPrx;
    }
Example #21
0
    public static Test.MyClassPrx allTests(Ice.Communicator communicator)
    {
        Ice.ObjectPrx baseProxy = communicator.stringToProxy("test:default -p 12010");
        Test.MyClassPrx cl = Test.MyClassPrxHelper.checkedCast(baseProxy);
        Test.MyClassPrx oneway = Test.MyClassPrxHelper.uncheckedCast(cl.ice_oneway());

        Console.Out.Write("testing ice_invoke... ");
        Console.Out.Flush();

        {
            byte[] inParams, outParams;
            if(!oneway.ice_invoke("opOneway", Ice.OperationMode.Normal, null, out outParams))
            {
                test(false);
            }

            Ice.OutputStream outS = Ice.Util.createOutputStream(communicator);
            outS.writeString(testString);
            inParams = outS.finished();

            if(cl.ice_invoke("opString", Ice.OperationMode.Normal, inParams, out outParams))
            {
                Ice.InputStream inS = Ice.Util.createInputStream(communicator, outParams);
                string s = inS.readString();
                test(s.Equals(testString));
                s = inS.readString();
                test(s.Equals(testString));
            }
            else
            {
                test(false);
            }
        }

        {
            byte[] outParams;
            if(cl.ice_invoke("opException", Ice.OperationMode.Normal, null, out outParams))
            {
                test(false);
            }
            else
            {
                Ice.InputStream inS = Ice.Util.createInputStream(communicator, outParams);
                try
                {
                    inS.throwException();
                }
                catch(Test.MyException)
                {
                }
                catch(System.Exception)
                {
                    test(false);
                }
            }
        }

        Console.Out.WriteLine("ok");

        Console.Out.Write("testing asynchronous ice_invoke... ");
        Console.Out.Flush();

        {
            byte[] inParams, outParams;
            Ice.AsyncResult result = oneway.begin_ice_invoke("opOneway", Ice.OperationMode.Normal, null);
            if(!oneway.end_ice_invoke(out outParams, result))
            {
                test(false);
            }

            Ice.OutputStream outS = Ice.Util.createOutputStream(communicator);
            outS.writeString(testString);
            inParams = outS.finished();

            // begin_ice_invoke with no callback
            result = cl.begin_ice_invoke("opString", Ice.OperationMode.Normal, inParams);
            if(cl.end_ice_invoke(out outParams, result))
            {
                Ice.InputStream inS = Ice.Util.createInputStream(communicator, outParams);
                string s = inS.readString();
                test(s.Equals(testString));
                s = inS.readString();
                test(s.Equals(testString));
            }
            else
            {
                test(false);
            }

            // begin_ice_invoke with Callback
            Callback cb = new Callback(communicator, false);
            cl.begin_ice_invoke("opString", Ice.OperationMode.Normal, inParams, cb.opString, null);
            cb.check();

            // begin_ice_invoke with Callback with cookie
            cb = new Callback(communicator, true);
            cl.begin_ice_invoke("opString", Ice.OperationMode.Normal, inParams, cb.opString, new Cookie());
            cb.check();

            // begin_ice_invoke with Callback_Object_ice_invoke
            cb = new Callback(communicator, true);
            cl.begin_ice_invoke("opString", Ice.OperationMode.Normal, inParams).whenCompleted(cb.opStringNC, null);
            cb.check();
        }

        {
            // begin_ice_invoke with no callback
            Ice.AsyncResult result = cl.begin_ice_invoke("opException", Ice.OperationMode.Normal, null);
            byte[] outParams;
            if(cl.end_ice_invoke(out outParams, result))
            {
                test(false);
            }
            else
            {
                Ice.InputStream inS = Ice.Util.createInputStream(communicator, outParams);
                try
                {
                    inS.throwException();
                }
                catch(Test.MyException)
                {
                }
                catch(System.Exception)
                {
                    test(false);
                }
            }

            // begin_ice_invoke with Callback
            Callback cb = new Callback(communicator, false);
            cl.begin_ice_invoke("opException", Ice.OperationMode.Normal, null, cb.opException, null);
            cb.check();

            // begin_ice_invoke with Callback with cookie
            cb = new Callback(communicator, true);
            cl.begin_ice_invoke("opException", Ice.OperationMode.Normal, null, cb.opException, new Cookie());
            cb.check();

            // begin_ice_invoke with Callback_Object_ice_invoke
            cb = new Callback(communicator, true);
            cl.begin_ice_invoke("opException", Ice.OperationMode.Normal, null).whenCompleted(cb.opExceptionNC, null);
            cb.check();
        }

        Console.Out.WriteLine("ok");

        return cl;
    }
Example #22
0
    public static InitialPrx allTests(Ice.Communicator communicator)
#endif
    {
        Ice.ObjectFactory factory = new MyObjectFactory();
        communicator.addObjectFactory(factory, "::Test::B");
        communicator.addObjectFactory(factory, "::Test::C");
        communicator.addObjectFactory(factory, "::Test::D");
        communicator.addObjectFactory(factory, "::Test::E");
        communicator.addObjectFactory(factory, "::Test::F");
        communicator.addObjectFactory(factory, "::Test::I");
        communicator.addObjectFactory(factory, "::Test::J");
        communicator.addObjectFactory(factory, "::Test::H");

        Write("testing stringToProxy... ");
        Flush();
        String @ref = "initial:default -p 12010";
        Ice.ObjectPrx @base = communicator.stringToProxy(@ref);
        test(@base != null);
        WriteLine("ok");
        
        Write("testing checked cast... ");
        Flush();
        InitialPrx initial = InitialPrxHelper.checkedCast(@base);
        test(initial != null);
        test(initial.Equals(@base));
        WriteLine("ok");
        
        Write("getting B1... ");
        Flush();
        B b1 = initial.getB1();
        test(b1 != null);
        WriteLine("ok");
        
        Write("getting B2... ");
        Flush();
        B b2 = initial.getB2();
        test(b2 != null);
        WriteLine("ok");
        
        Write("getting C... ");
        Flush();
        C c = initial.getC();
        test(c != null);
        WriteLine("ok");
        
        Write("getting D... ");
        Flush();
        D d = initial.getD();
        test(d != null);
        WriteLine("ok");
        
        Write("checking consistency... ");
        Flush();
        test(b1 != b2);
        //test(b1 != c);
        //test(b1 != d);
        //test(b2 != c);
        //test(b2 != d);
        //test(c != d);
        test(b1.theB == b1);
        test(b1.theC == null);
        test(b1.theA is B);
        test(((B) b1.theA).theA == b1.theA);
        test(((B) b1.theA).theB == b1);
        //test(((B)b1.theA).theC is C); // Redundant -- theC is always of type C
        test(((C) (((B) b1.theA).theC)).theB == b1.theA);
        test(b1.preMarshalInvoked);
        test(b1.postUnmarshalInvoked());
        test(b1.theA.preMarshalInvoked);
        test(b1.theA.postUnmarshalInvoked());
        test(((B)b1.theA).theC.preMarshalInvoked);
        test(((B)b1.theA).theC.postUnmarshalInvoked());

        // More tests possible for b2 and d, but I think this is already
        // sufficient.
        test(b2.theA == b2);
        test(d.theC == null);
        WriteLine("ok");
        
        Write("getting B1, B2, C, and D all at once... ");
        Flush();
        B b1out;
        B b2out;
        C cout;
        D dout;
        initial.getAll(out b1out, out b2out, out cout, out dout);
        test(b1out != null);
        test(b2out != null);
        test(cout != null);
        test(dout != null);
        WriteLine("ok");
        
        Write("checking consistency... ");
        Flush();
        test(b1out != b2out);
        test(b1out.theA == b2out);
        test(b1out.theB == b1out);
        test(b1out.theC == null);
        test(b2out.theA == b2out);
        test(b2out.theB == b1out);
        test(b2out.theC == cout);
        test(cout.theB == b2out);
        test(dout.theA == b1out);
        test(dout.theB == b2out);
        test(dout.theC == null);
        test(dout.preMarshalInvoked);
        test(dout.postUnmarshalInvoked());
        test(dout.theA.preMarshalInvoked);
        test(dout.theA.postUnmarshalInvoked()); 
        test(dout.theB.preMarshalInvoked);
        test(dout.theB.postUnmarshalInvoked());
        test(dout.theB.theC.preMarshalInvoked);
        test(dout.theB.theC.postUnmarshalInvoked());

        WriteLine("ok");

        Write("testing protected members... ");
        Flush();
        E e = initial.getE();
        test(e.checkValues());
        System.Reflection.BindingFlags flags = System.Reflection.BindingFlags.NonPublic |
                                               System.Reflection.BindingFlags.Public |
                                               System.Reflection.BindingFlags.Instance;
        test(!typeof(E).GetField("i", flags).IsPublic && !typeof(E).GetField("i", flags).IsPrivate);
        test(!typeof(E).GetField("s", flags).IsPublic && !typeof(E).GetField("s", flags).IsPrivate);
        F f = initial.getF();
        test(f.checkValues());
        test(f.e2.checkValues());
        test(!typeof(F).GetField("e1", flags).IsPublic && !typeof(F).GetField("e1", flags).IsPrivate);
        test(typeof(F).GetField("e2", flags).IsPublic && !typeof(F).GetField("e2", flags).IsPrivate);
        WriteLine("ok");

        Write("getting I, J and H... ");
        Flush();
        I i = initial.getI();
        test(i != null);
        I j = initial.getJ();
        test(j != null && ((J)j) != null);
        I h = initial.getH();
        test(h != null && ((H)h) != null);
        WriteLine("ok");
        
        Write("getting D1... ");
        Flush();
        D1 d1 = new D1(new A1("a1"), new A1("a2"), new A1("a3"), new A1("a4"));
        d1 = initial.getD1(d1);
        test(d1.a1.name.Equals("a1"));
        test(d1.a2.name.Equals("a2"));
        test(d1.a3.name.Equals("a3"));
        test(d1.a4.name.Equals("a4"));
        WriteLine("ok");
        
        Write("throw EDerived... ");
        Flush();
        try
        {
            initial.throwEDerived();
            test(false);
        }
        catch(EDerived ederived)
        {
            test(ederived.a1.name.Equals("a1"));
            test(ederived.a2.name.Equals("a2"));
            test(ederived.a3.name.Equals("a3"));
            test(ederived.a4.name.Equals("a4"));
        }
        WriteLine("ok");

        Write("setting I... ");
        Flush();
        initial.setI(i);
        initial.setI(j);
        initial.setI(h);
        WriteLine("ok");

        Write("testing sequences...");
        Flush();
        try
        {
            Base[] inS = new Base[0];
            Base[] outS;
            Base[] retS;
            retS = initial.opBaseSeq(inS, out outS);
            
            inS = new Base[1];
            inS[0] = new Base(new S(), "");
            retS = initial.opBaseSeq(inS, out outS);
            test(retS.Length == 1 && outS.Length == 1);
        }
        catch(Ice.OperationNotExistException)
        {
        }
        WriteLine("ok");

        Write("testing compact ID...");
        Flush();
        try
        {
            test(initial.getCompact() != null);
        }
        catch(Ice.OperationNotExistException)
        {
        }
        WriteLine("ok");

        Write("testing UnexpectedObjectException...");
        Flush();
        @ref = "uoet:default -p 12010";
        @base = communicator.stringToProxy(@ref);
        test(@base != null);
        UnexpectedObjectExceptionTestPrx uoet = UnexpectedObjectExceptionTestPrxHelper.uncheckedCast(@base);
        test(uoet != null);
        try
        {
            uoet.op();
            test(false);
        }
        catch(Ice.UnexpectedObjectException ex)
        {
            test(ex.type.Equals("::Test::AlsoEmpty"));
            test(ex.expectedType.Equals("::Test::Empty"));
        }
        catch(System.Exception ex)
        {
            WriteLine(ex.ToString());
            test(false);
        }
        WriteLine("ok");
#if SILVERLIGHT
        initial.shutdown();
#else
        return initial;
#endif
    }
Example #23
0
    public static void allTests(Ice.Communicator communicator)
#endif
    {
        string sref = "test:default -p 12010";
        Ice.ObjectPrx obj = communicator.stringToProxy(sref);
        test(obj != null);

        Test.TestIntfPrx p = Test.TestIntfPrxHelper.uncheckedCast(obj);

        sref = "testController:tcp -p 12011";
        obj = communicator.stringToProxy(sref);
        test(obj != null);

        Test.TestIntfControllerPrx testController = Test.TestIntfControllerPrxHelper.uncheckedCast(obj);

        Write("testing dispatcher... ");
        Flush();
        {
            p.op();

            Callback cb = new Callback();
            p.begin_op().whenCompleted(cb.response, cb.exception);
            cb.check();

            TestIntfPrx i = (TestIntfPrx)p.ice_adapterId("dummy");
            i.begin_op().whenCompleted(cb.exception);
            cb.check();

            //
            // Expect InvocationTimeoutException.
            //
            {
                Test.TestIntfPrx to = Test.TestIntfPrxHelper.uncheckedCast(p.ice_invocationTimeout(250));
                to.begin_sleep(500).whenCompleted(
                    () =>
                    {
                        test(false);
                    },
                    (Ice.Exception ex) => {
                        test(ex is Ice.InvocationTimeoutException);
                        test(Dispatcher.isDispatcherThread());
                        cb.called();
                    });
                cb.check();
            }

            testController.holdAdapter();
            Test.Callback_TestIntf_opWithPayload resp = cb.payload;
            Ice.ExceptionCallback excb = cb.ignoreEx;
            Ice.SentCallback scb = cb.sent;

            byte[] seq = new byte[10 * 1024];
            (new System.Random()).NextBytes(seq);
            Ice.AsyncResult r;
            while((r = p.begin_opWithPayload(seq).whenCompleted(resp, excb).whenSent(scb)).sentSynchronously());
            testController.resumeAdapter();
            r.waitForCompleted();
        }
        WriteLine("ok");

        p.shutdown();
    }
Example #24
0
    //
    // Change this proxy's communicator, while keeping its invocation timeout
    //
    private static Ice.RemoteLoggerPrx changeCommunicator(Ice.RemoteLoggerPrx prx, Ice.Communicator communicator)
    {
        if(prx == null)
        {
            return null;
        }

        Ice.ObjectPrx result = communicator.stringToProxy(prx.ToString());
        return Ice.RemoteLoggerPrxHelper.uncheckedCast(result.ice_invocationTimeout(prx.ice_getInvocationTimeout()));
    }
Example #25
0
    public static void allTests(Ice.Communicator communicator)
    {
        string @ref = "communicator:default -p 12010";
        RemoteCommunicatorPrx com = RemoteCommunicatorPrxHelper.uncheckedCast(communicator.stringToProxy(@ref));

        System.Random rand = new System.Random(unchecked((int)System.DateTime.Now.Ticks));

        Console.Out.Write("testing binding with single endpoint... ");
        Console.Out.Flush();
        {
            RemoteObjectAdapterPrx adapter = com.createObjectAdapter("Adapter", "default");

            TestIntfPrx test1 = adapter.getTestIntf();
            TestIntfPrx test2 = adapter.getTestIntf();
            test(test1.ice_getConnection() == test2.ice_getConnection());

            test1.ice_ping();
            test2.ice_ping();

            com.deactivateObjectAdapter(adapter);

            TestIntfPrx test3 = TestIntfPrxHelper.uncheckedCast(test1);
            test(test3.ice_getConnection() == test1.ice_getConnection());
            test(test3.ice_getConnection() == test2.ice_getConnection());

            try
            {
                test3.ice_ping();
                test(false);
            }
            catch(Ice.ConnectionRefusedException)
            {
            }
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("testing binding with multiple endpoints... ");
        Console.Out.Flush();
        {
            ArrayList adapters = new ArrayList();
            adapters.Add(com.createObjectAdapter("Adapter11", "default"));
            adapters.Add(com.createObjectAdapter("Adapter12", "default"));
            adapters.Add(com.createObjectAdapter("Adapter13", "default"));

            //
            // Ensure that when a connection is opened it's reused for new
            // proxies and that all endpoints are eventually tried.
            //
            List<string> names = new List<string>();
            names.Add("Adapter11");
            names.Add("Adapter12");
            names.Add("Adapter13");
            while(names.Count > 0)
            {
                ArrayList adpts = new ArrayList(adapters);

                TestIntfPrx test1 = createTestIntfPrx(adpts);
                shuffle(ref adpts);
                TestIntfPrx test2 = createTestIntfPrx(adpts);
                shuffle(ref adpts);
                TestIntfPrx test3 = createTestIntfPrx(adpts);
                test1.ice_ping();
                test(test1.ice_getConnection() == test2.ice_getConnection());
                test(test2.ice_getConnection() == test3.ice_getConnection());

                names.Remove(test1.getAdapterName());
                test1.ice_getConnection().close(false);
            }

            //
            // Ensure that the proxy correctly caches the connection (we
            // always send the request over the same connection.)
            //
            {
                foreach(RemoteObjectAdapterPrx adpt in adapters)
                {
                    adpt.getTestIntf().ice_ping();
                }

                TestIntfPrx t = createTestIntfPrx(adapters);
                string name = t.getAdapterName();
                int nRetry = 10;
                int i;
                for(i = 0; i < nRetry && t.getAdapterName().Equals(name); i++);
                test(i == nRetry);

                foreach(RemoteObjectAdapterPrx adpt in adapters)
                {
                    adpt.getTestIntf().ice_getConnection().close(false);
                }
            }

            //
            // Deactivate an adapter and ensure that we can still
            // establish the connection to the remaining adapters.
            //
            com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[0]);
            names.Add("Adapter12");
            names.Add("Adapter13");
            while(names.Count > 0)
            {
                ArrayList adpts = new ArrayList(adapters);

                TestIntfPrx test1 = createTestIntfPrx(adpts);
                shuffle(ref adpts);
                TestIntfPrx test2 = createTestIntfPrx(adpts);
                shuffle(ref adpts);
                TestIntfPrx test3 = createTestIntfPrx(adpts);

                test(test1.ice_getConnection() == test2.ice_getConnection());
                test(test2.ice_getConnection() == test3.ice_getConnection());

                names.Remove(test1.getAdapterName());
                test1.ice_getConnection().close(false);
            }

            //
            // Deactivate an adapter and ensure that we can still
            // establish the connection to the remaining adapter.
            //
            com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[2]);
            TestIntfPrx obj = createTestIntfPrx(adapters);
            test(obj.getAdapterName().Equals("Adapter12"));

            deactivate(com, adapters);
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("testing binding with multiple random endpoints... ");
        Console.Out.Flush();
        {
            RemoteObjectAdapterPrx[] adapters = new RemoteObjectAdapterPrx[5];
            adapters[0] = com.createObjectAdapter("AdapterRandom11", "default");
            adapters[1] = com.createObjectAdapter("AdapterRandom12", "default");
            adapters[2] = com.createObjectAdapter("AdapterRandom13", "default");
            adapters[3] = com.createObjectAdapter("AdapterRandom14", "default");
            adapters[4] = com.createObjectAdapter("AdapterRandom15", "default");

            int count;
            if(IceInternal.AssemblyUtil.platform_ == IceInternal.AssemblyUtil.Platform.Windows)
            {
                count = 20;
            }
            else
            {
                count = 60;
            }

            int adapterCount = adapters.Length;
            while(--count > 0)
            {
                TestIntfPrx[] proxies;
                if(IceInternal.AssemblyUtil.platform_ == IceInternal.AssemblyUtil.Platform.Windows)
                {
                    if(count == 10)
                    {
                        com.deactivateObjectAdapter(adapters[4]);
                        --adapterCount;
                    }
                    proxies = new TestIntfPrx[10];
                }
                else
                {
                    if(count < 60 && count % 10 == 0)
                    {
                        com.deactivateObjectAdapter(adapters[count / 10 - 1]);
                        --adapterCount;
                    }
                    proxies = new TestIntfPrx[40];
                }

                int i;
                for(i = 0; i < proxies.Length; ++i)
                {
                    RemoteObjectAdapterPrx[] adpts = new RemoteObjectAdapterPrx[rand.Next(adapters.Length)];
                    if(adpts.Length == 0)
                    {
                        adpts = new RemoteObjectAdapterPrx[1];
                    }
                    for(int j = 0; j < adpts.Length; ++j)
                    {
                        adpts[j] = adapters[rand.Next(adapters.Length)];
                    }
                    proxies[i] = createTestIntfPrx(new ArrayList(adpts));
                }

                for(i = 0; i < proxies.Length; i++)
                {
                    proxies[i].begin_getAdapterName();
                }
                for(i = 0; i < proxies.Length; i++)
                {
                    try
                    {
                        proxies[i].ice_ping();
                    }
                    catch(Ice.LocalException)
                    {
                    }
                }

                ArrayList connections = new ArrayList();
                for(i = 0; i < proxies.Length; i++)
                {
                    if(proxies[i].ice_getCachedConnection() != null)
                    {
                        if(!connections.Contains(proxies[i].ice_getCachedConnection()))
                        {
                            connections.Add(proxies[i].ice_getCachedConnection());
                        }
                    }
                }
                test(connections.Count <= adapterCount);

                foreach(RemoteObjectAdapterPrx a in adapters)
                {
                    try
                    {
                        a.getTestIntf().ice_getConnection().close(false);
                    }
                    catch(Ice.LocalException)
                    {
                        // Expected if adapter is down.
                    }
                }
            }
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("testing binding with multiple endpoints and AMI... ");
        Console.Out.Flush();
        {
            ArrayList adapters = new ArrayList();
            adapters.Add(com.createObjectAdapter("AdapterAMI11", "default"));
            adapters.Add(com.createObjectAdapter("AdapterAMI12", "default"));
            adapters.Add(com.createObjectAdapter("AdapterAMI13", "default"));

            //
            // Ensure that when a connection is opened it's reused for new
            // proxies and that all endpoints are eventually tried.
            //
            List<string> names = new List<string>();
            names.Add("AdapterAMI11");
            names.Add("AdapterAMI12");
            names.Add("AdapterAMI13");
            while(names.Count > 0)
            {
                ArrayList adpts = new ArrayList(adapters);

                TestIntfPrx test1 = createTestIntfPrx(adpts);
                shuffle(ref adpts);
                TestIntfPrx test2 = createTestIntfPrx(adpts);
                shuffle(ref adpts);
                TestIntfPrx test3 = createTestIntfPrx(adpts);
                test1.ice_ping();
                test(test1.ice_getConnection() == test2.ice_getConnection());
                test(test2.ice_getConnection() == test3.ice_getConnection());

                names.Remove(getAdapterNameWithAMI(test1));
                test1.ice_getConnection().close(false);
            }

            //
            // Ensure that the proxy correctly caches the connection (we
            // always send the request over the same connection.)
            //
            {
                foreach(RemoteObjectAdapterPrx adpt in adapters)
                {
                    adpt.getTestIntf().ice_ping();
                }

                TestIntfPrx t = createTestIntfPrx(adapters);
                string name = getAdapterNameWithAMI(t);
                int nRetry = 10;
                int i;
                for(i = 0; i < nRetry && getAdapterNameWithAMI(t).Equals(name); i++);
                test(i == nRetry);

                foreach(RemoteObjectAdapterPrx adpt in adapters)
                {
                    adpt.getTestIntf().ice_getConnection().close(false);
                }
            }

            //
            // Deactivate an adapter and ensure that we can still
            // establish the connection to the remaining adapters.
            //
            com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[0]);
            names.Add("AdapterAMI12");
            names.Add("AdapterAMI13");
            while(names.Count > 0)
            {
                ArrayList adpts = new ArrayList(adapters);

                TestIntfPrx test1 = createTestIntfPrx(adpts);
                shuffle(ref adpts);
                TestIntfPrx test2 = createTestIntfPrx(adpts);
                shuffle(ref adpts);
                TestIntfPrx test3 = createTestIntfPrx(adpts);

                test(test1.ice_getConnection() == test2.ice_getConnection());
                test(test2.ice_getConnection() == test3.ice_getConnection());

                names.Remove(getAdapterNameWithAMI(test1));
                test1.ice_getConnection().close(false);
            }

            //
            // Deactivate an adapter and ensure that we can still
            // establish the connection to the remaining adapter.
            //
            com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[2]);
            TestIntfPrx obj = createTestIntfPrx(adapters);
            test(getAdapterNameWithAMI(obj).Equals("AdapterAMI12"));

            deactivate(com, adapters);
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("testing random endpoint selection... ");
        Console.Out.Flush();
        {
            ArrayList adapters = new ArrayList();
            adapters.Add(com.createObjectAdapter("Adapter21", "default"));
            adapters.Add(com.createObjectAdapter("Adapter22", "default"));
            adapters.Add(com.createObjectAdapter("Adapter23", "default"));

            TestIntfPrx obj = createTestIntfPrx(adapters);
            test(obj.ice_getEndpointSelection() == Ice.EndpointSelectionType.Random);

            List<string> names = new List<string>();
            names.Add("Adapter21");
            names.Add("Adapter22");
            names.Add("Adapter23");
            while(names.Count > 0)
            {
                names.Remove(obj.getAdapterName());
                obj.ice_getConnection().close(false);
            }

            obj = TestIntfPrxHelper.uncheckedCast(obj.ice_endpointSelection(Ice.EndpointSelectionType.Random));
            test(obj.ice_getEndpointSelection() == Ice.EndpointSelectionType.Random);

            names.Add("Adapter21");
            names.Add("Adapter22");
            names.Add("Adapter23");
            while(names.Count > 0)
            {
                names.Remove(obj.getAdapterName());
                obj.ice_getConnection().close(false);
            }

            deactivate(com, adapters);
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("testing ordered endpoint selection... ");
        Console.Out.Flush();
        {
            ArrayList adapters = new ArrayList();
            adapters.Add(com.createObjectAdapter("Adapter31", "default"));
            adapters.Add(com.createObjectAdapter("Adapter32", "default"));
            adapters.Add(com.createObjectAdapter("Adapter33", "default"));

            TestIntfPrx obj = createTestIntfPrx(adapters);
            obj = TestIntfPrxHelper.uncheckedCast(obj.ice_endpointSelection(Ice.EndpointSelectionType.Ordered));
            test(obj.ice_getEndpointSelection() == Ice.EndpointSelectionType.Ordered);
            int nRetry = 3;
            int i;

            //
            // Ensure that endpoints are tried in order by deactiving the adapters
            // one after the other.
            //
            for(i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter31"); i++);
            test(i == nRetry);
            com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[0]);
            for(i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter32"); i++);
            test(i == nRetry);
            com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[1]);
            for(i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter33"); i++);
            test(i == nRetry);
            com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[2]);

            try
            {
                obj.getAdapterName();
            }
            catch(Ice.ConnectionRefusedException)
            {
            }

            Ice.Endpoint[] endpoints = obj.ice_getEndpoints();

            adapters.Clear();

            //
            // Now, re-activate the adapters with the same endpoints in the opposite
            // order.
            //
            adapters.Add(com.createObjectAdapter("Adapter36", endpoints[2].ToString()));
            for(i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter36"); i++);
            test(i == nRetry);
            obj.ice_getConnection().close(false);
            adapters.Add(com.createObjectAdapter("Adapter35", endpoints[1].ToString()));
            for(i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter35"); i++);
            test(i == nRetry);
            obj.ice_getConnection().close(false);
            adapters.Add(com.createObjectAdapter("Adapter34", endpoints[0].ToString()));
            for(i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter34"); i++);
            test(i == nRetry);

            deactivate(com, adapters);
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("testing per request binding with single endpoint... ");
        Console.Out.Flush();
        {
            RemoteObjectAdapterPrx adapter = com.createObjectAdapter("Adapter41", "default");

            TestIntfPrx test1 = TestIntfPrxHelper.uncheckedCast(adapter.getTestIntf().ice_connectionCached(false));
            TestIntfPrx test2 = TestIntfPrxHelper.uncheckedCast(adapter.getTestIntf().ice_connectionCached(false));
            test(!test1.ice_isConnectionCached());
            test(!test2.ice_isConnectionCached());
            test(test1.ice_getConnection() == test2.ice_getConnection());

            test1.ice_ping();

            com.deactivateObjectAdapter(adapter);

            TestIntfPrx test3 = TestIntfPrxHelper.uncheckedCast(test1);
            try
            {
                test(test3.ice_getConnection() == test1.ice_getConnection());
                test(false);
            }
            catch(Ice.ConnectionRefusedException)
            {
            }
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("testing per request binding with multiple endpoints... ");
        Console.Out.Flush();
        {
            ArrayList adapters = new ArrayList();
            adapters.Add(com.createObjectAdapter("Adapter51", "default"));
            adapters.Add(com.createObjectAdapter("Adapter52", "default"));
            adapters.Add(com.createObjectAdapter("Adapter53", "default"));

            TestIntfPrx obj = TestIntfPrxHelper.uncheckedCast(createTestIntfPrx(adapters).ice_connectionCached(false));
            test(!obj.ice_isConnectionCached());

            List<string> names = new List<string>();
            names.Add("Adapter51");
            names.Add("Adapter52");
            names.Add("Adapter53");
            while(names.Count > 0)
            {
                names.Remove(obj.getAdapterName());
            }

            com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[0]);

            names.Add("Adapter52");
            names.Add("Adapter53");
            while(names.Count > 0)
            {
                names.Remove(obj.getAdapterName());
            }

            com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[2]);

            test(obj.getAdapterName().Equals("Adapter52"));

            deactivate(com, adapters);
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("testing per request binding with multiple endpoints and AMI... ");
        Console.Out.Flush();
        {
            ArrayList adapters = new ArrayList();
            adapters.Add(com.createObjectAdapter("AdapterAMI51", "default"));
            adapters.Add(com.createObjectAdapter("AdapterAMI52", "default"));
            adapters.Add(com.createObjectAdapter("AdapterAMI53", "default"));

            TestIntfPrx obj = TestIntfPrxHelper.uncheckedCast(createTestIntfPrx(adapters).ice_connectionCached(false));
            test(!obj.ice_isConnectionCached());

            List<string> names = new List<string>();
            names.Add("AdapterAMI51");
            names.Add("AdapterAMI52");
            names.Add("AdapterAMI53");
            while(names.Count > 0)
            {
                names.Remove(getAdapterNameWithAMI(obj));
            }

            com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[0]);

            names.Add("AdapterAMI52");
            names.Add("AdapterAMI53");
            while(names.Count > 0)
            {
                names.Remove(getAdapterNameWithAMI(obj));
            }

            com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[2]);

            test(getAdapterNameWithAMI(obj).Equals("AdapterAMI52"));

            deactivate(com, adapters);
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("testing per request binding and ordered endpoint selection... ");
        Console.Out.Flush();
        {
            ArrayList adapters = new ArrayList();
            adapters.Add(com.createObjectAdapter("Adapter61", "default"));
            adapters.Add(com.createObjectAdapter("Adapter62", "default"));
            adapters.Add(com.createObjectAdapter("Adapter63", "default"));

            TestIntfPrx obj = createTestIntfPrx(adapters);
            obj = TestIntfPrxHelper.uncheckedCast(obj.ice_endpointSelection(Ice.EndpointSelectionType.Ordered));
            test(obj.ice_getEndpointSelection() == Ice.EndpointSelectionType.Ordered);
            obj = TestIntfPrxHelper.uncheckedCast(obj.ice_connectionCached(false));
            test(!obj.ice_isConnectionCached());
            int nRetry = 3;
            int i;

            //
            // Ensure that endpoints are tried in order by deactiving the adapters
            // one after the other.
            //
            for(i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter61"); i++);
            test(i == nRetry);
            com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[0]);
            for(i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter62"); i++);
            test(i == nRetry);
            com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[1]);
            for(i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter63"); i++);
            test(i == nRetry);
            com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[2]);

            try
            {
                obj.getAdapterName();
            }
            catch(Ice.ConnectionRefusedException)
            {
            }

            Ice.Endpoint[] endpoints = obj.ice_getEndpoints();

            adapters.Clear();

            //
            // Now, re-activate the adapters with the same endpoints in the opposite
            // order.
            //
            adapters.Add(com.createObjectAdapter("Adapter66", endpoints[2].ToString()));
            for(i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter66"); i++);
            test(i == nRetry);
            adapters.Add(com.createObjectAdapter("Adapter65", endpoints[1].ToString()));
            for(i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter65"); i++);
            test(i == nRetry);
            adapters.Add(com.createObjectAdapter("Adapter64", endpoints[0].ToString()));
            for(i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter64"); i++);
            test(i == nRetry);

            deactivate(com, adapters);
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("testing per request binding and ordered endpoint selection and AMI... ");
        Console.Out.Flush();
        {
            ArrayList adapters = new ArrayList();
            adapters.Add(com.createObjectAdapter("AdapterAMI61", "default"));
            adapters.Add(com.createObjectAdapter("AdapterAMI62", "default"));
            adapters.Add(com.createObjectAdapter("AdapterAMI63", "default"));

            TestIntfPrx obj = createTestIntfPrx(adapters);
            obj = TestIntfPrxHelper.uncheckedCast(obj.ice_endpointSelection(Ice.EndpointSelectionType.Ordered));
            test(obj.ice_getEndpointSelection() == Ice.EndpointSelectionType.Ordered);
            obj = TestIntfPrxHelper.uncheckedCast(obj.ice_connectionCached(false));
            test(!obj.ice_isConnectionCached());
            int nRetry = 3;
            int i;

            //
            // Ensure that endpoints are tried in order by deactiving the adapters
            // one after the other.
            //
            for(i = 0; i < nRetry && getAdapterNameWithAMI(obj).Equals("AdapterAMI61"); i++);
            test(i == nRetry);
            com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[0]);
            for(i = 0; i < nRetry && getAdapterNameWithAMI(obj).Equals("AdapterAMI62"); i++);
            test(i == nRetry);
            com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[1]);
            for(i = 0; i < nRetry && getAdapterNameWithAMI(obj).Equals("AdapterAMI63"); i++);
            test(i == nRetry);
            com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[2]);

            try
            {
                obj.getAdapterName();
            }
            catch(Ice.ConnectionRefusedException)
            {
            }

            Ice.Endpoint[] endpoints = obj.ice_getEndpoints();

            adapters.Clear();

            //
            // Now, re-activate the adapters with the same endpoints in the opposite
            // order.
            //
            adapters.Add(com.createObjectAdapter("AdapterAMI66", endpoints[2].ToString()));
            for(i = 0; i < nRetry && getAdapterNameWithAMI(obj).Equals("AdapterAMI66"); i++);
            test(i == nRetry);
            adapters.Add(com.createObjectAdapter("AdapterAMI65", endpoints[1].ToString()));
            for(i = 0; i < nRetry && getAdapterNameWithAMI(obj).Equals("AdapterAMI65"); i++);
            test(i == nRetry);
            adapters.Add(com.createObjectAdapter("AdapterAMI64", endpoints[0].ToString()));
            for(i = 0; i < nRetry && getAdapterNameWithAMI(obj).Equals("AdapterAMI64"); i++);
            test(i == nRetry);

            deactivate(com, adapters);
        }
        Console.Out.WriteLine("ok");

        Console.Out.Write("testing endpoint mode filtering... ");
        Console.Out.Flush();
        {
            ArrayList adapters = new ArrayList();
            adapters.Add(com.createObjectAdapter("Adapter71", "default"));
            adapters.Add(com.createObjectAdapter("Adapter72", "udp"));

            TestIntfPrx obj = createTestIntfPrx(adapters);
            test(obj.getAdapterName().Equals("Adapter71"));

            TestIntfPrx testUDP = TestIntfPrxHelper.uncheckedCast(obj.ice_datagram());
            test(obj.ice_getConnection() != testUDP.ice_getConnection());
            try
            {
                testUDP.getAdapterName();
            }
            catch(Ice.TwowayOnlyException)
            {
            }
        }
        Console.Out.WriteLine("ok");

        if(communicator.getProperties().getProperty("Ice.Plugin.IceSSL").Length > 0)
        {
            Console.Out.Write("testing unsecure vs. secure endpoints... ");
            Console.Out.Flush();
            {
                ArrayList adapters = new ArrayList();
                adapters.Add(com.createObjectAdapter("Adapter81", "ssl"));
                adapters.Add(com.createObjectAdapter("Adapter82", "tcp"));

                TestIntfPrx obj = createTestIntfPrx(adapters);
                int i;
                for(i = 0; i < 5; i++)
                {
                    test(obj.getAdapterName().Equals("Adapter82"));
                    obj.ice_getConnection().close(false);
                }

                TestIntfPrx testSecure = TestIntfPrxHelper.uncheckedCast(obj.ice_secure(true));
                test(testSecure.ice_isSecure());
                testSecure = TestIntfPrxHelper.uncheckedCast(obj.ice_secure(false));
                test(!testSecure.ice_isSecure());
                testSecure = TestIntfPrxHelper.uncheckedCast(obj.ice_secure(true));
                test(testSecure.ice_isSecure());
                test(obj.ice_getConnection() != testSecure.ice_getConnection());

                com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[1]);

                for(i = 0; i < 5; i++)
                {
                    test(obj.getAdapterName().Equals("Adapter81"));
                    obj.ice_getConnection().close(false);
                }

                com.createObjectAdapter("Adapter83", (obj.ice_getEndpoints()[1]).ToString()); // Reactive tcp OA.

                for(i = 0; i < 5; i++)
                {
                    test(obj.getAdapterName().Equals("Adapter83"));
                    obj.ice_getConnection().close(false);
                }

                com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[0]);
                try
                {
                    testSecure.ice_ping();
                    test(false);
                }
                catch(Ice.ConnectionRefusedException)
                {
                }

                deactivate(com, adapters);
            }
            Console.Out.WriteLine("ok");
        }

        com.shutdown();
    }
Example #26
0
    public static void allTests(Ice.Communicator communicator)
    {
        TestIntfPrx service1 = TestIntfPrxHelper.uncheckedCast(communicator.stringToProxy("test:tcp -p 12010"));
        TestIntfPrx service2 = TestIntfPrxHelper.uncheckedCast(communicator.stringToProxy("test:tcp -p 12011"));
        TestIntfPrx service3 = TestIntfPrxHelper.uncheckedCast(communicator.stringToProxy("test:tcp -p 12012"));
        TestIntfPrx service4 = TestIntfPrxHelper.uncheckedCast(communicator.stringToProxy("test:tcp -p 12013"));

        if(service1.getProperty("IceBox.InheritProperties").Equals(""))
        {
            Console.Out.Write("testing service properties... ");
            Console.Out.Flush();

            test(service1.getProperty("Ice.ProgramName").Equals("IceBox-Service1"));
            test(service1.getProperty("Service").Equals("1"));
            test(service1.getProperty("Service1.Ovrd").Equals("2"));
            test(service1.getProperty("Service1.Unset").Equals(""));
            test(service1.getProperty("Arg").Equals("1"));

            string[] args1 = {"-a", "--Arg=2"};
            test(IceUtilInternal.Arrays.Equals(service1.getArgs(), args1));

            test(service2.getProperty("Ice.ProgramName").Equals("Test"));
            test(service2.getProperty("Service").Equals("2"));
            test(service2.getProperty("Service1.ArgProp").Equals(""));
            test(service2.getProperty("IceBox.InheritProperties").Equals("1"));

            string[] args2 = {"--Service1.ArgProp=1"};
            test(IceUtilInternal.Arrays.Equals(service2.getArgs(), args2));

            Console.Out.WriteLine("ok");

            Console.Out.Write("testing with shared communicator... ");
            Console.Out.Flush();

            test(service3.getProperty("Ice.ProgramName").Equals("IceBox-SharedCommunicator"));
            test(service3.getProperty("Service").Equals("4"));
            test(service3.getProperty("Prop").Equals(""));
            test(service3.getProperty("Service3.Prop").Equals("1"));
            test(service3.getProperty("Ice.Trace.Slicing").Equals("3"));

            test(service4.getProperty("Ice.ProgramName").Equals("IceBox-SharedCommunicator"));
            test(service4.getProperty("Service").Equals("4"));
            test(service4.getProperty("Prop").Equals(""));
            test(service4.getProperty("Service3.Prop").Equals("1"));
            test(service4.getProperty("Ice.Trace.Slicing").Equals("3"));

            string[] args4 = {"--Service3.Prop=2"};
            test(IceUtilInternal.Arrays.Equals(service4.getArgs(), args4));

            Console.Out.WriteLine("ok");
        }
        else
        {
            Console.Out.Write("testing property inheritance... ");
            Console.Out.Flush();

            test(service1.getProperty("Ice.ProgramName").Equals("IceBox2-Service1"));
            test(service1.getProperty("ServerProp").Equals("1"));
            test(service1.getProperty("OverrideMe").Equals("2"));
            test(service1.getProperty("UnsetMe").Equals(""));
            test(service1.getProperty("Service1.Prop").Equals("1"));
            test(service1.getProperty("Service1.ArgProp").Equals("2"));

            test(service2.getProperty("Ice.ProgramName").Equals("IceBox2-SharedCommunicator"));
            test(service2.getProperty("ServerProp").Equals("1"));
            test(service2.getProperty("OverrideMe").Equals("3"));
            test(service2.getProperty("UnsetMe").Equals(""));
            test(service2.getProperty("Service2.Prop").Equals("1"));

            Console.Out.WriteLine("ok");
        }
    }
Example #27
0
    private static void allTests(Ice.Communicator communicator)
    {
        Console.Out.Write("testing equals() for Slice structures... ");
        Console.Out.Flush();

        //
        // Define some default values.
        //
        C def_cls = new C(5);
        S1 def_s = new S1("name");
        string[] def_ss = new string[]{ "one", "two", "three" };
        IntList def_il = new IntList();
        def_il.Add(1);
        def_il.Add(2);
        def_il.Add(3);
        Dictionary<string, string> def_sd = new Dictionary<string, string>();
        def_sd.Add("abc", "def");
        Ice.ObjectPrx def_prx = communicator.stringToProxy("test");
        S2 def_s2 = new S2(true, (byte)98, (short)99, 100, 101, (float)1.0, 2.0, "string", def_ss, def_il, def_sd,
                           def_s, def_cls, def_prx);

        //
        // Compare default-constructed structures.
        //
        {
            test(new S2().Equals(new S2()));
        }

        //
        // Change one primitive member at a time.
        //
        {
            S2 v;

            v = (S2)def_s2.Clone();
            test(v.Equals(def_s2));

            v = (S2)def_s2.Clone();
            v.bo = false;
            test(!v.Equals(def_s2));

            v = (S2)def_s2.Clone();
            v.by--;
            test(!v.Equals(def_s2));

            v = (S2)def_s2.Clone();
            v.sh--;
            test(!v.Equals(def_s2));

            v = (S2)def_s2.Clone();
            v.i--;
            test(!v.Equals(def_s2));

            v = (S2)def_s2.Clone();
            v.l--;
            test(!v.Equals(def_s2));

            v = (S2)def_s2.Clone();
            v.f--;
            test(!v.Equals(def_s2));

            v = (S2)def_s2.Clone();
            v.d--;
            test(!v.Equals(def_s2));

            v = (S2)def_s2.Clone();
            v.str = "";
            test(!v.Equals(def_s2));
        }

        //
        // String member
        //
        {
            S2 v1, v2;

            v1 = (S2)def_s2.Clone();
            v1.str = (string)def_s2.str.Clone();
            test(v1.Equals(def_s2));

            v1 = (S2)def_s2.Clone();
            v2 = (S2)def_s2.Clone();
            v1.str = null;
            test(!v1.Equals(v2));

            v1 = (S2)def_s2.Clone();
            v2 = (S2)def_s2.Clone();
            v2.str = null;
            test(!v1.Equals(v2));

            v1 = (S2)def_s2.Clone();
            v2 = (S2)def_s2.Clone();
            v1.str = null;
            v2.str = null;
            test(v1.Equals(v2));
        }

        //
        // Sequence member
        //
        {
            S2 v1, v2;

            v1 = (S2)def_s2.Clone();
            v1.ss = (string[])def_s2.ss.Clone();
            test(v1.Equals(def_s2));

            v1 = (S2)def_s2.Clone();
            v2 = (S2)def_s2.Clone();
            v1.ss = null;
            test(!v1.Equals(v2));

            v1 = (S2)def_s2.Clone();
            v2 = (S2)def_s2.Clone();
            v2.ss = null;
            test(!v1.Equals(v2));
        }

        //
        // Custom sequence member
        //
        {
            S2 v1, v2;

            v1 = (S2)def_s2.Clone();
            v1.il = (IntList)def_s2.il.Clone();
            test(v1.Equals(def_s2));

            v1 = (S2)def_s2.Clone();
            v1.il = new IntList();
            test(!v1.Equals(def_s2));

            v1 = (S2)def_s2.Clone();
            v2 = (S2)def_s2.Clone();
            v1.il = null;
            test(!v1.Equals(v2));

            v1 = (S2)def_s2.Clone();
            v2 = (S2)def_s2.Clone();
            v2.il = null;
            test(!v1.Equals(v2));
        }

        //
        // Dictionary member
        //
        {
            S2 v1, v2;

            v1 = (S2)def_s2.Clone();
            v1.sd = new Dictionary<string, string>(def_s2.sd);
            test(v1.Equals(def_s2));

            v1 = (S2)def_s2.Clone();
            v1.sd = new Dictionary<string, string>();
            test(!v1.Equals(def_s2));

            v1 = (S2)def_s2.Clone();
            v2 = (S2)def_s2.Clone();
            v1.sd = null;
            test(!v1.Equals(v2));

            v1 = (S2)def_s2.Clone();
            v2 = (S2)def_s2.Clone();
            v2.sd = null;
            test(!v1.Equals(v2));
        }

        //
        // Struct member
        //
        {
            S2 v1, v2;

            v1 = (S2)def_s2.Clone();
            v1.s = (S1)def_s2.s.Clone();
            test(v1.Equals(def_s2));

            v1 = (S2)def_s2.Clone();
            v1.s = new S1("name");
            test(v1.Equals(def_s2));

            v1 = (S2)def_s2.Clone();
            v1.s = new S1("noname");
            test(!v1.Equals(def_s2));

            v1 = (S2)def_s2.Clone();
            v2 = (S2)def_s2.Clone();
            v1.s = null;
            test(!v1.Equals(v2));

            v1 = (S2)def_s2.Clone();
            v2 = (S2)def_s2.Clone();
            v2.s = null;
            test(!v1.Equals(v2));
        }

        //
        // Class member
        //
        {
            S2 v1, v2;

            v1 = (S2)def_s2.Clone();
            v1.cls = (C)def_s2.cls.Clone();
            test(!v1.Equals(def_s2));

            v1 = (S2)def_s2.Clone();
            v2 = (S2)def_s2.Clone();
            v1.cls = null;
            test(!v1.Equals(v2));

            v1 = (S2)def_s2.Clone();
            v2 = (S2)def_s2.Clone();
            v2.cls = null;
            test(!v1.Equals(v2));
        }

        //
        // Proxy member
        //
        {
            S2 v1, v2;

            v1 = (S2)def_s2.Clone();
            v1.prx = communicator.stringToProxy("test");
            test(v1.Equals(def_s2));

            v1 = (S2)def_s2.Clone();
            v1.prx = communicator.stringToProxy("test2");
            test(!v1.Equals(def_s2));

            v1 = (S2)def_s2.Clone();
            v2 = (S2)def_s2.Clone();
            v1.prx = null;
            test(!v1.Equals(v2));

            v1 = (S2)def_s2.Clone();
            v2 = (S2)def_s2.Clone();
            v2.prx = null;
            test(!v1.Equals(v2));
        }

        Console.Out.WriteLine("ok");
    }
Example #28
0
    public static GPrx allTests(Ice.Communicator communicator)
#endif
    {
        
        Write("testing Ice.Admin.Facets property... ");
        test(communicator.getProperties().getPropertyAsList("Ice.Admin.Facets").Length == 0);
        communicator.getProperties().setProperty("Ice.Admin.Facets", "foobar");
        String[] facetFilter = communicator.getProperties().getPropertyAsList("Ice.Admin.Facets");
        test(facetFilter.Length == 1 && facetFilter[0].Equals("foobar"));
        communicator.getProperties().setProperty("Ice.Admin.Facets", "foo\\'bar");
        facetFilter = communicator.getProperties().getPropertyAsList("Ice.Admin.Facets");
        test(facetFilter.Length == 1 && facetFilter[0].Equals("foo'bar"));
        communicator.getProperties().setProperty("Ice.Admin.Facets", "'foo bar' toto 'titi'");
        facetFilter = communicator.getProperties().getPropertyAsList("Ice.Admin.Facets");
        test(facetFilter.Length == 3 && facetFilter[0].Equals("foo bar") && facetFilter[1].Equals("toto")
             && facetFilter[2].Equals("titi"));
        communicator.getProperties().setProperty("Ice.Admin.Facets", "'foo bar\\' toto' 'titi'");
        facetFilter = communicator.getProperties().getPropertyAsList("Ice.Admin.Facets");
        test(facetFilter.Length == 2 && facetFilter[0].Equals("foo bar' toto") && facetFilter[1].Equals("titi"));
        //  communicator.getProperties().setProperty("Ice.Admin.Facets", "'foo bar' 'toto titi");
        // facetFilter = communicator.getProperties().getPropertyAsList("Ice.Admin.Facets");
        // test(facetFilter.Length == 0);
        communicator.getProperties().setProperty("Ice.Admin.Facets", "");
        WriteLine("ok");

#if !SILVERLIGHT
        Write("testing facet registration exceptions... ");
        communicator.getProperties().setProperty("FacetExceptionTestAdapter.Endpoints", "default");
        Ice.ObjectAdapter adapter = communicator.createObjectAdapter("FacetExceptionTestAdapter");
        Ice.Object obj = new EmptyI();
        adapter.add(obj, communicator.stringToIdentity("d"));
        adapter.addFacet(obj, communicator.stringToIdentity("d"), "facetABCD");
        try
        {
            adapter.addFacet(obj, communicator.stringToIdentity("d"), "facetABCD");
            test(false);
        }
        catch(Ice.AlreadyRegisteredException)
        {
        }
        adapter.removeFacet(communicator.stringToIdentity("d"), "facetABCD");
        try
        {
            adapter.removeFacet(communicator.stringToIdentity("d"), "facetABCD");
            test(false);
        }
        catch(Ice.NotRegisteredException)
        {
        }
        WriteLine("ok");

        Write("testing removeAllFacets... ");
        Ice.Object obj1 = new EmptyI();
        Ice.Object obj2 = new EmptyI();
        adapter.addFacet(obj1, communicator.stringToIdentity("id1"), "f1");
        adapter.addFacet(obj2, communicator.stringToIdentity("id1"), "f2");
        Ice.Object obj3 = new EmptyI();
        adapter.addFacet(obj1, communicator.stringToIdentity("id2"), "f1");
        adapter.addFacet(obj2, communicator.stringToIdentity("id2"), "f2");
        adapter.addFacet(obj3, communicator.stringToIdentity("id2"), "");
        Dictionary<string, Ice.Object> fm
            = adapter.removeAllFacets(communicator.stringToIdentity("id1"));
        test(fm.Count == 2);
        test(fm["f1"] == obj1);
        test(fm["f2"] == obj2);
        try
        {
            adapter.removeAllFacets(communicator.stringToIdentity("id1"));
            test(false);
        }
        catch(Ice.NotRegisteredException)
        {
        }
        fm = adapter.removeAllFacets(communicator.stringToIdentity("id2"));
        test(fm.Count == 3);
        test(fm["f1"] == obj1);
        test(fm["f2"] == obj2);
        test(fm[""] == obj3);
        WriteLine("ok");

        adapter.deactivate();
#endif
        Write("testing stringToProxy... ");
        Flush();
        string @ref = "d:default -p 12010";
        Ice.ObjectPrx db = communicator.stringToProxy(@ref);
        test(db != null);
        WriteLine("ok");

        Write("testing unchecked cast... ");
        Flush();
        Ice.ObjectPrx prx = Ice.ObjectPrxHelper.uncheckedCast(db);
        test(prx.ice_getFacet().Length == 0);
        prx = Ice.ObjectPrxHelper.uncheckedCast(db, "facetABCD");
        test(prx.ice_getFacet() == "facetABCD");
        Ice.ObjectPrx prx2 = Ice.ObjectPrxHelper.uncheckedCast(prx);
        test(prx2.ice_getFacet() == "facetABCD");
        Ice.ObjectPrx prx3 = Ice.ObjectPrxHelper.uncheckedCast(prx, "");
        test(prx3.ice_getFacet().Length == 0);
        DPrx d = Test.DPrxHelper.uncheckedCast(db);
        test(d.ice_getFacet().Length == 0);
        DPrx df = Test.DPrxHelper.uncheckedCast(db, "facetABCD");
        test(df.ice_getFacet() == "facetABCD");
        DPrx df2 = Test.DPrxHelper.uncheckedCast(df);
        test(df2.ice_getFacet() == "facetABCD");
        DPrx df3 = Test.DPrxHelper.uncheckedCast(df, "");
        test(df3.ice_getFacet().Length == 0);
        WriteLine("ok");

        Write("testing checked cast... ");
        Flush();
        prx = Ice.ObjectPrxHelper.checkedCast(db);
        test(prx.ice_getFacet().Length == 0);
        prx = Ice.ObjectPrxHelper.checkedCast(db, "facetABCD");
        test(prx.ice_getFacet() == "facetABCD");
        prx2 = Ice.ObjectPrxHelper.checkedCast(prx);
        test(prx2.ice_getFacet() == "facetABCD");
        prx3 = Ice.ObjectPrxHelper.checkedCast(prx, "");
        test(prx3.ice_getFacet().Length == 0);
        d = Test.DPrxHelper.checkedCast(db);
        test(d.ice_getFacet().Length == 0);
        df = Test.DPrxHelper.checkedCast(db, "facetABCD");
        test(df.ice_getFacet() == "facetABCD");
        df2 = Test.DPrxHelper.checkedCast(df);
        test(df2.ice_getFacet() == "facetABCD");
        df3 = Test.DPrxHelper.checkedCast(df, "");
        test(df3.ice_getFacet().Length == 0);
        WriteLine("ok");

        Write("testing non-facets A, B, C, and D... ");
        Flush();
        d = DPrxHelper.checkedCast(db);
        test(d != null);
        test(d.Equals(db));
        test(d.callA().Equals("A"));
        test(d.callB().Equals("B"));
        test(d.callC().Equals("C"));
        test(d.callD().Equals("D"));
        WriteLine("ok");
     
        Write("testing facets A, B, C, and D... ");
        Flush();
        df = DPrxHelper.checkedCast(d, "facetABCD");
        test(df != null);
        test(df.callA().Equals("A"));
        test(df.callB().Equals("B"));
        test(df.callC().Equals("C"));
        test(df.callD().Equals("D"));
        WriteLine("ok");
        
        Write("testing facets E and F... ");
        Flush();
        FPrx ff = FPrxHelper.checkedCast(d, "facetEF");
        test(ff != null);
        test(ff.callE().Equals("E"));
        test(ff.callF().Equals("F"));
        WriteLine("ok");
        
        Write("testing facet G... ");
        Flush();
        GPrx gf = GPrxHelper.checkedCast(ff, "facetGH");
        test(gf != null);
        test(gf.callG().Equals("G"));
        WriteLine("ok");
        
        Write("testing whether casting preserves the facet... ");
        Flush();
        HPrx hf = HPrxHelper.checkedCast(gf);
        test(hf != null);
        test(hf.callG().Equals("G"));
        test(hf.callH().Equals("H"));
        WriteLine("ok");
        
#if SILVERLIGHT
        gf.shutdown();
#else
        return gf;
#endif
    }
Example #29
0
    public static Test.RetryPrx allTests(Ice.Communicator communicator)
#endif
    {
        Write("testing stringToProxy... ");
        Flush();
        string rf = "retry:default -p 12010";
        Ice.ObjectPrx base1 = communicator.stringToProxy(rf);
        test(base1 != null);
        Ice.ObjectPrx base2 = communicator.stringToProxy(rf);
        test(base2 != null);
        WriteLine("ok");

        Write("testing checked cast... ");
        Flush();
        Test.RetryPrx retry1 = Test.RetryPrxHelper.checkedCast(base1);
        test(retry1 != null);
        test(retry1.Equals(base1));
        Test.RetryPrx retry2 = Test.RetryPrxHelper.checkedCast(base2);
        test(retry2 != null);
        test(retry2.Equals(base2));
        WriteLine("ok");

        Write("calling regular operation with first proxy... ");
        Flush();
        retry1.op(false);
        WriteLine("ok");

        Write("calling operation to kill connection with second proxy... ");
        Flush();
        try
        {
            retry2.op(true);
            test(false);
        }
        catch(Ice.ConnectionLostException)
        {
            WriteLine("ok");
        }

        Write("calling regular operation with first proxy again... ");
        Flush();
        retry1.op(false);
        WriteLine("ok");

        AMIRegular cb1 = new AMIRegular();
        AMIException cb2 = new AMIException();

        Write("calling regular AMI operation with first proxy... ");
        retry1.begin_op(false).whenCompleted(cb1.response, cb1.exception);
        cb1.check();
        WriteLine("ok");

        Write("calling AMI operation to kill connection with second proxy... ");
        retry2.begin_op(true).whenCompleted(cb2.response, cb2.exception);
        cb2.check();
        WriteLine("ok");

        Write("calling regular AMI operation with first proxy again... ");
        retry1.begin_op(false).whenCompleted(cb1.response, cb1.exception);
        cb1.check();
        WriteLine("ok");
#if SILVERLIGHT
        retry1.shutdown();
#else
        return retry1;
#endif
    }
Example #30
0
    public static void allTests(Ice.Communicator communicator, List<int> ports)
#endif
    {
#if SILVERLIGHT
        List<int> ports = new List<int>();
        {
            int basePort = 12340;
            for (int i = 0; i < 12; i++)
            {
                ports.Add(basePort + i);
            }
        }
#endif
        Write("testing stringToProxy... ");
        Flush();
        string refString = "test";
        for(int i = 0; i < ports.Count; i++)
        {
            refString += ":default -p " + ports[i];
        }
        Ice.ObjectPrx basePrx = communicator.stringToProxy(refString);
        test(basePrx != null);
        WriteLine("ok");

        Write("testing checked cast... ");
        Flush();
        TestIntfPrx obj = TestIntfPrxHelper.checkedCast(basePrx);
        test(obj != null);
        test(obj.Equals(basePrx));
        WriteLine("ok");

        if(IceInternal.AssemblyUtil.runtime_ == IceInternal.AssemblyUtil.Runtime.Mono)
        {
            WriteLine("");
            WriteLine("This test aborts a number of server processes.");
            WriteLine("Test output may be interspersed with \"killed\" message from the shell.");
            WriteLine("These messages are expected and do NOT indicate a test failure.");
            WriteLine("");
        }

        int oldPid = 0;
        bool ami = false;
        for(int i = 1, j = 0; i <= ports.Count; ++i, ++j)
        {
            if(j > 3)
            {
                j = 0;
                ami = !ami;
            }

            if(!ami)
            {
                Write("testing server #" + i + "... ");
                Flush();
                int pid = obj.pid();
                test(pid != oldPid);
                WriteLine("ok");
                oldPid = pid;
            }
            else
            {
                Write("testing server #" + i + " with AMI... ");
                Flush();
                Callback cb = new Callback();
                int pid = -1;
                obj.begin_pid().whenCompleted(
                    (int p) =>
                    {
                        pid = p;
                        cb.called();
                    },
                    (Ice.Exception ex) =>
                    {
                        WriteLine(ex.ToString());
                        test(false);
                    });
                cb.check();
                test(pid != oldPid);
                WriteLine("ok");
                oldPid = pid;
            }

            if(j == 0)
            {
                if(!ami)
                {
                    Write("shutting down server #" + i + "... ");
                    Flush();
                    obj.shutdown();
                    WriteLine("ok");
                }
                else
                {
                    Write("shutting down server #" + i + " with AMI... ");
                    Callback cb = new Callback();
                    obj.begin_shutdown().whenCompleted(
                        () =>
                        {
                            cb.called();
                        },
                        (Ice.Exception ex) =>
                        {
                            WriteLine(ex.ToString());
                            test(false);
                        });
                    cb.check();
                    WriteLine("ok");
                }
            }
            else if(j == 1 || i + 1 > ports.Count)
            {
                if(!ami)
                {
                    Write("aborting server #" + i + "... ");
                    Flush();
                    try
                    {
                        obj.abort();
                        test(false);
                    }
                    catch(Ice.ConnectionLostException)
                    {
                        WriteLine("ok");
                    }
                    catch(Ice.ConnectFailedException)
                    {
                        WriteLine("ok");
                    }
                    catch(Ice.SocketException)
                    {
                        WriteLine("ok");
                    }
                }
                else
                {
                    Write("aborting server #" + i + " with AMI... ");
                    Flush();
                    Callback cb = new Callback();
                    obj.begin_abort().whenCompleted(
                        () =>
                        {
                            test(false);
                        },
                        (Ice.Exception ex) =>
                        {
                            exceptAbortI(ex);
                            cb.called();
                        });
                    cb.check();
                    WriteLine("ok");
                }
            }
            else if(j == 2 || j == 3)
            {
                if(!ami)
                {
                    Write("aborting server #" + i + " and #" + (i + 1) + " with idempotent call... ");
                    Flush();
                    try
                    {
                        obj.idempotentAbort();
                        test(false);
                    }
                    catch(Ice.ConnectionLostException)
                    {
                        WriteLine("ok");
                    }
                    catch(Ice.ConnectFailedException)
                    {
                        WriteLine("ok");
                    }
                    catch(Ice.SocketException)
                    {
                        WriteLine("ok");
                    }
                }
                else
                {
                    Write("aborting server #" + i + " and #" + (i + 1) + " with idempotent AMI call... ");
                    Flush();
                    Callback cb = new Callback();
                    obj.begin_idempotentAbort().whenCompleted(
                        () =>
                        {
                            test(false);
                        },
                        (Ice.Exception ex) =>
                        {
                            exceptAbortI(ex);
                            cb.called();
                        });
                    cb.check();
                    WriteLine("ok");
                }
                ++i;
            }
            else
            {
                Debug.Assert(false);
            }
        }

        Write("testing whether all servers are gone... ");
        Flush();
        try
        {
            obj.ice_ping();
            test(false);
        }
        catch(Ice.LocalException)
        {
            WriteLine("ok");
        }
    }