public AbstractIceRuntime()
        {
            if (communicator == null)
            {
                InitializationData initdata = new InitializationData();

                initdata.properties = Util.createProperties();
                initdata.properties.setProperty("Ice.Default.Locator", this.Locator);
                initdata.properties.setProperty("Ice.MessageSizeMax", "102400");
                initdata.properties.setProperty("Ice.ACM.Client", "0");

                communicator = Util.initialize(initdata);
            }
        }
Exemple #2
0
        /// 开启ICE
        public void Start()
        {
            try
            {
                var initData = new InitializationData();

                //设置属性
                if (iceClientOptions.Properties != null)
                {
                    initData.properties = iceClientOptions.Properties;
                }
                else
                {
                    initData.properties = Util.createProperties();
                }
                //initData.properties.setProperty("Ice.ACM.Client.Heartbeat", "Always");
                //initData.properties.setProperty("Ice.RetryIntervals", "-1");
                initData.properties.setProperty("Ice.FactoryAssemblies", "client");
                initData.properties.setProperty("Ice.Trace.Network", "1");
                initData.properties.setProperty("Ice.Default.Timeout", "15000");
                initData.logger = new NLogice();

                //设置dispatcher,由主线程调用
                if (iceClientOptions.EnableDispatcher)
                {
                    initData.dispatcher = delegate(Action action, Connection connection)
                    {
                        lock (this)
                        {
                            actions.Add(action);
                        }
                    };
                }

                Communicator = Util.initialize(initData);
                Adapter      = Communicator.createObjectAdapter("");
                Thread thread = new Thread(new ThreadStart(() =>
                {
                    Communicator.waitForShutdown();
                    NLogger.Info("ice closed!");
                }));

                thread.Start();
                NLogger.Info("ice started!");
            }
            catch (System.Exception ex)
            {
                NLogger.Error(ex.Message);
            }
        }
Exemple #3
0
        //build the comunicator
        private Communicator buildComunicator()
        {
            _logger.LogDebug("Initializing Communicator v{0} ({1}) ..", Ice.Util.stringVersion(), Ice.Util.intVersion());

            Properties properties = Util.createProperties();

            properties.setProperty("Ice.Trace.Network", "3");

            InitializationData initializationData = new InitializationData();

            initializationData.properties = properties;

            return(Ice.Util.initialize(initializationData));
        }
Exemple #4
0
            public override void run(string[] args)
            {
                var initData = new InitializationData();

                initData.typeIdNamespaces = new string[] { "Ice.scope.TypeId" };
                initData.properties       = createTestProperties(ref args);
                using (var communicator = initialize(initData))
                {
                    var output = getWriter();
                    output.Write("test same Slice type name in different scopes... ");
                    output.Flush();
                    AllTests.allTests(this);
                    output.WriteLine("ok");
                }
            }
        public PayloadDecompressor(InitializationData initializationData)
        {
            if (initializationData == null)
            {
                throw new ArgumentNullException(nameof(initializationData));
            }

            _initializationData       = initializationData;
            _payloadContract          = initializationData.CompressionContracts[nameof(PayloadContract)].ToObject <PayloadContract>();
            _collidableContract       = initializationData.CompressionContracts[nameof(CollidableContract)].ToObject <CollidableContract>();
            _shipContract             = initializationData.CompressionContracts[nameof(ShipContract)].ToObject <ShipContract>();
            _bulletContract           = initializationData.CompressionContracts[nameof(BulletContract)].ToObject <BulletContract>();
            _leaderboardEntryContract = initializationData.CompressionContracts[nameof(LeaderboardEntryContract)].ToObject <LeaderboardEntryContract>();
            _powerupContract          = initializationData.CompressionContracts[nameof(PowerupContract)].ToObject <PowerupContract>();
        }
Exemple #6
0
            public override void run(string[] args)
            {
                var initData = new InitializationData();

                initData.typeIdNamespaces = new string[] { "Ice.exceptions.TypeId" };
                initData.properties       = createTestProperties(ref args);
                initData.properties.setProperty("Ice.Warn.Connections", "0");
                initData.properties.setProperty("Ice.MessageSizeMax", "10"); // 10KB max
                using (var communicator = initialize(initData))
                {
                    communicator.getProperties().setProperty("TestAdapter.Endpoints", getTestEndpoint(0));
                    var thrower = AllTests.allTests(this);
                    thrower.shutdown();
                }
            }
Exemple #7
0
            public override void run(string[] args)
            {
                var initData = new InitializationData();

                initData.typeIdNamespaces = new string[] { "Ice.seqMapping.TypeId" };
                initData.properties       = createTestProperties(ref args);
                using (var communicator = initialize(initData))
                {
                    var myClass = AllTests.allTests(this, false);
                    Console.Out.Write("shutting down server... ");
                    Console.Out.Flush();
                    myClass.shutdown();
                    Console.Out.WriteLine("ok");
                }
            }
Exemple #8
0
            public override void run(string[] args)
            {
                var initData = new InitializationData();

                initData.typeIdNamespaces = new string[] { "Ice.seqMapping.TypeId" };
                initData.properties       = createTestProperties(ref args);
                using (var communicator = initialize(initData))
                {
                    communicator.getProperties().setProperty("TestAdapter.Endpoints", getTestEndpoint(0));
                    var adapter = communicator.createObjectAdapter("TestAdapter");
                    adapter.Add(new MyClassI(), "test");
                    //adapter.activate(); // Don't activate OA to ensure collocation is used.
                    AllTests.allTests(this, true);
                }
            }
Exemple #9
0
                public override void run(string[] args)
                {
                    var initData = new InitializationData();

                    initData.typeIdNamespaces = new string[] { "Ice.seqMapping.AMD.TypeId" };
                    initData.properties       = createTestProperties(ref args);
                    using (var communicator = initialize(initData))
                    {
                        communicator.getProperties().setProperty("TestAdapter.Endpoints", getTestEndpoint(0));
                        var adapter = communicator.createObjectAdapter("TestAdapter");
                        adapter.add(new MyClassI(), Ice.Util.stringToIdentity("test"));
                        adapter.activate();
                        serverReady();
                        communicator.waitForShutdown();
                    }
                }
Exemple #10
0
        static void Main(string[] args)
        {
            Server server = new Server();

            InitializationData initializationData = new InitializationData {
                properties = Util.createProperties()
            };

            initializationData.properties.setProperty("Ice.ThreadPool.Client.Size", "1");
            initializationData.properties.setProperty("Ice.ThreadPool.Client.SizeMax", "10");
            initializationData.properties.setProperty("Ice.ThreadPool.Server.Size", "1");
            initializationData.properties.setProperty("Ice.ThreadPool.Server.SizeMax", "10");
            initializationData.properties.setProperty("Ice.ACM.Client", "0");

            Environment.Exit(server.main(args, initializationData));
        }
Exemple #11
0
            public override void run(string[] args)
            {
                var initData = new InitializationData();

                initData.typeIdNamespaces = new string[] { "Ice.optional.TypeId" };
                initData.properties       = createTestProperties(ref args);
                using (var communicator = initialize(initData))
                {
                    communicator.Properties.setProperty("TestAdapter.Endpoints", getTestEndpoint(0));
                    var adapter = communicator.createObjectAdapter("TestAdapter");
                    adapter.Add(new InitialI(), "initial");
                    adapter.Activate();
                    serverReady();
                    communicator.waitForShutdown();
                }
            }
Exemple #12
0
        public void Prepare(InitializationData data, ILogger logger)
        {
            if (data == null)
            {
                throw new ArgumentNullException("data");
            }
            if (data.ServiceInfo == null)
            {
                throw new ArgumentException("No valid ServiceInfo in InitializationData");
            }
            if (data.ServiceInfo.Initializer == null)
            {
                throw new ArgumentException("No valid initializer in InitializationData");
            }

            _initializationData = data;
        }
Exemple #13
0
            public override void run(string[] args)
            {
                var initData = new InitializationData();

                initData.typeIdNamespaces = new string[] { "Ice.exceptions.TypeId" };
                initData.properties       = createTestProperties(ref args);
                initData.properties.setProperty("Ice.Warn.Connections", "0");
                initData.properties.setProperty("Ice.Warn.Dispatch", "0");
                initData.properties.setProperty("Ice.MessageSizeMax", "10"); // 10KB max
                using (var communicator = initialize(initData))
                {
                    communicator.Properties.setProperty("TestAdapter.Endpoints", getTestEndpoint(0));
                    ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter");
                    adapter.Add(new ThrowerI(), "thrower");
                    AllTests.allTests(this);
                }
            }
 public RelayCommunicator(string applicationName, string configFileClasspath)
 {
     try
     {
         InitializationData initData = new InitializationData();
         initData.properties = Util.createProperties();
         Trace.TraceInformation("About to load properties...");
         initData.properties.load(configFileClasspath);
         Trace.TraceInformation("Done loading properties!  About to call Util.initialize()...");
         communicator = Util.initialize(initData);
         Trace.TraceInformation("Done calling Util.initialize()!");
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Exemple #15
0
 public void Start(string args, ACMCloseFlag close = ACMCloseFlag.CloseOff, ACMHeartbeatFlag heartbeat = ACMHeartbeatFlag.HeartbeatOff)
 {
     acmClose     = close;
     acmHeartbeat = heartbeat;
     if (communicator == null || communicator.isShutdown())
     {
         Status = BundleStatus.Starting;
         try
         {
             const int SIZE_MAX = 128 * 1024 * 1024;
             var       initData = new InitializationData();
             initData.properties = Util.createProperties();
             initData.properties.setProperty("Ice.Trace.Network", "2");
             initData.properties.setProperty("Ice.MessageSizeMax", $"{SIZE_MAX}");
             initData.properties.setProperty("Filesystem.MaxFileSize", $"{SIZE_MAX}");
             initData.properties.setProperty("Ice.ACM.Close", $"{(int)acmClose}");
             initData.properties.setProperty("Ice.ACM.Heartbeat", $"{(int)acmHeartbeat}");
             communicator = Util.initialize(initData);
             var pos  = args.IndexOf(':');
             var name = "SimpleMessenger";
             if (pos > 0)
             {
                 name = args.Substring(0, pos);
                 args = args.Substring(pos + 1).TrimStart();
             }
             ObjectAdapter objectAdapter = communicator.createObjectAdapterWithEndpoints("SimpleMessengerAdapter", args);
             servant = new WorkerImpl(OnMethodInvoked);
             Identity id = Util.stringToIdentity(name);
             objectAdapter.add(servant, id);
             objectAdapter.activate();
             Status = BundleStatus.Running;
             communicator.waitForShutdown();
             Status = BundleStatus.Idle;
         }
         catch (System.Exception ex)
         {
             Status = BundleStatus.Exception;
             OnExceptionOccured?.Invoke(ex);
         }
     }
     else
     {
         Status = BundleStatus.Unknown;
     }
 }
Exemple #16
0
            public override void run(string[] args)
            {
                var initData = new InitializationData();

                initData.typeIdNamespaces = new string[] { "Ice.objects.TypeId" };
                initData.properties       = createTestProperties(ref args);
                initData.properties.setProperty("Ice.Warn.Dispatch", "0");
                using (var communicator = initialize(initData))
                {
                    communicator.Properties.setProperty("TestAdapter.Endpoints", getTestEndpoint(0));
                    Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter");
                    adapter.Add(new InitialI(adapter), "initial");
                    adapter.Add(new F2I(), "F21");
                    var uoet = new UnexpectedObjectExceptionTestI();
                    adapter.Add((incoming, current) => uoet.Dispatch(incoming, current), "uoet");
                    Test.AllTests.allTests(this);
                }
            }
        private static OrdinalModel OrdinalModel()
        {
            FieldParameters parameters = new FieldParameters()
            {
                Size = 10
            };
            OrdinalModel model = new OrdinalModel(parameters);

            InitializationData data = new InitializationData(typeof(TickerElement))
            {
                Count           = Count,
                InitialazerType = typeof(RandomInitializer)
            };
            Initializer initializer = Initializer.FromInitializationData(data);

            model.Initialize(new[] { initializer });
            return(model);
        }
Exemple #18
0
 private void Window_Loaded(object sender, EventArgs e)
 {
     try
     {
         var initData = new InitializationData();
         initData.properties = Util.createProperties();
         initData.properties.load("config.client");
         initData.dispatcher = (Action action, Connection connection) =>
         {
             Dispatcher.BeginInvoke(DispatcherPriority.Normal, action);
         };
         _communicator = Util.initialize(initData);
         updateProxy();
     }
     catch (LocalException ex)
     {
         handleException(ex);
     }
 }
Exemple #19
0
        /// <summary>
        /// communicator
        /// </summary>
        /// <returns></returns>
        private Communicator buildCommunicator()
        {
            _logger.LogDebug("Initializing Communicator v{0} ({1}) .. ", Ice.Util.stringVersion(), Ice.Util.intVersion());

            //ZeroC Properties
            Properties properties = Util.createProperties();
            // https://doc.zeroc.com/ice/latest/property-reference/ice-trace
            // properties.setProperty("Ice.Trace.Admin.Properties", "1");
            // properties.setProperty("Ice.Trace.Locator", "2");
            // properties.setProperty("Ice.Trace.Network", "3");
            // properties.setProperty("Ice.Trace.Protocol", "1");
            // properties.setProperty("Ice.Trace.Slicing", "1");
            // properties.setProperty("Ice.Trace.ThreadPool", "1");
            // properties.setProperty("Ice.Compression.Level", "9");
            InitializationData initializationData = new InitializationData();

            initializationData.properties = properties;
            return(Ice.Util.initialize(initializationData));
        }
Exemple #20
0
            public override void run(string[] args)
            {
                var initData = new InitializationData();

                initData.typeIdNamespaces = new string[] { "Ice.servantLocator.TypeId" };
                initData.properties       = createTestProperties(ref args);
                using (var communicator = initialize(initData))
                {
                    communicator.getProperties().setProperty("TestAdapter.Endpoints", getTestEndpoint(0));
                    communicator.getProperties().setProperty("Ice.Warn.Dispatch", "0");

                    var adapter = communicator.createObjectAdapter("TestAdapter");
                    adapter.addServantLocator(new ServantLocatorI("category"), "category");
                    adapter.addServantLocator(new ServantLocatorI(""), "");
                    adapter.add(new TestI(), Ice.Util.stringToIdentity("asm"));
                    adapter.add(new TestActivationI(), Ice.Util.stringToIdentity("test/activation"));
                    AllTests.allTests(this);
                }
            }
 private void Window_Loaded(object sender, EventArgs e)
 {
     try
     {
         var initData = new InitializationData();
         initData.properties = Util.createProperties();
         initData.properties.load("config.client");
         initData.dispatcher = (Action action, Connection connection) =>
             {
                 Dispatcher.BeginInvoke(DispatcherPriority.Normal, action);
             };
         _communicator = Util.initialize(initData);
         updateProxy();
     }
     catch(LocalException ex)
     {
         handleException(ex);
     }
 }
Exemple #22
0
            public override void run(string[] args)
            {
                var initData = new InitializationData();

                initData.typeIdNamespaces = new string[] { "Ice.operations.TypeId" };
                initData.properties       = createTestProperties(ref args);
                //
                // We don't want connection warnings because of the timeout test.
                //
                initData.properties.setProperty("Ice.Warn.Connections", "0");
                using (var communicator = initialize(initData))
                {
                    communicator.getProperties().setProperty("TestAdapter.Endpoints", getTestEndpoint(0));
                    ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter");
                    adapter.Add(new MyDerivedClassI(), "test");
                    adapter.Activate();
                    serverReady();
                    communicator.waitForShutdown();
                }
            }
Exemple #23
0
            public override void run(string[] args)
            {
                var initData = new InitializationData();

                initData.typeIdNamespaces = new string[] { "Ice.objects.TypeId" };
                initData.properties       = createTestProperties(ref args);
                initData.properties.setProperty("Ice.Warn.Dispatch", "0");
                using (var communicator = initialize(initData))
                {
                    communicator.getProperties().setProperty("TestAdapter.Endpoints", getTestEndpoint(0));
                    Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter");
                    var initial = new InitialI(adapter);
                    adapter.add(initial, Ice.Util.stringToIdentity("initial"));
                    var uet = new UnexpectedObjectExceptionTestI();
                    adapter.add(uet, Ice.Util.stringToIdentity("uoet"));
                    Test.AllTests.allTests(this);
                    // We must call shutdown even in the collocated case for cyclic dependency cleanup
                    initial.shutdown();
                }
            }
Exemple #24
0
                public override void run(string[] args)
                {
                    var initData = new InitializationData();

                    initData.typeIdNamespaces = new string[] { "Ice.servantLocator.AMD.TypeId" };
                    initData.properties       = createTestProperties(ref args);
                    using (var communicator = initialize(initData))
                    {
                        communicator.Properties.setProperty("TestAdapter.Endpoints", getTestEndpoint(0));
                        communicator.Properties.setProperty("Ice.Warn.Dispatch", "0");

                        var adapter = communicator.createObjectAdapter("TestAdapter");
                        adapter.AddServantLocator(new ServantLocatorI("category"), "category");
                        adapter.AddServantLocator(new ServantLocatorI(""), "");
                        adapter.Add(new TestI(), "asm");
                        adapter.Add(new TestActivationI(), "test/activation");
                        adapter.Activate();
                        serverReady();
                        adapter.WaitForDeactivate();
                    }
                }
 /**
  * Creates a DirectConnectCommunicator.  The caller is responsible for calling {@link #waitForShutdown()}.
  */
 public DirectConnectCommunicator(string applicationName, string configFileClasspath, string objectAdapterName, QwerkClientServantFactory servantFactory)
 {
     log("constructor called");
     this.applicationName   = applicationName;
     this.servantFactory    = servantFactory;
     this.objectAdapterName = objectAdapterName;
     log("About to do properties loading try block...");
     try
     {
         InitializationData initData = new InitializationData();
         initData.properties = Util.createProperties();
         initData.properties.load(configFileClasspath);
         communicator = Util.initialize(initData);
         log("Properties Loaded!");
     }
     catch (Exception e)
     {
         log(e.ToString());
         throw e;
     }
     log("constructor terminated");
 }
Exemple #26
0
            public override void run(string[] args)
            {
                var initData = new InitializationData();

                initData.typeIdNamespaces = new string[] { "Ice.objects.TypeId" };
                initData.properties       = createTestProperties(ref args);
                initData.properties.setProperty("Ice.Warn.Dispatch", "0");
                using (var communicator = initialize(initData))
                {
                    communicator.getProperties().setProperty("TestAdapter.Endpoints", getTestEndpoint(0));
                    Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter");
                    Ice.Object        @object = new InitialI(adapter);
                    adapter.add(@object, Ice.Util.stringToIdentity("initial"));
                    @object = new F2I();
                    adapter.add(@object, Ice.Util.stringToIdentity("F21"));
                    @object = new UnexpectedObjectExceptionTestI();
                    adapter.add(@object, Ice.Util.stringToIdentity("uoet"));
                    adapter.activate();
                    serverReady();
                    communicator.waitForShutdown();
                }
            }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env,
                              RoleManager <AccountRole> roleManager,
                              UserManager <AccountUser> userManager)
        {
            using (var serviceScope = app.ApplicationServices.GetService <IServiceScopeFactory>().CreateScope())
            {
                var context = serviceScope.ServiceProvider.GetRequiredService <Personnel_ServiceContext>();
                InitializationData.Initialize(context, roleManager, userManager).Wait();
                context.Database.Migrate();
            }

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }
            app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthentication();
            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
            });
        }
Exemple #28
0
        public int Connect()
        {
            try
            {
                if (_ic == null)
                {
                    var icData = new InitializationData();
                    _ic = Ice.Util.initialize(icData);

                    GetTradeServant();
                    //GetQueryServant();

                    _isConnected = true;
                    return(0);
                }
            }
            catch (System.Exception ex)
            {
                Program.logger.LogInfo("PortClient:{0},交易接口连接初始化失败!\r\n{1}", _id, ex);
                //App.Logger.Error(string.Format("PortClient:{0},交易接口连接初始化失败!", _id), ex);
            }

            return(1);
        }
Exemple #29
0
        public ControllerI(MainPage mainPage)
        {
            IceSSL.Util.registerIceSSL(false);
            IceDiscovery.Util.registerIceDiscovery(false);
            _mainPage = mainPage;
            var initData = new InitializationData();

            initData.properties = Util.createProperties();
            initData.properties.setProperty("Ice.ThreadPool.Client.SizeMax", "10");
            initData.properties.setProperty("Ice.ThreadPool.Server.SizeMax", "10");
            initData.properties.setProperty("ControllerAdapter.Endpoints", "tcp");
            initData.properties.setProperty("Ice.Override.ConnectTimeout", "1000");
            //initData.properties.setProperty("Ice.Trace.Network", "3");
            //initData.properties.setProperty("Ice.Trace.Protocol", "1");
            initData.properties.setProperty("ControllerAdapter.AdapterId", new Guid().ToString());

            if (!mainPage.platformAdapter.registerProcessController())
            {
                initData.properties.setProperty("Ice.Plugin.IceDiscovery", "IceDiscovery:IceDiscovery.PluginFactory");
                initData.properties.setProperty("IceDiscovery.DomainId", "TestController");
            }

            _communicator = Util.initialize(initData);

            _adapter           = _communicator.createObjectAdapter("ControllerAdapter");
            _processController = ProcessControllerPrxHelper.uncheckedCast(
                _adapter.add(new ProcessControllerI(mainPage),
                             Util.stringToIdentity(mainPage.platformAdapter.processControllerIdentity())));
            _adapter.activate();

            if (mainPage.platformAdapter.registerProcessController())
            {
                registerProcessController();
            }
            _mainPage.print(mainPage.platformAdapter.processControllerIdentity());
        }
Exemple #30
0
 protected override void UnregisterBilliardEventHandlers(InitializationData data)
 {
     Mode.OnBadBreak -= HandleBadBreak;
 }
Exemple #31
0
            public static void allTests(global::Test.TestHelper helper)
            {
                Communicator communicator = helper.communicator();
                var          manager      = ServerManagerPrx.Parse($"ServerManager :{helper.getTestEndpoint(0)}", communicator);
                var          locator      = TestLocatorPrx.UncheckedCast(communicator.getDefaultLocator());

                Console.WriteLine("registry checkedcast");
                var registry = TestLocatorRegistryPrx.CheckedCast(locator.getRegistry());

                test(registry != null);

                var output = helper.getWriter();

                output.Write("testing stringToProxy... ");
                output.Flush();
                var @base = IObjectPrx.Parse("test @ TestAdapter", communicator);
                var base2 = IObjectPrx.Parse("test @ TestAdapter", communicator);
                var base3 = IObjectPrx.Parse("test", communicator);
                var base4 = IObjectPrx.Parse("ServerManager", communicator);
                var base5 = IObjectPrx.Parse("test2", communicator);
                var base6 = IObjectPrx.Parse("test @ ReplicatedAdapter", communicator);

                output.WriteLine("ok");

                output.Write("testing ice_locator and ice_getLocator... ");
                test(Util.proxyIdentityCompare(@base.Locator, communicator.getDefaultLocator()) == 0);
                var anotherLocator = LocatorPrx.Parse("anotherLocator", communicator);

                @base = @base.Clone(locator: anotherLocator);
                test(Util.proxyIdentityCompare(@base.Locator, anotherLocator) == 0);
                communicator.setDefaultLocator(null);
                @base = IObjectPrx.Parse("test @ TestAdapter", communicator);
                test(@base.Locator == null);
                @base = @base.Clone(locator: anotherLocator);
                test(Util.proxyIdentityCompare(@base.Locator, anotherLocator) == 0);
                communicator.setDefaultLocator(locator);
                @base = IObjectPrx.Parse("test @ TestAdapter", communicator);
                test(Util.proxyIdentityCompare(@base.Locator, communicator.getDefaultLocator()) == 0);

                //
                // We also test ice_router/ice_getRouter(perhaps we should add a
                // test/Ice/router test?)
                //
                test(@base.Router == null);
                var anotherRouter = RouterPrx.Parse("anotherRouter", communicator);

                @base = @base.Clone(router: anotherRouter);
                test(Util.proxyIdentityCompare(@base.Router, anotherRouter) == 0);
                var router = RouterPrx.Parse("dummyrouter", communicator);

                communicator.setDefaultRouter(router);
                @base = IObjectPrx.Parse("test @ TestAdapter", communicator);
                test(Util.proxyIdentityCompare(@base.Router, communicator.getDefaultRouter()) == 0);
                communicator.setDefaultRouter(null);
                @base = IObjectPrx.Parse("test @ TestAdapter", communicator);
                test(@base.Router == null);
                output.WriteLine("ok");

                output.Write("starting server... ");
                output.Flush();
                manager.startServer();
                output.WriteLine("ok");

                output.Write("testing checked cast... ");
                output.Flush();
                var obj = Test.TestIntfPrx.CheckedCast(@base);

                test(obj != null);
                var obj2 = Test.TestIntfPrx.CheckedCast(base2);

                test(obj2 != null);
                var obj3 = Test.TestIntfPrx.CheckedCast(base3);

                test(obj3 != null);
                var obj4 = Test.ServerManagerPrx.CheckedCast(base4);

                test(obj4 != null);
                var obj5 = Test.TestIntfPrx.CheckedCast(base5);

                test(obj5 != null);
                var obj6 = Test.TestIntfPrx.CheckedCast(base6);

                test(obj6 != null);
                output.WriteLine("ok");

                output.Write("testing id@AdapterId indirect proxy... ");
                output.Flush();
                obj.shutdown();
                manager.startServer();
                try
                {
                    obj2.IcePing();
                }
                catch (LocalException)
                {
                    test(false);
                }
                output.WriteLine("ok");

                output.Write("testing id@ReplicaGroupId indirect proxy... ");
                output.Flush();
                obj.shutdown();
                manager.startServer();
                try
                {
                    obj6.IcePing();
                }
                catch (LocalException)
                {
                    test(false);
                }
                output.WriteLine("ok");

                output.Write("testing identity indirect proxy... ");
                output.Flush();
                obj.shutdown();
                manager.startServer();
                try
                {
                    obj3.IcePing();
                }
                catch (LocalException)
                {
                    test(false);
                }
                try
                {
                    obj2.IcePing();
                }
                catch (LocalException)
                {
                    test(false);
                }
                obj.shutdown();
                manager.startServer();
                try
                {
                    obj2.IcePing();
                }
                catch (LocalException)
                {
                    test(false);
                }
                try
                {
                    obj3.IcePing();
                }
                catch (LocalException)
                {
                    test(false);
                }
                obj.shutdown();
                manager.startServer();
                try
                {
                    obj2.IcePing();
                }
                catch (LocalException)
                {
                    test(false);
                }
                obj.shutdown();
                manager.startServer();
                try
                {
                    obj3.IcePing();
                }
                catch (LocalException)
                {
                    test(false);
                }
                obj.shutdown();
                manager.startServer();
                try
                {
                    obj5 = Test.TestIntfPrx.CheckedCast(base5);
                    obj5.IcePing();
                }
                catch (LocalException)
                {
                    test(false);
                }
                output.WriteLine("ok");

                output.Write("testing proxy with unknown identity... ");
                output.Flush();
                try
                {
                    @base = IObjectPrx.Parse("unknown/unknown", communicator);
                    @base.IcePing();
                    test(false);
                }
                catch (NotRegisteredException ex)
                {
                    test(ex.kindOfObject.Equals("object"));
                    test(ex.id.Equals("unknown/unknown"));
                }
                output.WriteLine("ok");

                output.Write("testing proxy with unknown adapter... ");
                output.Flush();
                try
                {
                    @base = IObjectPrx.Parse("test @ TestAdapterUnknown", communicator);
                    @base.IcePing();
                    test(false);
                }
                catch (NotRegisteredException ex)
                {
                    test(ex.kindOfObject.Equals("object adapter"));
                    test(ex.id.Equals("TestAdapterUnknown"));
                }
                output.WriteLine("ok");

                output.Write("testing locator cache timeout... ");
                output.Flush();

                var basencc = IObjectPrx.Parse("test@TestAdapter", communicator).Clone(connectionCached: false);
                int count   = locator.getRequestCount();

                basencc.Clone(locatorCacheTimeout: 0).IcePing(); // No locator cache.
                test(++count == locator.getRequestCount());
                basencc.Clone(locatorCacheTimeout: 0).IcePing(); // No locator cache.
                test(++count == locator.getRequestCount());
                basencc.Clone(locatorCacheTimeout: 2).IcePing(); // 2s timeout.
                test(count == locator.getRequestCount());
                System.Threading.Thread.Sleep(1300);             // 1300ms
                basencc.Clone(locatorCacheTimeout: 1).IcePing(); // 1s timeout.
                test(++count == locator.getRequestCount());

                IObjectPrx.Parse("test", communicator).Clone(locatorCacheTimeout: 0).IcePing(); // No locator cache.
                count += 2;
                test(count == locator.getRequestCount());
                IObjectPrx.Parse("test", communicator).Clone(locatorCacheTimeout: 2).IcePing(); // 2s timeout
                test(count == locator.getRequestCount());
                System.Threading.Thread.Sleep(1300);                                            // 1300ms
                IObjectPrx.Parse("test", communicator).Clone(locatorCacheTimeout: 1).IcePing(); // 1s timeout
                count += 2;
                test(count == locator.getRequestCount());

                IObjectPrx.Parse("test@TestAdapter", communicator).Clone(locatorCacheTimeout: -1).IcePing();
                test(count == locator.getRequestCount());
                IObjectPrx.Parse("test", communicator).Clone(locatorCacheTimeout: -1).IcePing();
                test(count == locator.getRequestCount());
                IObjectPrx.Parse("test@TestAdapter", communicator).IcePing();
                test(count == locator.getRequestCount());
                IObjectPrx.Parse("test", communicator).IcePing();
                test(count == locator.getRequestCount());

                test(IObjectPrx.Parse("test", communicator).Clone(locatorCacheTimeout: 99).LocatorCacheTimeout == 99);

                output.WriteLine("ok");

                output.Write("testing proxy from server... ");
                output.Flush();
                obj = TestIntfPrx.Parse("test@TestAdapter", communicator);
                var hello = obj.getHello();

                test(hello.AdapterId.Equals("TestAdapter"));
                hello.sayHello();
                hello = obj.getReplicatedHello();
                test(hello.AdapterId.Equals("ReplicatedAdapter"));
                hello.sayHello();
                output.WriteLine("ok");

                output.Write("testing locator request queuing... ");
                output.Flush();
                hello = obj.getReplicatedHello().Clone(locatorCacheTimeout: 0, connectionCached: false);
                count = locator.getRequestCount();
                hello.IcePing();
                test(++count == locator.getRequestCount());
                List <Task> results = new List <Task>();

                for (int i = 0; i < 1000; i++)
                {
                    results.Add(hello.sayHelloAsync());
                }
                Task.WaitAll(results.ToArray());
                results.Clear();
                test(locator.getRequestCount() > count && locator.getRequestCount() < count + 999);
                if (locator.getRequestCount() > count + 800)
                {
                    output.Write("queuing = " + (locator.getRequestCount() - count));
                }
                count = locator.getRequestCount();
                hello = hello.Clone(adapterId: "unknown");
                for (int i = 0; i < 1000; i++)
                {
                    results.Add(hello.sayHelloAsync().ContinueWith((Task t) =>
                    {
                        try
                        {
                            t.Wait();
                        }
                        catch (AggregateException ex) when(ex.InnerException is Ice.NotRegisteredException)
                        {
                        }
                    }));
                }
                Task.WaitAll(results.ToArray());
                results.Clear();
                // XXX:
                // Take into account the retries.
                test(locator.getRequestCount() > count && locator.getRequestCount() < count + 1999);
                if (locator.getRequestCount() > count + 800)
                {
                    output.Write("queuing = " + (locator.getRequestCount() - count));
                }
                output.WriteLine("ok");

                output.Write("testing adapter locator cache... ");
                output.Flush();
                try
                {
                    IObjectPrx.Parse("test@TestAdapter3", communicator).IcePing();
                    test(false);
                }
                catch (NotRegisteredException ex)
                {
                    test(ex.kindOfObject == "object adapter");
                    test(ex.id.Equals("TestAdapter3"));
                }
                registry.setAdapterDirectProxy("TestAdapter3", locator.findAdapterById("TestAdapter"));
                try
                {
                    IObjectPrx.Parse("test@TestAdapter3", communicator).IcePing();
                    registry.setAdapterDirectProxy("TestAdapter3",
                                                   IObjectPrx.Parse($"dummy:{helper.getTestEndpoint(99)}", communicator));
                    IObjectPrx.Parse("test@TestAdapter3", communicator).IcePing();
                }
                catch (LocalException)
                {
                    test(false);
                }

                try
                {
                    IObjectPrx.Parse("test@TestAdapter3", communicator).Clone(locatorCacheTimeout: 0).IcePing();
                    test(false);
                }
                catch (LocalException)
                {
                }
                try
                {
                    IObjectPrx.Parse("test@TestAdapter3", communicator).IcePing();
                    test(false);
                }
                catch (LocalException)
                {
                }
                registry.setAdapterDirectProxy("TestAdapter3", locator.findAdapterById("TestAdapter"));
                try
                {
                    IObjectPrx.Parse("test@TestAdapter3", communicator).IcePing();
                }
                catch (LocalException)
                {
                    test(false);
                }
                output.WriteLine("ok");

                output.Write("testing well-known object locator cache... ");
                output.Flush();
                registry.addObject(IObjectPrx.Parse("test3@TestUnknown", communicator));
                try
                {
                    IObjectPrx.Parse("test3", communicator).IcePing();
                    test(false);
                }
                catch (NotRegisteredException ex)
                {
                    test(ex.kindOfObject == "object adapter");
                    test(ex.id.Equals("TestUnknown"));
                }
                registry.addObject(IObjectPrx.Parse("test3@TestAdapter4", communicator)); // Update
                registry.setAdapterDirectProxy("TestAdapter4",
                                               IObjectPrx.Parse($"dummy:{helper.getTestEndpoint(99)}", communicator));
                try
                {
                    IObjectPrx.Parse("test3", communicator).IcePing();
                    test(false);
                }
                catch (LocalException)
                {
                }
                registry.setAdapterDirectProxy("TestAdapter4", locator.findAdapterById("TestAdapter"));
                try
                {
                    IObjectPrx.Parse("test3", communicator).IcePing();
                }
                catch (LocalException)
                {
                    test(false);
                }

                registry.setAdapterDirectProxy("TestAdapter4",
                                               IObjectPrx.Parse($"dummy:{helper.getTestEndpoint(99)}", communicator));
                try
                {
                    IObjectPrx.Parse("test3", communicator).IcePing();
                }
                catch (LocalException)
                {
                    test(false);
                }

                try
                {
                    IObjectPrx.Parse("test@TestAdapter4", communicator).Clone(locatorCacheTimeout: 0).IcePing();
                    test(false);
                }
                catch (LocalException)
                {
                }
                try
                {
                    IObjectPrx.Parse("test@TestAdapter4", communicator).IcePing();
                    test(false);
                }
                catch (LocalException)
                {
                }
                try
                {
                    IObjectPrx.Parse("test3", communicator).IcePing();
                    test(false);
                }
                catch (LocalException)
                {
                }
                registry.addObject(IObjectPrx.Parse("test3@TestAdapter", communicator));
                try
                {
                    IObjectPrx.Parse("test3", communicator).IcePing();
                }
                catch (LocalException)
                {
                    test(false);
                }

                registry.addObject(IObjectPrx.Parse("test4", communicator));
                try
                {
                    IObjectPrx.Parse("test4", communicator).IcePing();
                    test(false);
                }
                catch (NoEndpointException)
                {
                }
                output.WriteLine("ok");

                output.Write("testing locator cache background updates... ");
                output.Flush();
                {
                    InitializationData initData = new InitializationData();
                    initData.properties = communicator.Properties.Clone();
                    initData.properties.setProperty("Ice.BackgroundLocatorCacheUpdates", "1");
                    Communicator ic = helper.initialize(initData);

                    registry.setAdapterDirectProxy("TestAdapter5", locator.findAdapterById("TestAdapter"));
                    registry.addObject(IObjectPrx.Parse("test3@TestAdapter", communicator));

                    count = locator.getRequestCount();
                    IObjectPrx.Parse("test@TestAdapter5", ic).Clone(locatorCacheTimeout: 0).IcePing(); // No locator cache.
                    IObjectPrx.Parse("test3", ic).Clone(locatorCacheTimeout: 0).IcePing();             // No locator cache.
                    count += 3;
                    test(count == locator.getRequestCount());
                    registry.setAdapterDirectProxy("TestAdapter5", null);
                    registry.addObject(IObjectPrx.Parse($"test3:{helper.getTestEndpoint(99)}", communicator));
                    IObjectPrx.Parse("test@TestAdapter5", ic).Clone(locatorCacheTimeout: 10).IcePing(); // 10s timeout.
                    IObjectPrx.Parse("test3", ic).Clone(locatorCacheTimeout: 10).IcePing();             // 10s timeout.
                    test(count == locator.getRequestCount());
                    System.Threading.Thread.Sleep(1200);

                    // The following request should trigger the background
                    // updates but still use the cached endpoints and
                    // therefore succeed.
                    IObjectPrx.Parse("test@TestAdapter5", ic).Clone(locatorCacheTimeout: 1).IcePing(); // 1s timeout.
                    IObjectPrx.Parse("test3", ic).Clone(locatorCacheTimeout: 1).IcePing();             // 1s timeout.

                    try
                    {
                        while (true)
                        {
                            IObjectPrx.Parse("test@TestAdapter5", ic).Clone(locatorCacheTimeout: 1).IcePing(); // 1s timeout.
                            System.Threading.Thread.Sleep(10);
                        }
                    }
                    catch (LocalException)
                    {
                        // Expected to fail once they endpoints have been updated in the background.
                    }
                    try
                    {
                        while (true)
                        {
                            IObjectPrx.Parse("test3", ic).Clone(locatorCacheTimeout: 1).IcePing(); // 1s timeout.
                            System.Threading.Thread.Sleep(10);
                        }
                    }
                    catch (LocalException)
                    {
                        // Expected to fail once they endpoints have been updated in the background.
                    }
                    ic.destroy();
                }
                output.WriteLine("ok");

                output.Write("testing proxy from server after shutdown... ");
                output.Flush();
                hello = obj.getReplicatedHello();
                obj.shutdown();
                manager.startServer();
                hello.sayHello();
                output.WriteLine("ok");

                output.Write("testing object migration... ");
                output.Flush();
                hello = HelloPrx.Parse("hello", communicator);
                obj.migrateHello();
                hello.GetConnection().close(ConnectionClose.GracefullyWithWait);
                hello.sayHello();
                obj.migrateHello();
                hello.sayHello();
                obj.migrateHello();
                hello.sayHello();
                output.WriteLine("ok");

                output.Write("testing locator encoding resolution... ");
                output.Flush();
                hello = HelloPrx.Parse("hello", communicator);
                count = locator.getRequestCount();
                IObjectPrx.Parse("test@TestAdapter", communicator).Clone(encodingVersion: Util.Encoding_1_1).IcePing();
                test(count == locator.getRequestCount());
                IObjectPrx.Parse("test@TestAdapter10", communicator).Clone(encodingVersion: Util.Encoding_1_0).IcePing();
                test(++count == locator.getRequestCount());
                IObjectPrx.Parse("test -e 1.0@TestAdapter10-2", communicator).IcePing();
                test(++count == locator.getRequestCount());
                output.WriteLine("ok");

                output.Write("shutdown server... ");
                output.Flush();
                obj.shutdown();
                output.WriteLine("ok");

                output.Write("testing whether server is gone... ");
                output.Flush();
                try
                {
                    obj2.IcePing();
                    test(false);
                }
                catch (LocalException)
                {
                }
                try
                {
                    obj3.IcePing();
                    test(false);
                }
                catch (LocalException)
                {
                }
                try
                {
                    obj5.IcePing();
                    test(false);
                }
                catch (LocalException)
                {
                }
                output.WriteLine("ok");

                output.Write("testing indirect proxies to collocated objects... ");
                output.Flush();

                communicator.Properties.setProperty("Hello.AdapterId", Guid.NewGuid().ToString());
                ObjectAdapter adapter = communicator.createObjectAdapterWithEndpoints("Hello", "default");

                var id = new Identity(Guid.NewGuid().ToString(), "");

                adapter.Add(new HelloI(), id);
                adapter.Activate();

                // Ensure that calls on the well-known proxy is collocated.
                HelloPrx?helloPrx = HelloPrx.Parse("\"" + id.ToString(communicator.ToStringMode) + "\"", communicator);

                test(helloPrx.GetConnection() == null);

                // Ensure that calls on the indirect proxy (with adapter ID) is collocated
                helloPrx = HelloPrx.CheckedCast(adapter.CreateIndirectProxy(id));
                test(helloPrx != null && helloPrx.GetConnection() == null);

                // Ensure that calls on the direct proxy is collocated
                helloPrx = HelloPrx.CheckedCast(adapter.CreateDirectProxy(id));
                test(helloPrx != null && helloPrx.GetConnection() == null);

                output.WriteLine("ok");

                output.Write("shutdown server manager... ");
                output.Flush();
                manager.shutdown();
                output.WriteLine("ok");
            }