Пример #1
0
    public static void allTests(TestCommon.Application app)
    {
        Ice.Communicator      communicator = app.communicator();
        string                @ref         = "communicator:" + app.getTestEndpoint(0);
        RemoteCommunicatorPrx com          = RemoteCommunicatorPrxHelper.uncheckedCast(communicator.stringToProxy(@ref));

        System.Random rand = new System.Random(unchecked ((int)System.DateTime.Now.Ticks));

        Write("testing binding with single endpoint... ");
        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.ConnectFailedException)
            {
            }
            catch (Ice.ConnectTimeoutException)
            {
            }
        }
        WriteLine("ok");

        Write("testing binding with multiple endpoints... ");
        Flush();
        {
            List <RemoteObjectAdapterPrx> adapters = new List <RemoteObjectAdapterPrx>();
            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)
            {
                List <RemoteObjectAdapterPrx> adpts = new List <RemoteObjectAdapterPrx>(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(Ice.ConnectionClose.GracefullyWithWait);
            }

            //
            // 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(Ice.ConnectionClose.GracefullyWithWait);
                }
            }

            //
            // 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)
            {
                List <RemoteObjectAdapterPrx> adpts = new List <RemoteObjectAdapterPrx>(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(Ice.ConnectionClose.GracefullyWithWait);
            }

            //
            // 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);
        }
        WriteLine("ok");

        Write("testing binding with multiple random endpoints... ");
        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        = 20;
            int adapterCount = adapters.Length;
            while (--count > 0)
            {
                TestIntfPrx[] proxies;
                if (count == 1)
                {
                    com.deactivateObjectAdapter(adapters[4]);
                    --adapterCount;
                }
                proxies = new TestIntfPrx[10];

                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 List <RemoteObjectAdapterPrx>(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)
                    {
                    }
                }

                List <Ice.Connection> connections = new List <Ice.Connection>();
                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(Ice.ConnectionClose.GracefullyWithWait);
                    }
                    catch (Ice.LocalException)
                    {
                        // Expected if adapter is down.
                    }
                }
            }
        }
        WriteLine("ok");

        Write("testing binding with multiple endpoints and AMI... ");
        Flush();
        {
            List <RemoteObjectAdapterPrx> adapters = new List <RemoteObjectAdapterPrx>();
            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)
            {
                List <RemoteObjectAdapterPrx> adpts = new List <RemoteObjectAdapterPrx>(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(Ice.ConnectionClose.GracefullyWithWait);
            }

            //
            // 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(Ice.ConnectionClose.GracefullyWithWait);
                }
            }

            //
            // 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)
            {
                List <RemoteObjectAdapterPrx> adpts = new List <RemoteObjectAdapterPrx>(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(Ice.ConnectionClose.GracefullyWithWait);
            }

            //
            // 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);
        }
        WriteLine("ok");

        Write("testing random endpoint selection... ");
        Flush();
        {
            List <RemoteObjectAdapterPrx> adapters = new List <RemoteObjectAdapterPrx>();
            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(Ice.ConnectionClose.GracefullyWithWait);
            }

            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(Ice.ConnectionClose.GracefullyWithWait);
            }

            deactivate(com, adapters);
        }
        WriteLine("ok");

        Write("testing ordered endpoint selection... ");
        Flush();
        {
            List <RemoteObjectAdapterPrx> adapters = new List <RemoteObjectAdapterPrx>();
            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.ConnectFailedException)
            {
            }
            catch (Ice.ConnectTimeoutException)
            {
            }

            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(Ice.ConnectionClose.GracefullyWithWait);
            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(Ice.ConnectionClose.GracefullyWithWait);
            adapters.Add(com.createObjectAdapter("Adapter34", endpoints[0].ToString()));
            for (i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter34"); i++)
            {
                ;
            }
            test(i == nRetry);

            deactivate(com, adapters);
        }
        WriteLine("ok");

        Write("testing per request binding with single endpoint... ");
        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() != null && test2.ice_getConnection() != null);
            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.ConnectFailedException)
            {
            }
            catch (Ice.ConnectTimeoutException)
            {
            }
        }
        WriteLine("ok");

        Write("testing per request binding with multiple endpoints... ");
        Flush();
        {
            List <RemoteObjectAdapterPrx> adapters = new List <RemoteObjectAdapterPrx>();
            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);
        }
        WriteLine("ok");

        Write("testing per request binding with multiple endpoints and AMI... ");
        Flush();
        {
            List <RemoteObjectAdapterPrx> adapters = new List <RemoteObjectAdapterPrx>();
            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);
        }
        WriteLine("ok");

        Write("testing per request binding and ordered endpoint selection... ");
        Flush();
        {
            List <RemoteObjectAdapterPrx> adapters = new List <RemoteObjectAdapterPrx>();
            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.ConnectFailedException)
            {
            }
            catch (Ice.ConnectTimeoutException)
            {
            }

            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);
        }
        WriteLine("ok");

        Write("testing per request binding and ordered endpoint selection and AMI... ");
        Flush();
        {
            List <RemoteObjectAdapterPrx> adapters = new List <RemoteObjectAdapterPrx>();
            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.ConnectFailedException)
            {
            }
            catch (Ice.ConnectTimeoutException)
            {
            }

            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);
        }
        WriteLine("ok");

        Write("testing endpoint mode filtering... ");
        Flush();
        {
            List <RemoteObjectAdapterPrx> adapters = new List <RemoteObjectAdapterPrx>();
            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 (System.ArgumentException)
            {
            }
        }
        WriteLine("ok");
        if (communicator.getProperties().getProperty("Ice.Plugin.IceSSL").Length > 0)
        {
            Write("testing unsecure vs. secure endpoints... ");
            Flush();
            {
                List <RemoteObjectAdapterPrx> adapters = new List <RemoteObjectAdapterPrx>();
                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(Ice.ConnectionClose.GracefullyWithWait);
                }

                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(Ice.ConnectionClose.GracefullyWithWait);
                }

                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(Ice.ConnectionClose.GracefullyWithWait);
                }

                com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[0]);
                try
                {
                    testSecure.ice_ping();
                    test(false);
                }
                catch (Ice.ConnectFailedException)
                {
                }
                catch (Ice.ConnectTimeoutException)
                {
                }

                deactivate(com, adapters);
            }
            WriteLine("ok");
        }

        {
            Write("testing ipv4 & ipv6 connections... ");
            Flush();

            Ice.Properties ipv4 = Ice.Util.createProperties();
            ipv4.setProperty("Ice.IPv4", "1");
            ipv4.setProperty("Ice.IPv6", "0");
            ipv4.setProperty("Adapter.Endpoints", "tcp -h localhost");

            Ice.Properties ipv6 = Ice.Util.createProperties();
            ipv6.setProperty("Ice.IPv4", "0");
            ipv6.setProperty("Ice.IPv6", "1");
            ipv6.setProperty("Adapter.Endpoints", "tcp -h localhost");

            Ice.Properties bothPreferIPv4 = Ice.Util.createProperties();
            bothPreferIPv4.setProperty("Ice.IPv4", "1");
            bothPreferIPv4.setProperty("Ice.IPv6", "1");
            bothPreferIPv4.setProperty("Ice.PreferIPv6Address", "0");
            bothPreferIPv4.setProperty("Adapter.Endpoints", "tcp -h localhost");

            Ice.Properties bothPreferIPv6 = Ice.Util.createProperties();
            bothPreferIPv6.setProperty("Ice.IPv4", "1");
            bothPreferIPv6.setProperty("Ice.IPv6", "1");
            bothPreferIPv6.setProperty("Ice.PreferIPv6Address", "1");
            bothPreferIPv6.setProperty("Adapter.Endpoints", "tcp -h localhost");

            List <Ice.Properties> clientProps = new List <Ice.Properties>();
            clientProps.Add(ipv4);
            clientProps.Add(ipv6);
            clientProps.Add(bothPreferIPv4);
            clientProps.Add(bothPreferIPv6);

            string endpoint = "tcp -p " + app.getTestPort(2).ToString();

            Ice.Properties anyipv4 = ipv4.ice_clone_();
            anyipv4.setProperty("Adapter.Endpoints", endpoint);
            anyipv4.setProperty("Adapter.PublishedEndpoints", endpoint + " -h 127.0.0.1");

            Ice.Properties anyipv6 = ipv6.ice_clone_();
            anyipv6.setProperty("Adapter.Endpoints", endpoint);
            anyipv6.setProperty("Adapter.PublishedEndpoints", endpoint + " -h \".1\"");

            Ice.Properties anyboth = Ice.Util.createProperties();
            anyboth.setProperty("Ice.IPv4", "1");
            anyboth.setProperty("Ice.IPv6", "1");
            anyboth.setProperty("Adapter.Endpoints", endpoint);
            anyboth.setProperty("Adapter.PublishedEndpoints", endpoint + " -h \"::1\":" + endpoint + " -h 127.0.0.1");

            Ice.Properties localipv4 = ipv4.ice_clone_();
            localipv4.setProperty("Adapter.Endpoints", "tcp -h 127.0.0.1");

            Ice.Properties localipv6 = ipv6.ice_clone_();
            localipv6.setProperty("Adapter.Endpoints", "tcp -h \"::1\"");

            List <Ice.Properties> serverProps = new List <Ice.Properties>(clientProps);
            serverProps.Add(anyipv4);
            serverProps.Add(anyipv6);
            serverProps.Add(anyboth);
            serverProps.Add(localipv4);
            serverProps.Add(localipv6);

            bool ipv6NotSupported = false;
            foreach (Ice.Properties p in serverProps)
            {
                Ice.InitializationData serverInitData = new Ice.InitializationData();
                serverInitData.properties = p;
                Ice.Communicator  serverCommunicator = Ice.Util.initialize(serverInitData);
                Ice.ObjectAdapter oa;
                try
                {
                    oa = serverCommunicator.createObjectAdapter("Adapter");
                    oa.activate();
                }
                catch (Ice.DNSException)
                {
                    serverCommunicator.destroy();
                    continue; // IP version not supported.
                }
                catch (Ice.SocketException)
                {
                    if (p == ipv6)
                    {
                        ipv6NotSupported = true;
                    }
                    serverCommunicator.destroy();
                    continue; // IP version not supported.
                }

                Ice.ObjectPrx prx = oa.createProxy(Ice.Util.stringToIdentity("dummy"));
                try
                {
                    prx.ice_collocationOptimized(false).ice_ping();
                }
                catch (Ice.LocalException)
                {
                    serverCommunicator.destroy();
                    continue; // IP version not supported.
                }

                string strPrx = prx.ToString();
                foreach (Ice.Properties q in clientProps)
                {
                    Ice.InitializationData clientInitData = new Ice.InitializationData();
                    clientInitData.properties = q;
                    Ice.Communicator clientCommunicator = Ice.Util.initialize(clientInitData);
                    prx = clientCommunicator.stringToProxy(strPrx);
                    try
                    {
                        prx.ice_ping();
                        test(false);
                    }
                    catch (Ice.ObjectNotExistException)
                    {
                        // Expected, no object registered.
                    }
                    catch (Ice.DNSException)
                    {
                        // Expected if no IPv4 or IPv6 address is
                        // associated to localhost or if trying to connect
                        // to an any endpoint with the wrong IP version,
                        // e.g.: resolving an IPv4 address when only IPv6
                        // is enabled fails with a DNS exception.
                    }
                    catch (Ice.SocketException)
                    {
                        test((p == ipv4 && q == ipv6) || (p == ipv6 && q == ipv4) ||
                             (p == bothPreferIPv4 && q == ipv6) || (p == bothPreferIPv6 && q == ipv4) ||
                             (p == bothPreferIPv6 && q == ipv6 && ipv6NotSupported) ||
                             (p == anyipv4 && q == ipv6) || (p == anyipv6 && q == ipv4) ||
                             (p == localipv4 && q == ipv6) || (p == localipv6 && q == ipv4) ||
                             (p == ipv6 && q == bothPreferIPv4) || (p == ipv6 && q == bothPreferIPv6) ||
                             (p == bothPreferIPv6 && q == ipv6));
                    }
                    clientCommunicator.destroy();
                }
                serverCommunicator.destroy();
            }

            WriteLine("ok");
        }
        com.shutdown();
    }
Пример #2
0
    public static void allTests(TestCommon.Application app)
    {
        Ice.Communicator communicator = app.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");

        Console.Out.Write("testing locator finder... ");
        Ice.Identity finderId = new Ice.Identity();
        finderId.category = "Ice";
        finderId.name     = "LocatorFinder";
        Ice.LocatorFinderPrx finder = Ice.LocatorFinderPrxHelper.checkedCast(
            communicator.getDefaultLocator().ice_identity(finderId));
        test(finder.getLocator() != null);
        Console.Out.WriteLine("ok");

        Console.Out.Write("testing discovery... ");
        {
            // Add test well-known object
            IceGrid.RegistryPrx registry = IceGrid.RegistryPrxHelper.checkedCast(
                communicator.stringToProxy(communicator.getDefaultLocator().ice_getIdentity().category + "/Registry"));
            test(registry != null);

            try
            {
                IceGrid.AdminSessionPrx session = registry.createAdminSession("foo", "bar");
                session.getAdmin().addObjectWithType(@base, "::Test");
                session.destroy();
            }
            catch (Ice.UserException)
            {
                test(false);
            }

            //
            // Ensure the IceGrid discovery locator can discover the
            // registries and make sure locator requests are forwarded.
            //
            Ice.InitializationData initData = new Ice.InitializationData();
            initData.properties = communicator.getProperties().ice_clone_();
            initData.properties.setProperty("Ice.Default.Locator", "");
            initData.properties.setProperty("Ice.Plugin.IceLocatorDiscovery",
                                            "IceLocatorDiscovery:IceLocatorDiscovery.PluginFactory");
            initData.properties.setProperty("IceLocatorDiscovery.Port", app.getTestPort(99).ToString());
            initData.properties.setProperty("AdapterForDiscoveryTest.AdapterId", "discoveryAdapter");
            initData.properties.setProperty("AdapterForDiscoveryTest.Endpoints", "default");

            Ice.Communicator com = Ice.Util.initialize(initData);
            test(com.getDefaultLocator() != null);
            com.stringToProxy("test @ TestAdapter").ice_ping();
            com.stringToProxy("test").ice_ping();

            test(com.getDefaultLocator().getRegistry() != null);
            test(IceGrid.LocatorPrxHelper.uncheckedCast(com.getDefaultLocator()).getLocalRegistry() != null);
            test(IceGrid.LocatorPrxHelper.uncheckedCast(com.getDefaultLocator()).getLocalQuery() != null);

            Ice.ObjectAdapter adapter = com.createObjectAdapter("AdapterForDiscoveryTest");
            adapter.activate();
            adapter.deactivate();
            com.destroy();

            //
            // Now, ensure that the IceGrid discovery locator correctly
            // handles failure to find a locator.
            //
            initData.properties.setProperty("IceLocatorDiscovery.InstanceName", "unknown");
            initData.properties.setProperty("IceLocatorDiscovery.RetryCount", "1");
            initData.properties.setProperty("IceLocatorDiscovery.Timeout", "100");
            com = Ice.Util.initialize(initData);
            test(com.getDefaultLocator() != null);
            try
            {
                com.stringToProxy("test @ TestAdapter").ice_ping();
            }
            catch (Ice.NoEndpointException)
            {
            }
            try
            {
                com.stringToProxy("test").ice_ping();
            }
            catch (Ice.NoEndpointException)
            {
            }
            test(com.getDefaultLocator().getRegistry() == null);
            test(IceGrid.LocatorPrxHelper.checkedCast(com.getDefaultLocator()) == null);
            try
            {
                IceGrid.LocatorPrxHelper.uncheckedCast(com.getDefaultLocator()).getLocalRegistry();
            }
            catch (Ice.OperationNotExistException)
            {
            }

            adapter = com.createObjectAdapter("AdapterForDiscoveryTest");
            adapter.activate();
            adapter.deactivate();

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

        Console.Out.Write("shutting down server... ");
        Console.Out.Flush();
        obj.shutdown();
        Console.Out.WriteLine("ok");
    }
Пример #3
0
    public static void allTests(TestCommon.Application app)
    {
        Ice.Communicator communicator = app.communicator();
        Write("testing proxy endpoint information... ");
        Flush();
        {
            Ice.ObjectPrx p1 = communicator.stringToProxy(
                "test -t:default -h tcphost -p 10000 -t 1200 -z --sourceAddress 10.10.10.10:" +
                "udp -h udphost -p 10001 --interface eth0 --ttl 5 --sourceAddress 10.10.10.10:" +
                "opaque -e 1.8 -t 100 -v ABCD");

            Ice.Endpoint[] endps = p1.ice_getEndpoints();

            Ice.EndpointInfo    info        = endps[0].getInfo();
            Ice.TCPEndpointInfo tcpEndpoint = getTCPEndpointInfo(info);
            test(tcpEndpoint.host.Equals("tcphost"));
            test(tcpEndpoint.port == 10000);
            test(tcpEndpoint.sourceAddress.Equals("10.10.10.10"));
            test(tcpEndpoint.timeout == 1200);
            test(tcpEndpoint.compress);
            test(!tcpEndpoint.datagram());

            test(tcpEndpoint.type() == Ice.TCPEndpointType.value && !tcpEndpoint.secure() ||
                 tcpEndpoint.type() == Ice.SSLEndpointType.value && tcpEndpoint.secure() ||
                 tcpEndpoint.type() == Ice.WSEndpointType.value && !tcpEndpoint.secure() ||
                 tcpEndpoint.type() == Ice.WSSEndpointType.value && tcpEndpoint.secure());
            test(tcpEndpoint.type() == Ice.TCPEndpointType.value && info is Ice.TCPEndpointInfo ||
                 tcpEndpoint.type() == Ice.SSLEndpointType.value && info is IceSSL.EndpointInfo ||
                 tcpEndpoint.type() == Ice.WSEndpointType.value && info is Ice.WSEndpointInfo ||
                 tcpEndpoint.type() == Ice.WSSEndpointType.value && info is Ice.WSEndpointInfo);

            Ice.UDPEndpointInfo udpEndpoint = (Ice.UDPEndpointInfo)endps[1].getInfo();
            test(udpEndpoint.host.Equals("udphost"));
            test(udpEndpoint.port == 10001);
            test(udpEndpoint.mcastInterface.Equals("eth0"));
            test(udpEndpoint.mcastTtl == 5);
            test(udpEndpoint.sourceAddress.Equals("10.10.10.10"));
            test(udpEndpoint.timeout == -1);
            test(!udpEndpoint.compress);
            test(!udpEndpoint.secure());
            test(udpEndpoint.datagram());
            test(udpEndpoint.type() == 3);

            Ice.OpaqueEndpointInfo opaqueEndpoint = (Ice.OpaqueEndpointInfo)endps[2].getInfo();
            test(opaqueEndpoint.rawBytes.Length > 0);
            test(opaqueEndpoint.rawEncoding.Equals(new Ice.EncodingVersion(1, 8)));
        }
        WriteLine("ok");

        Ice.ObjectAdapter adapter;
        Write("test object adapter endpoint information... ");
        Flush();
        {
            string host = communicator.getProperties().getPropertyAsInt("Ice.IPv6") != 0 ? "::1" : "127.0.0.1";
            communicator.getProperties().setProperty("TestAdapter.Endpoints", "tcp -h \"" + host +
                                                     "\" -t 15000:udp -h \"" + host + "\"");
            adapter = communicator.createObjectAdapter("TestAdapter");

            Ice.Endpoint[] endpoints = adapter.getEndpoints();
            test(endpoints.Length == 2);
            Ice.Endpoint[] publishedEndpoints = adapter.getPublishedEndpoints();
            test(IceUtilInternal.Arrays.Equals(endpoints, publishedEndpoints));

            Ice.TCPEndpointInfo tcpEndpoint = getTCPEndpointInfo(endpoints[0].getInfo());
            test(tcpEndpoint.type() == Ice.TCPEndpointType.value || tcpEndpoint.type() == Ice.SSLEndpointType.value ||
                 tcpEndpoint.type() == Ice.WSEndpointType.value || tcpEndpoint.type() == Ice.WSSEndpointType.value);

            test(tcpEndpoint.host.Equals(host));
            test(tcpEndpoint.port > 0);
            test(tcpEndpoint.timeout == 15000);

            Ice.UDPEndpointInfo udpEndpoint = (Ice.UDPEndpointInfo)endpoints[1].getInfo();
            test(udpEndpoint.host.Equals(host));
            test(udpEndpoint.datagram());
            test(udpEndpoint.port > 0);

            endpoints = new Ice.Endpoint[] { endpoints[0] };
            test(endpoints.Length == 1);
            adapter.setPublishedEndpoints(endpoints);
            publishedEndpoints = adapter.getPublishedEndpoints();
            test(IceUtilInternal.Arrays.Equals(endpoints, publishedEndpoints));

            adapter.destroy();

            int port = app.getTestPort(1);
            communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -h * -p " + port);
            communicator.getProperties().setProperty("TestAdapter.PublishedEndpoints", app.getTestEndpoint(1));
            adapter = communicator.createObjectAdapter("TestAdapter");

            endpoints = adapter.getEndpoints();
            test(endpoints.Length >= 1);
            publishedEndpoints = adapter.getPublishedEndpoints();
            test(publishedEndpoints.Length == 1);

            foreach (Ice.Endpoint endpoint in endpoints)
            {
                tcpEndpoint = getTCPEndpointInfo(endpoint.getInfo());
                test(tcpEndpoint.port == port);
            }

            tcpEndpoint = getTCPEndpointInfo(publishedEndpoints[0].getInfo());
            test(tcpEndpoint.host.Equals("127.0.0.1"));
            test(tcpEndpoint.port == port);

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

        int endpointPort = app.getTestPort(0);

        Ice.ObjectPrx @base = communicator.stringToProxy("test:" +
                                                         app.getTestEndpoint(0) + ":" +
                                                         app.getTestEndpoint(0, "udp"));
        TestIntfPrx testIntf = TestIntfPrxHelper.checkedCast(@base);

        string defaultHost = communicator.getProperties().getProperty("Ice.Default.Host");

        Write("test connection endpoint information... ");
        Flush();
        {
            Ice.EndpointInfo    info    = @base.ice_getConnection().getEndpoint().getInfo();
            Ice.TCPEndpointInfo tcpinfo = getTCPEndpointInfo(info);
            test(tcpinfo.port == endpointPort);
            test(!tcpinfo.compress);
            test(tcpinfo.host.Equals(defaultHost));

            Dictionary <string, string> ctx = testIntf.getEndpointInfoAsContext();
            test(ctx["host"].Equals(tcpinfo.host));
            test(ctx["compress"].Equals("false"));
            int port = System.Int32.Parse(ctx["port"]);
            test(port > 0);

            info = @base.ice_datagram().ice_getConnection().getEndpoint().getInfo();
            Ice.UDPEndpointInfo udp = (Ice.UDPEndpointInfo)info;
            test(udp.port == endpointPort);
            test(udp.host.Equals(defaultHost));
        }
        WriteLine("ok");

        Write("testing connection information... ");
        Flush();
        {
            Ice.Connection connection = @base.ice_getConnection();
            connection.setBufferSize(1024, 2048);

            Ice.ConnectionInfo    info   = connection.getInfo();
            Ice.TCPConnectionInfo ipInfo = getTCPConnectionInfo(info);
            test(!info.incoming);
            test(info.adapterName.Length == 0);
            test(ipInfo.remotePort == endpointPort);
            test(ipInfo.localPort > 0);
            if (defaultHost.Equals("127.0.0.1"))
            {
                test(ipInfo.localAddress.Equals(defaultHost));
                test(ipInfo.remoteAddress.Equals(defaultHost));
            }
            test(ipInfo.rcvSize >= 1024);
            test(ipInfo.sndSize >= 2048);

            Dictionary <string, string> ctx = testIntf.getConnectionInfoAsContext();
            test(ctx["incoming"].Equals("true"));
            test(ctx["adapterName"].Equals("TestAdapter"));
            test(ctx["remoteAddress"].Equals(ipInfo.localAddress));
            test(ctx["localAddress"].Equals(ipInfo.remoteAddress));
            test(ctx["remotePort"].Equals(ipInfo.localPort.ToString()));
            test(ctx["localPort"].Equals(ipInfo.remotePort.ToString()));

            if (@base.ice_getConnection().type().Equals("ws") || @base.ice_getConnection().type().Equals("wss"))
            {
                Dictionary <string, string> headers = ((Ice.WSConnectionInfo)info).headers;
                test(headers["Upgrade"].Equals("websocket"));
                test(headers["Connection"].Equals("Upgrade"));
                test(headers["Sec-WebSocket-Protocol"].Equals("ice.zeroc.com"));
                test(headers["Sec-WebSocket-Accept"] != null);

                test(ctx["ws.Upgrade"].Equals("websocket"));
                test(ctx["ws.Connection"].Equals("Upgrade"));
                test(ctx["ws.Sec-WebSocket-Protocol"].Equals("ice.zeroc.com"));
                test(ctx["ws.Sec-WebSocket-Version"].Equals("13"));
                test(ctx["ws.Sec-WebSocket-Key"] != null);
            }

            connection = @base.ice_datagram().ice_getConnection();
            connection.setBufferSize(2048, 1024);

            Ice.UDPConnectionInfo udpInfo = (Ice.UDPConnectionInfo)connection.getInfo();
            test(!udpInfo.incoming);
            test(udpInfo.adapterName.Length == 0);
            test(udpInfo.localPort > 0);
            test(udpInfo.remotePort == endpointPort);

            if (defaultHost.Equals("127.0.0.1"))
            {
                test(udpInfo.remoteAddress.Equals(defaultHost));
                test(udpInfo.localAddress.Equals(defaultHost));
            }
            test(udpInfo.rcvSize >= 2048);
            test(udpInfo.sndSize >= 1024);
        }
        WriteLine("ok");

        testIntf.shutdown();

        communicator.shutdown();
        communicator.waitForShutdown();
    }
Пример #4
0
    public static void allTests(TestCommon.Application app)
    {
        Ice.Communicator communicator = app.communicator();
        communicator.getProperties().setProperty("ReplyAdapter.Endpoints", "udp");
        Ice.ObjectAdapter adapter = communicator.createObjectAdapter("ReplyAdapter");
        PingReplyI        replyI  = new PingReplyI();

        Test.PingReplyPrx reply =
            (Test.PingReplyPrx)Test.PingReplyPrxHelper.uncheckedCast(adapter.addWithUUID(replyI)).ice_datagram();
        adapter.activate();

        Console.Out.Write("testing udp... ");
        Console.Out.Flush();
        Ice.ObjectPrx    @base = communicator.stringToProxy("test:" + app.getTestEndpoint(0, "udp")).ice_datagram();
        Test.TestIntfPrx obj   = Test.TestIntfPrxHelper.uncheckedCast(@base);

        int  nRetry = 5;
        bool ret    = false;

        while (nRetry-- > 0)
        {
            replyI.reset();
            obj.ping(reply);
            obj.ping(reply);
            obj.ping(reply);
            ret = replyI.waitReply(3, 2000);
            if (ret)
            {
                break; // Success
            }

            // If the 3 datagrams were not received within the 2 seconds, we try again to
            // receive 3 new datagrams using a new object. We give up after 5 retries.
            replyI = new PingReplyI();
            reply  = (Test.PingReplyPrx)Test.PingReplyPrxHelper.uncheckedCast(adapter.addWithUUID(replyI)).ice_datagram();
        }
        test(ret == true);

        if (communicator.getProperties().getPropertyAsInt("Ice.Override.Compress") == 0)
        {
            //
            // Only run this test if compression is disabled, the test expect fixed message size
            // to be sent over the wire.
            //
            byte[] seq = null;
            try
            {
                seq = new byte[1024];
                while (true)
                {
                    seq = new byte[seq.Length * 2 + 10];
                    replyI.reset();
                    obj.sendByteSeq(seq, reply);
                    replyI.waitReply(1, 10000);
                }
            }
            catch (Ice.DatagramLimitException)
            {
                //
                // The server's Ice.UDP.RcvSize property is set to 16384, which means that DatagramLimitException
                // will be throw when try to send a packet bigger than that.
                //
                test(seq.Length > 16384);
            }
            obj.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait);
            communicator.getProperties().setProperty("Ice.UDP.SndSize", "64000");
            seq = new byte[50000];
            try
            {
                replyI.reset();
                obj.sendByteSeq(seq, reply);

                bool b = replyI.waitReply(1, 500);
                //
                // The server's Ice.UDP.RcvSize property is set to 16384, which means this packet
                // should not be delivered.
                //
                test(!b);
            }
            catch (Ice.DatagramLimitException)
            {
            }
            catch (Ice.LocalException ex)
            {
                Console.Out.WriteLine(ex);
                test(false);
            }
        }

        Console.Out.WriteLine("ok");

        Console.Out.Write("testing udp multicast... ");
        Console.Out.Flush();
        StringBuilder endpoint = new StringBuilder();

        if (communicator.getProperties().getProperty("Ice.IPv6").Equals("1"))
        {
            endpoint.Append("udp -h \"ff15::1:1\" --interface \"::1\" -p "); // Use loopback to prevent other machines to answer.
        }
        else
        {
            endpoint.Append("udp -h 239.255.1.1 --interface 127.0.0.1 -p "); // Use loopback to prevent other machines to answer.
        }
        endpoint.Append(app.getTestPort(10));
        @base = communicator.stringToProxy("test -d:" + endpoint.ToString());
        TestIntfPrx objMcast = Test.TestIntfPrxHelper.uncheckedCast(@base);

        nRetry = 5;
        while (nRetry-- > 0)
        {
            replyI.reset();
            objMcast.ping(reply);
            ret = replyI.waitReply(5, 5000);
            if (ret)
            {
                break;
            }
            replyI = new PingReplyI();
            reply  = (Test.PingReplyPrx)Test.PingReplyPrxHelper.uncheckedCast(adapter.addWithUUID(replyI)).ice_datagram();
        }
        if (!ret)
        {
            Console.Out.WriteLine("failed (is a firewall enabled?)");
        }
        else
        {
            Console.Out.WriteLine("ok");
        }

        Console.Out.Write("testing udp bi-dir connection... ");
        Console.Out.Flush();
        obj.ice_getConnection().setAdapter(adapter);
        objMcast.ice_getConnection().setAdapter(adapter);
        nRetry = 5;
        while (nRetry-- > 0)
        {
            replyI.reset();
            obj.pingBiDir(reply.ice_getIdentity());
            obj.pingBiDir(reply.ice_getIdentity());
            obj.pingBiDir(reply.ice_getIdentity());
            ret = replyI.waitReply(3, 2000);
            if (ret)
            {
                break; // Success
            }
            replyI = new PingReplyI();
            reply  = (PingReplyPrx)PingReplyPrxHelper.uncheckedCast(adapter.addWithUUID(replyI)).ice_datagram();
        }
        test(ret);
        Console.Out.WriteLine("ok");

        //
        // Sending the replies back on the multicast UDP connection doesn't work for most
        // platform (it works for macOS Leopard but not Snow Leopard, doesn't work on SLES,
        // Windows...). For Windows, see UdpTransceiver constructor for the details. So
        // we don't run this test.
        //
//         Console.Out.Write("testing udp bi-dir connection... ");
//         nRetry = 5;
//         while(nRetry-- > 0)
//         {
//             replyI.reset();
//             objMcast.pingBiDir(reply.ice_getIdentity());
//             ret = replyI.waitReply(5, 2000);
//             if(ret)
//             {
//                 break; // Success
//             }
//             replyI = new PingReplyI();
//             reply = (PingReplyPrx)PingReplyPrxHelper.uncheckedCast(adapter.addWithUUID(replyI)).ice_datagram();
//         }

//         if(!ret)
//         {
//             Console.Out.WriteLine("failed (is a firewall enabled?)");
//         }
//         else
//         {
//             Console.Out.WriteLine("ok");
//         }
    }