Exemplo n.º 1
0
        public override int run(string[] args)
        {
            //
            // Create OA and servants
            //

            communicator().getProperties().setProperty("MyOA.AdapterId", "myOA");

            Ice.ObjectAdapter oa = communicator().createObjectAdapterWithEndpoints("MyOA2", "tcp -h localhost");

            Ice.Object      servant        = new MyObjectI();
            InterceptorI    interceptor    = new InterceptorI(servant);
            AMDInterceptorI amdInterceptor = new AMDInterceptorI(servant);

            Test.MyObjectPrx prx       = Test.MyObjectPrxHelper.uncheckedCast(oa.addWithUUID(interceptor));
            Test.MyObjectPrx prxForAMD = Test.MyObjectPrxHelper.uncheckedCast(oa.addWithUUID(amdInterceptor));

            Console.WriteLine("Collocation optimization on");
            int rs = run(prx, interceptor);

            if (rs != 0)
            {
                return(rs);
            }

            Console.WriteLine("Now with AMD");
            rs = runAmd(prxForAMD, amdInterceptor);
            if (rs != 0)
            {
                return(rs);
            }

            oa.activate(); // Only necessary for non-collocation optimized tests

            Console.WriteLine("Collocation optimization off");
            interceptor.clear();
            prx = Test.MyObjectPrxHelper.uncheckedCast(prx.ice_collocationOptimized(false));
            rs  = run(prx, interceptor);
            if (rs != 0)
            {
                return(rs);
            }

            Console.WriteLine("Now with AMD");
            amdInterceptor.clear();
            prxForAMD = Test.MyObjectPrxHelper.uncheckedCast(prxForAMD.ice_collocationOptimized(false));
            rs        = runAmd(prxForAMD, amdInterceptor);

            return(rs);
        }
Exemplo n.º 2
0
        public override int run(string[] args)
        {
            //
            // Create OA and servants
            //

            communicator().getProperties().setProperty("MyOA.AdapterId", "myOA");

            Ice.ObjectAdapter oa = communicator().createObjectAdapterWithEndpoints("MyOA2", "tcp -h localhost");

            Ice.Object servant = new MyObjectI();
            InterceptorI interceptor = new InterceptorI(servant);
            AMDInterceptorI amdInterceptor = new AMDInterceptorI(servant);

            Test.MyObjectPrx prx = Test.MyObjectPrxHelper.uncheckedCast(oa.addWithUUID(interceptor));
            Test.MyObjectPrx prxForAMD = Test.MyObjectPrxHelper.uncheckedCast(oa.addWithUUID(amdInterceptor));

            Console.WriteLine("Collocation optimization on");
            int rs = run(prx, interceptor);
            if(rs != 0)
            {
                return rs;
            }

            Console.WriteLine("Now with AMD");
            rs = runAmd(prxForAMD, amdInterceptor);
            if(rs != 0)
            {
                return rs;
            }

            oa.activate(); // Only necessary for non-collocation optimized tests

            Console.WriteLine("Collocation optimization off");
            interceptor.clear();
            prx = Test.MyObjectPrxHelper.uncheckedCast(prx.ice_collocationOptimized(false));
            rs = run(prx, interceptor);
            if(rs != 0)
            {
                return rs;
            }

            Console.WriteLine("Now with AMD");
            amdInterceptor.clear();
            prxForAMD = Test.MyObjectPrxHelper.uncheckedCast(prxForAMD.ice_collocationOptimized(false));
            rs = runAmd(prxForAMD, amdInterceptor);

            return rs;
        }
Exemplo n.º 3
0
            public override void run(string[] args)
            {
                var properties = createTestProperties(ref args);

                properties.setProperty("Ice.Package.Test", "Ice.interceptor");
                using (var communicator = initialize(properties))
                {
                    //
                    // Create OA and servants
                    //
                    communicator.getProperties().setProperty("MyOA.AdapterId", "myOA");

                    Ice.ObjectAdapter oa = communicator.createObjectAdapterWithEndpoints("MyOA2", "tcp -h localhost");

                    Ice.Object   servant     = new MyObjectI();
                    InterceptorI interceptor = new InterceptorI(servant);

                    Test.MyObjectPrx prx = Test.MyObjectPrxHelper.uncheckedCast(oa.addWithUUID(interceptor));

                    var output = getWriter();

                    output.WriteLine("Collocation optimization on");
                    runTest(prx, interceptor);
                    output.WriteLine("Now with AMD");
                    interceptor.clear();
                    runAmdTest(prx, interceptor);

                    oa.activate(); // Only necessary for non-collocation optimized tests

                    output.WriteLine("Collocation optimization off");
                    interceptor.clear();
                    prx = Test.MyObjectPrxHelper.uncheckedCast(prx.ice_collocationOptimized(false));
                    runTest(prx, interceptor);

                    output.WriteLine("Now with AMD");
                    interceptor.clear();
                    runAmdTest(prx, interceptor);
                }
            }
Exemplo n.º 4
0
    allTests(Ice.Communicator communicator)
    {
        Ice.ObjectAdapter oa = communicator.createObjectAdapterWithEndpoints("MyOA", "tcp -h localhost");
        oa.activate();

        Ice.Object servant = new MyObjectI();

        //
        // Register default servant with category "foo"
        //
        oa.addDefaultServant(servant, "foo");

        //
        // Start test
        //
        Console.Out.Write("testing single category... ");
        Console.Out.Flush();

        Ice.Object r = oa.findDefaultServant("foo");
        test(r == servant);

        r = oa.findDefaultServant("bar");
        test(r == null);

        Ice.Identity identity = new Ice.Identity();
        identity.category = "foo";

        string[] names = new string[] { "foo", "bar", "x", "y", "abcdefg" };

        Test.MyObjectPrx prx = null;
        for (int idx = 0; idx < 5; ++idx)
        {
            identity.name = names[idx];
            prx           = Test.MyObjectPrxHelper.uncheckedCast(oa.createProxy(identity));
            prx.ice_ping();
            test(prx.getName() == names[idx]);
        }

        identity.name = "ObjectNotExist";
        prx           = Test.MyObjectPrxHelper.uncheckedCast(oa.createProxy(identity));
        try
        {
            prx.ice_ping();
            test(false);
        }
        catch (Ice.ObjectNotExistException)
        {
            // Expected
        }

        try
        {
            prx.getName();
            test(false);
        }
        catch (Ice.ObjectNotExistException)
        {
            // Expected
        }

        identity.name = "FacetNotExist";
        prx           = Test.MyObjectPrxHelper.uncheckedCast(oa.createProxy(identity));
        try
        {
            prx.ice_ping();
            test(false);
        }
        catch (Ice.FacetNotExistException)
        {
            // Expected
        }

        try
        {
            prx.getName();
            test(false);
        }
        catch (Ice.FacetNotExistException)
        {
            // Expected
        }

        identity.category = "bar";
        for (int idx = 0; idx < 5; idx++)
        {
            identity.name = names[idx];
            prx           = Test.MyObjectPrxHelper.uncheckedCast(oa.createProxy(identity));

            try
            {
                prx.ice_ping();
                test(false);
            }
            catch (Ice.ObjectNotExistException)
            {
                // Expected
            }

            try
            {
                prx.getName();
                test(false);
            }
            catch (Ice.ObjectNotExistException)
            {
                // Expected
            }
        }

        oa.removeDefaultServant("foo");
        identity.category = "foo";
        prx = Test.MyObjectPrxHelper.uncheckedCast(oa.createProxy(identity));
        try
        {
            prx.ice_ping();
        }
        catch (Ice.ObjectNotExistException)
        {
            // Expected
        }

        Console.Out.WriteLine("ok");

        Console.Out.Write("testing default category... ");
        Console.Out.Flush();

        oa.addDefaultServant(servant, "");

        r = oa.findDefaultServant("bar");
        test(r == null);

        r = oa.findDefaultServant("");
        test(r == servant);

        for (int idx = 0; idx < 5; ++idx)
        {
            identity.name = names[idx];
            prx           = Test.MyObjectPrxHelper.uncheckedCast(oa.createProxy(identity));
            prx.ice_ping();
            test(prx.getName() == names[idx]);
        }

        Console.Out.WriteLine("ok");
    }
Exemplo n.º 5
0
            allTests(global::Test.TestHelper helper)
            {
                var           output       = helper.getWriter();
                Communicator  communicator = helper.communicator();
                ObjectAdapter oa           = communicator.createObjectAdapterWithEndpoints("MyOA", "tcp -h localhost");

                oa.Activate();

                var  servantI = new MyObjectI();
                var  servantT = default(MyObjectTraits);
                Disp servantD = (incoming, current) => servantT.Dispatch(servantI, incoming, current);

                //
                // Register default servant with category "foo"
                //
                oa.AddDefaultServant(servantD, "foo");

                //
                // Start test
                //
                output.Write("testing single category... ");
                output.Flush();

                Disp r = oa.FindDefaultServant("foo");

                test(r == servantD);

                r = oa.FindDefaultServant("bar");
                test(r == null);

                Ice.Identity identity = new Ice.Identity();
                identity.category = "foo";

                string[] names = new string[] { "foo", "bar", "x", "y", "abcdefg" };

                IMyObjectPrx prx = null;

                for (int idx = 0; idx < 5; ++idx)
                {
                    identity.name = names[idx];
                    prx           = IMyObjectPrx.UncheckedCast(oa.CreateProxy(identity));
                    prx.IcePing();
                    test(prx.getName() == names[idx]);
                }

                identity.name = "ObjectNotExist";
                prx           = IMyObjectPrx.UncheckedCast(oa.CreateProxy(identity));
                try
                {
                    prx.IcePing();
                    test(false);
                }
                catch (ObjectNotExistException)
                {
                    // Expected
                }

                try
                {
                    prx.getName();
                    test(false);
                }
                catch (ObjectNotExistException)
                {
                    // Expected
                }

                identity.name = "FacetNotExist";
                prx           = IMyObjectPrx.UncheckedCast(oa.CreateProxy(identity));
                try
                {
                    prx.IcePing();
                    test(false);
                }
                catch (FacetNotExistException)
                {
                    // Expected
                }

                try
                {
                    prx.getName();
                    test(false);
                }
                catch (FacetNotExistException)
                {
                    // Expected
                }

                identity.category = "bar";
                for (int idx = 0; idx < 5; idx++)
                {
                    identity.name = names[idx];
                    prx           = Test.IMyObjectPrx.UncheckedCast(oa.CreateProxy(identity));

                    try
                    {
                        prx.IcePing();
                        test(false);
                    }
                    catch (Ice.ObjectNotExistException)
                    {
                        // Expected
                    }

                    try
                    {
                        prx.getName();
                        test(false);
                    }
                    catch (Ice.ObjectNotExistException)
                    {
                        // Expected
                    }
                }

                oa.RemoveDefaultServant("foo");
                identity.category = "foo";
                prx = Test.IMyObjectPrx.UncheckedCast(oa.CreateProxy(identity));
                try
                {
                    prx.IcePing();
                }
                catch (Ice.ObjectNotExistException)
                {
                    // Expected
                }

                output.WriteLine("ok");

                output.Write("testing default category... ");
                output.Flush();

                oa.AddDefaultServant(servantD, "");

                r = oa.FindDefaultServant("bar");
                test(r == null);

                r = oa.FindDefaultServant("");
                test(r == servantD);

                for (int idx = 0; idx < 5; ++idx)
                {
                    identity.name = names[idx];
                    prx           = Test.IMyObjectPrx.UncheckedCast(oa.CreateProxy(identity));
                    prx.IcePing();
                    test(prx.getName() == names[idx]);
                }

                output.WriteLine("ok");
            }
Exemplo n.º 6
0
    allTests(Ice.Communicator communicator)
    {
        Ice.ObjectAdapter oa = communicator.createObjectAdapterWithEndpoints("MyOA", "tcp -h localhost");
        oa.activate();

        Ice.Object servant = new MyObjectI();

        //
        // Register default servant with category "foo"
        //
        oa.addDefaultServant(servant, "foo");

        //
        // Start test
        //
        Console.Out.Write("testing single category... ");
        Console.Out.Flush();

        Ice.Object r = oa.findDefaultServant("foo");
        test(r == servant);

        r = oa.findDefaultServant("bar");
        test(r == null);

        Ice.Identity identity = new Ice.Identity();
        identity.category = "foo";

        string[] names = new string[] { "foo", "bar", "x", "y", "abcdefg" };

        Test.MyObjectPrx prx = null;
        for(int idx = 0; idx < 5; ++idx)
        {
            identity.name = names[idx];
            prx = Test.MyObjectPrxHelper.uncheckedCast(oa.createProxy(identity));
            prx.ice_ping();
            test(prx.getName() == names[idx]);
        }

        identity.name = "ObjectNotExist";
        prx = Test.MyObjectPrxHelper.uncheckedCast(oa.createProxy(identity));
        try
        {
            prx.ice_ping();
            test(false);
        }
        catch(Ice.ObjectNotExistException)
        {
            // Expected
        }

        try
        {
            prx.getName();
            test(false);
        }
        catch(Ice.ObjectNotExistException)
        {
            // Expected
        }

        identity.name = "FacetNotExist";
        prx = Test.MyObjectPrxHelper.uncheckedCast(oa.createProxy(identity));
        try
        {
            prx.ice_ping();
            test(false);
        }
        catch(Ice.FacetNotExistException)
        {
            // Expected
        }

        try
        {
            prx.getName();
            test(false);
        }
        catch(Ice.FacetNotExistException)
        {
            // Expected
        }

        identity.category = "bar";
        for(int idx = 0; idx < 5; idx++)
        {
            identity.name = names[idx];
            prx = Test.MyObjectPrxHelper.uncheckedCast(oa.createProxy(identity));

            try
            {
                prx.ice_ping();
                test(false);
            }
            catch(Ice.ObjectNotExistException)
            {
                // Expected
            }

            try
            {
                prx.getName();
                test(false);
            }
            catch(Ice.ObjectNotExistException)
            {
                // Expected
            }
        }

        oa.removeDefaultServant("foo");
        identity.category = "foo";
        prx = Test.MyObjectPrxHelper.uncheckedCast(oa.createProxy(identity));
        try
        {
            prx.ice_ping();
        }
        catch(Ice.ObjectNotExistException)
        {
            // Expected
        }

        Console.Out.WriteLine("ok");

        Console.Out.Write("testing default category... ");
        Console.Out.Flush();

        oa.addDefaultServant(servant, "");

        r = oa.findDefaultServant("bar");
        test(r == null);

        r = oa.findDefaultServant("");
        test(r == servant);

        for(int idx = 0; idx < 5; ++idx)
        {
            identity.name = names[idx];
            prx = Test.MyObjectPrxHelper.uncheckedCast(oa.createProxy(identity));
            prx.ice_ping();
            test(prx.getName() == names[idx]);
        }

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