예제 #1
0
        public override void run(string[] args)
        {
            bool async = args.Any(v => v.Equals("--async"));

            using var communicator = initialize(ref args);
            communicator.SetProperty("TestAdapter.Endpoints", getTestEndpoint(0));
            ObjectAdapter adapter = communicator.CreateObjectAdapter("TestAdapter");

            if (async)
            {
                adapter.AddDefault(new BlobjectAsyncI());
            }
            else
            {
                adapter.AddDefault(new BlobjectI());
            }
            adapter.Activate();
            serverReady();
            communicator.WaitForShutdown();
        }
예제 #2
0
파일: Server.cs 프로젝트: yuwenyong/ice
        public override void Run(string[] args)
        {
            using Communicator communicator = Initialize(ref args);
            communicator.SetProperty("TestAdapter.Endpoints", GetTestEndpoint(0));
            ObjectAdapter adapter = communicator.CreateObjectAdapter("TestAdapter");

            adapter.AddDefault(new Servant());
            adapter.Activate();
            ServerReady();
            adapter.WaitForDeactivate();
        }
예제 #3
0
        public override void run(string[] args)
        {
            using var communicator = initialize(ref args);
            communicator.SetProperty("TestAdapter.Endpoints", getTestEndpoint(0));
            ObjectAdapter adapter = communicator.CreateObjectAdapter("TestAdapter");

            adapter.AddDefault(new BlobjectI());
            adapter.Activate();
            serverReady();
            communicator.WaitForShutdown();
        }
예제 #4
0
        public override async Task RunAsync(string[] args)
        {
            await using Communicator communicator = Initialize(ref args);
            communicator.SetProperty("TestAdapter.Endpoints", GetTestEndpoint(0));

            ObjectAdapter adapter = communicator.CreateObjectAdapter("TestAdapter");

            adapter.AddDefault(new Servant());

            AllTests.allTests(this);
        }
예제 #5
0
파일: Server.cs 프로젝트: renchuanrc/ice
        public override async Task RunAsync(string[] args)
        {
            await using Communicator communicator = Initialize(ref args);
            communicator.SetProperty("TestAdapter.Endpoints", GetTestEndpoint(0));
            ObjectAdapter adapter = communicator.CreateObjectAdapter("TestAdapter");

            adapter.AddDefault(new BlobjectI());
            await adapter.ActivateAsync();

            ServerReady();
            await communicator.WaitForShutdownAsync();
        }
예제 #6
0
파일: Server.cs 프로젝트: yuweiApp/ice
        public override void Run(string[] args)
        {
            using Communicator communicator = Initialize(ref args);
            communicator.SetProperty("TestAdapter.Endpoints", GetTestEndpoint(0));
            ObjectAdapter adapter = communicator.CreateObjectAdapter("TestAdapter");
            var           blob    = new BlobjectI();

            adapter.AddDefault(blob);
            adapter.Add("__echo", new Echo());
            adapter.Activate();
            communicator.WaitForShutdown();
        }
예제 #7
0
        public override async Task RunAsync(string[] args)
        {
            await Communicator.ActivateAsync();

            Communicator.SetProperty("TestAdapter.Endpoints", GetTestEndpoint(0));

            ObjectAdapter adapter = Communicator.CreateObjectAdapter("TestAdapter");

            adapter.AddDefault(new Servant());

            await AllTests.RunAsync(this);
        }
예제 #8
0
        public override async Task RunAsync(string[] args)
        {
            await Communicator.ActivateAsync();

            Communicator.SetProperty("TestAdapter.Endpoints", GetTestEndpoint(0));

            ObjectAdapter adapter = Communicator.CreateObjectAdapter("TestAdapter");

            adapter.AddDefault(new Servant());
            await adapter.ActivateAsync();

            ServerReady();
            await Communicator.ShutdownComplete;
        }
예제 #9
0
            public override void Run(string[] args)
            {
                using Communicator communicator = Initialize(ref args);
                communicator.SetProperty("TestAdapter.Endpoints", GetTestEndpoint(0));

                // 2 threads are necessary to dispatch the collocated transient() call with AMI
                communicator.SetProperty("TestAdapter.ThreadPool.Size", "2");

                ObjectAdapter adapter = communicator.CreateObjectAdapter("TestAdapter");

                adapter.AddDefault(new Servant());

                AllTests.allTests(this);

                adapter.WaitForDeactivate();
            }
예제 #10
0
파일: AllTests.cs 프로젝트: yuwenyong/ice
        Run(TestHelper helper)
        {
            TextWriter   output       = helper.GetWriter();
            Communicator?communicator = helper.Communicator();

            TestHelper.Assert(communicator != null);
            ObjectAdapter oa = communicator.CreateObjectAdapterWithEndpoints("MyOA", "tcp -h localhost");

            oa.Activate();

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

            var servant = new MyObject();

            oa.AddDefaultForCategory("foo", servant);
            try
            {
                oa.AddDefaultForCategory("foo", new MyObject());
                TestHelper.Assert(false); // duplicate registration not allowed
            }
            catch (System.ArgumentException)
            {
                // Expected
            }

            IObject?r = oa.Find("foo");

            TestHelper.Assert(r == null);
            r = oa.Find("foo/someId");
            TestHelper.Assert(r == servant);
            r = oa.Find("bar/someId");
            TestHelper.Assert(r == null);

            var identity = new Identity("", "foo");

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

            IMyObjectPrx?prx = null;

            for (int idx = 0; idx < 5; ++idx)
            {
                identity = new Identity(names[idx], identity.Category);
                prx      = oa.CreateProxy(identity, IMyObjectPrx.Factory);
                prx.IcePing();
                TestHelper.Assert(prx.GetName() == names[idx]);
            }

            identity = new Identity("ObjectNotExist", identity.Category);
            prx      = oa.CreateProxy(identity, IMyObjectPrx.Factory);
            try
            {
                prx.IcePing();
                TestHelper.Assert(false);
            }
            catch (ObjectNotExistException)
            {
                // Expected
            }

            try
            {
                prx.GetName();
                TestHelper.Assert(false);
            }
            catch (ObjectNotExistException)
            {
                // Expected
            }

            identity = new Identity(identity.Name, "bar");
            for (int idx = 0; idx < 5; idx++)
            {
                identity = new Identity(names[idx], identity.Category);
                prx      = oa.CreateProxy(identity, Test.IMyObjectPrx.Factory);

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

                try
                {
                    prx.GetName();
                    TestHelper.Assert(false);
                }
                catch (Ice.ObjectNotExistException)
                {
                    // Expected
                }
            }

            IObject?removed = oa.RemoveDefaultForCategory("foo");

            TestHelper.Assert(removed == servant);
            removed = oa.RemoveDefaultForCategory("foo");
            TestHelper.Assert(removed == null);
            identity = new Identity(identity.Name, "foo");
            prx      = oa.CreateProxy(identity, IMyObjectPrx.Factory);
            try
            {
                prx.IcePing();
            }
            catch (ObjectNotExistException)
            {
                // Expected
            }

            output.WriteLine("ok");

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

            var defaultServant = new MyObject();

            oa.AddDefault(defaultServant);
            try
            {
                oa.AddDefault(servant);
                TestHelper.Assert(false);
            }
            catch (System.ArgumentException)
            {
                // Expected
            }

            oa.AddDefaultForCategory("", servant); // associated with empty category

            r = oa.Find("bar");
            TestHelper.Assert(r == servant);

            r = oa.Find("x/y");
            TestHelper.Assert(r == defaultServant);

            for (int idx = 0; idx < 5; ++idx)
            {
                identity = new Identity(names[idx], "");
                prx      = oa.CreateProxy(identity, IMyObjectPrx.Factory);
                prx.IcePing();
                TestHelper.Assert(prx.GetName() == names[idx]);
            }

            removed = oa.RemoveDefault();
            TestHelper.Assert(removed == defaultServant);
            removed = oa.RemoveDefault();
            TestHelper.Assert(removed == null);

            output.WriteLine("ok");
        }
예제 #11
0
        public static async Task RunAsync(TestHelper helper)
        {
            TextWriter   output       = helper.Output;
            Communicator?communicator = helper.Communicator;

            TestHelper.Assert(communicator != null);

            ObjectAdapter oa = communicator.CreateObjectAdapterWithEndpoints("MyOA",
                                                                             helper.GetTestEndpoint(ephemeral: true));
            await oa.ActivateAsync();

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

            var servant = new MyObject();

            oa.AddDefaultForCategory("foo", servant);
            try
            {
                oa.AddDefaultForCategory("foo", new MyObject());
                TestHelper.Assert(false); // duplicate registration not allowed
            }
            catch (ArgumentException)
            {
                // Expected
            }

            IObject?r = oa.Find("foo");

            TestHelper.Assert(r == null);
            r = oa.Find("foo/someId");
            TestHelper.Assert(r == servant);
            r = oa.Find("bar/someId");
            TestHelper.Assert(r == null);

            var identity = new Identity("", "foo");

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

            IMyObjectPrx?prx = null;

            foreach (string name in names)
            {
                identity = new Identity(name, identity.Category);
                prx      = oa.CreateProxy(identity, IMyObjectPrx.Factory);
                prx.IcePing();
                TestHelper.Assert(prx.GetName() == name);
            }

            identity = new Identity("ObjectNotExist", identity.Category);
            prx      = oa.CreateProxy(identity, IMyObjectPrx.Factory);
            try
            {
                prx.IcePing();
                TestHelper.Assert(false);
            }
            catch (ObjectNotExistException)
            {
                // Expected
            }

            try
            {
                prx.GetName();
                TestHelper.Assert(false);
            }
            catch (ObjectNotExistException)
            {
                // Expected
            }

            identity = new Identity(identity.Name, "bar");
            foreach (string name in names)
            {
                identity = new Identity(name, identity.Category);
                prx      = oa.CreateProxy(identity, IMyObjectPrx.Factory);

                try
                {
                    prx.IcePing();
                    TestHelper.Assert(false);
                }
                catch (ObjectNotExistException)
                {
                    // Expected
                }

                try
                {
                    prx.GetName();
                    TestHelper.Assert(false);
                }
                catch (ObjectNotExistException)
                {
                    // Expected
                }
            }

            IObject?removed = oa.RemoveDefaultForCategory("foo");

            TestHelper.Assert(removed == servant);
            removed = oa.RemoveDefaultForCategory("foo");
            TestHelper.Assert(removed == null);
            identity = new Identity(identity.Name, "foo");
            prx      = oa.CreateProxy(identity, IMyObjectPrx.Factory);
            try
            {
                prx.IcePing();
            }
            catch (ObjectNotExistException)
            {
                // Expected
            }

            output.WriteLine("ok");

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

            var defaultServant = new MyObject();

            oa.AddDefault(defaultServant);
            try
            {
                oa.AddDefault(servant);
                TestHelper.Assert(false);
            }
            catch (ArgumentException)
            {
                // Expected
            }

            oa.AddDefaultForCategory("", servant); // associated with empty category

            r = oa.Find("bar");
            TestHelper.Assert(r == servant);

            r = oa.Find("x/y");
            TestHelper.Assert(r == defaultServant);

            foreach (string name in names)
            {
                identity = new Identity(name, "");
                prx      = oa.CreateProxy(identity, IMyObjectPrx.Factory);
                prx.IcePing();
                TestHelper.Assert(prx.GetName() == name);
            }

            removed = oa.RemoveDefault();
            TestHelper.Assert(removed == defaultServant);
            removed = oa.RemoveDefault();
            TestHelper.Assert(removed == null);

            output.WriteLine("ok");
        }