public static void allTests(Ice.Communicator communicator) { string @ref = "communicator:default -p 12010"; RemoteCommunicatorPrx com = RemoteCommunicatorPrxHelper.uncheckedCast(communicator.stringToProxy(@ref)); System.Random rand = new System.Random(unchecked((int)System.DateTime.Now.Ticks)); Console.Out.Write("testing binding with single endpoint... "); Console.Out.Flush(); { RemoteObjectAdapterPrx adapter = com.createObjectAdapter("Adapter", "default"); TestIntfPrx test1 = adapter.getTestIntf(); TestIntfPrx test2 = adapter.getTestIntf(); test(test1.ice_getConnection() == test2.ice_getConnection()); test1.ice_ping(); test2.ice_ping(); com.deactivateObjectAdapter(adapter); TestIntfPrx test3 = TestIntfPrxHelper.uncheckedCast(test1); test(test3.ice_getConnection() == test1.ice_getConnection()); test(test3.ice_getConnection() == test2.ice_getConnection()); try { test3.ice_ping(); test(false); } catch(Ice.ConnectionRefusedException) { } } Console.Out.WriteLine("ok"); Console.Out.Write("testing binding with multiple endpoints... "); Console.Out.Flush(); { ArrayList adapters = new ArrayList(); adapters.Add(com.createObjectAdapter("Adapter11", "default")); adapters.Add(com.createObjectAdapter("Adapter12", "default")); adapters.Add(com.createObjectAdapter("Adapter13", "default")); // // Ensure that when a connection is opened it's reused for new // proxies and that all endpoints are eventually tried. // List<string> names = new List<string>(); names.Add("Adapter11"); names.Add("Adapter12"); names.Add("Adapter13"); while(names.Count > 0) { ArrayList adpts = new ArrayList(adapters); TestIntfPrx test1 = createTestIntfPrx(adpts); shuffle(ref adpts); TestIntfPrx test2 = createTestIntfPrx(adpts); shuffle(ref adpts); TestIntfPrx test3 = createTestIntfPrx(adpts); test1.ice_ping(); test(test1.ice_getConnection() == test2.ice_getConnection()); test(test2.ice_getConnection() == test3.ice_getConnection()); names.Remove(test1.getAdapterName()); test1.ice_getConnection().close(false); } // // Ensure that the proxy correctly caches the connection (we // always send the request over the same connection.) // { foreach(RemoteObjectAdapterPrx adpt in adapters) { adpt.getTestIntf().ice_ping(); } TestIntfPrx t = createTestIntfPrx(adapters); string name = t.getAdapterName(); int nRetry = 10; int i; for(i = 0; i < nRetry && t.getAdapterName().Equals(name); i++); test(i == nRetry); foreach(RemoteObjectAdapterPrx adpt in adapters) { adpt.getTestIntf().ice_getConnection().close(false); } } // // Deactivate an adapter and ensure that we can still // establish the connection to the remaining adapters. // com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[0]); names.Add("Adapter12"); names.Add("Adapter13"); while(names.Count > 0) { ArrayList adpts = new ArrayList(adapters); TestIntfPrx test1 = createTestIntfPrx(adpts); shuffle(ref adpts); TestIntfPrx test2 = createTestIntfPrx(adpts); shuffle(ref adpts); TestIntfPrx test3 = createTestIntfPrx(adpts); test(test1.ice_getConnection() == test2.ice_getConnection()); test(test2.ice_getConnection() == test3.ice_getConnection()); names.Remove(test1.getAdapterName()); test1.ice_getConnection().close(false); } // // Deactivate an adapter and ensure that we can still // establish the connection to the remaining adapter. // com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[2]); TestIntfPrx obj = createTestIntfPrx(adapters); test(obj.getAdapterName().Equals("Adapter12")); deactivate(com, adapters); } Console.Out.WriteLine("ok"); Console.Out.Write("testing binding with multiple random endpoints... "); Console.Out.Flush(); { RemoteObjectAdapterPrx[] adapters = new RemoteObjectAdapterPrx[5]; adapters[0] = com.createObjectAdapter("AdapterRandom11", "default"); adapters[1] = com.createObjectAdapter("AdapterRandom12", "default"); adapters[2] = com.createObjectAdapter("AdapterRandom13", "default"); adapters[3] = com.createObjectAdapter("AdapterRandom14", "default"); adapters[4] = com.createObjectAdapter("AdapterRandom15", "default"); int count; if(IceInternal.AssemblyUtil.platform_ == IceInternal.AssemblyUtil.Platform.Windows) { count = 20; } else { count = 60; } int adapterCount = adapters.Length; while(--count > 0) { TestIntfPrx[] proxies; if(IceInternal.AssemblyUtil.platform_ == IceInternal.AssemblyUtil.Platform.Windows) { if(count == 10) { com.deactivateObjectAdapter(adapters[4]); --adapterCount; } proxies = new TestIntfPrx[10]; } else { if(count < 60 && count % 10 == 0) { com.deactivateObjectAdapter(adapters[count / 10 - 1]); --adapterCount; } proxies = new TestIntfPrx[40]; } int i; for(i = 0; i < proxies.Length; ++i) { RemoteObjectAdapterPrx[] adpts = new RemoteObjectAdapterPrx[rand.Next(adapters.Length)]; if(adpts.Length == 0) { adpts = new RemoteObjectAdapterPrx[1]; } for(int j = 0; j < adpts.Length; ++j) { adpts[j] = adapters[rand.Next(adapters.Length)]; } proxies[i] = createTestIntfPrx(new ArrayList(adpts)); } for(i = 0; i < proxies.Length; i++) { proxies[i].begin_getAdapterName(); } for(i = 0; i < proxies.Length; i++) { try { proxies[i].ice_ping(); } catch(Ice.LocalException) { } } ArrayList connections = new ArrayList(); for(i = 0; i < proxies.Length; i++) { if(proxies[i].ice_getCachedConnection() != null) { if(!connections.Contains(proxies[i].ice_getCachedConnection())) { connections.Add(proxies[i].ice_getCachedConnection()); } } } test(connections.Count <= adapterCount); foreach(RemoteObjectAdapterPrx a in adapters) { try { a.getTestIntf().ice_getConnection().close(false); } catch(Ice.LocalException) { // Expected if adapter is down. } } } } Console.Out.WriteLine("ok"); Console.Out.Write("testing binding with multiple endpoints and AMI... "); Console.Out.Flush(); { ArrayList adapters = new ArrayList(); adapters.Add(com.createObjectAdapter("AdapterAMI11", "default")); adapters.Add(com.createObjectAdapter("AdapterAMI12", "default")); adapters.Add(com.createObjectAdapter("AdapterAMI13", "default")); // // Ensure that when a connection is opened it's reused for new // proxies and that all endpoints are eventually tried. // List<string> names = new List<string>(); names.Add("AdapterAMI11"); names.Add("AdapterAMI12"); names.Add("AdapterAMI13"); while(names.Count > 0) { ArrayList adpts = new ArrayList(adapters); TestIntfPrx test1 = createTestIntfPrx(adpts); shuffle(ref adpts); TestIntfPrx test2 = createTestIntfPrx(adpts); shuffle(ref adpts); TestIntfPrx test3 = createTestIntfPrx(adpts); test1.ice_ping(); test(test1.ice_getConnection() == test2.ice_getConnection()); test(test2.ice_getConnection() == test3.ice_getConnection()); names.Remove(getAdapterNameWithAMI(test1)); test1.ice_getConnection().close(false); } // // Ensure that the proxy correctly caches the connection (we // always send the request over the same connection.) // { foreach(RemoteObjectAdapterPrx adpt in adapters) { adpt.getTestIntf().ice_ping(); } TestIntfPrx t = createTestIntfPrx(adapters); string name = getAdapterNameWithAMI(t); int nRetry = 10; int i; for(i = 0; i < nRetry && getAdapterNameWithAMI(t).Equals(name); i++); test(i == nRetry); foreach(RemoteObjectAdapterPrx adpt in adapters) { adpt.getTestIntf().ice_getConnection().close(false); } } // // Deactivate an adapter and ensure that we can still // establish the connection to the remaining adapters. // com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[0]); names.Add("AdapterAMI12"); names.Add("AdapterAMI13"); while(names.Count > 0) { ArrayList adpts = new ArrayList(adapters); TestIntfPrx test1 = createTestIntfPrx(adpts); shuffle(ref adpts); TestIntfPrx test2 = createTestIntfPrx(adpts); shuffle(ref adpts); TestIntfPrx test3 = createTestIntfPrx(adpts); test(test1.ice_getConnection() == test2.ice_getConnection()); test(test2.ice_getConnection() == test3.ice_getConnection()); names.Remove(getAdapterNameWithAMI(test1)); test1.ice_getConnection().close(false); } // // Deactivate an adapter and ensure that we can still // establish the connection to the remaining adapter. // com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[2]); TestIntfPrx obj = createTestIntfPrx(adapters); test(getAdapterNameWithAMI(obj).Equals("AdapterAMI12")); deactivate(com, adapters); } Console.Out.WriteLine("ok"); Console.Out.Write("testing random endpoint selection... "); Console.Out.Flush(); { ArrayList adapters = new ArrayList(); adapters.Add(com.createObjectAdapter("Adapter21", "default")); adapters.Add(com.createObjectAdapter("Adapter22", "default")); adapters.Add(com.createObjectAdapter("Adapter23", "default")); TestIntfPrx obj = createTestIntfPrx(adapters); test(obj.ice_getEndpointSelection() == Ice.EndpointSelectionType.Random); List<string> names = new List<string>(); names.Add("Adapter21"); names.Add("Adapter22"); names.Add("Adapter23"); while(names.Count > 0) { names.Remove(obj.getAdapterName()); obj.ice_getConnection().close(false); } obj = TestIntfPrxHelper.uncheckedCast(obj.ice_endpointSelection(Ice.EndpointSelectionType.Random)); test(obj.ice_getEndpointSelection() == Ice.EndpointSelectionType.Random); names.Add("Adapter21"); names.Add("Adapter22"); names.Add("Adapter23"); while(names.Count > 0) { names.Remove(obj.getAdapterName()); obj.ice_getConnection().close(false); } deactivate(com, adapters); } Console.Out.WriteLine("ok"); Console.Out.Write("testing ordered endpoint selection... "); Console.Out.Flush(); { ArrayList adapters = new ArrayList(); adapters.Add(com.createObjectAdapter("Adapter31", "default")); adapters.Add(com.createObjectAdapter("Adapter32", "default")); adapters.Add(com.createObjectAdapter("Adapter33", "default")); TestIntfPrx obj = createTestIntfPrx(adapters); obj = TestIntfPrxHelper.uncheckedCast(obj.ice_endpointSelection(Ice.EndpointSelectionType.Ordered)); test(obj.ice_getEndpointSelection() == Ice.EndpointSelectionType.Ordered); int nRetry = 3; int i; // // Ensure that endpoints are tried in order by deactiving the adapters // one after the other. // for(i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter31"); i++); test(i == nRetry); com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[0]); for(i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter32"); i++); test(i == nRetry); com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[1]); for(i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter33"); i++); test(i == nRetry); com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[2]); try { obj.getAdapterName(); } catch(Ice.ConnectionRefusedException) { } Ice.Endpoint[] endpoints = obj.ice_getEndpoints(); adapters.Clear(); // // Now, re-activate the adapters with the same endpoints in the opposite // order. // adapters.Add(com.createObjectAdapter("Adapter36", endpoints[2].ToString())); for(i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter36"); i++); test(i == nRetry); obj.ice_getConnection().close(false); adapters.Add(com.createObjectAdapter("Adapter35", endpoints[1].ToString())); for(i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter35"); i++); test(i == nRetry); obj.ice_getConnection().close(false); adapters.Add(com.createObjectAdapter("Adapter34", endpoints[0].ToString())); for(i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter34"); i++); test(i == nRetry); deactivate(com, adapters); } Console.Out.WriteLine("ok"); Console.Out.Write("testing per request binding with single endpoint... "); Console.Out.Flush(); { RemoteObjectAdapterPrx adapter = com.createObjectAdapter("Adapter41", "default"); TestIntfPrx test1 = TestIntfPrxHelper.uncheckedCast(adapter.getTestIntf().ice_connectionCached(false)); TestIntfPrx test2 = TestIntfPrxHelper.uncheckedCast(adapter.getTestIntf().ice_connectionCached(false)); test(!test1.ice_isConnectionCached()); test(!test2.ice_isConnectionCached()); test(test1.ice_getConnection() == test2.ice_getConnection()); test1.ice_ping(); com.deactivateObjectAdapter(adapter); TestIntfPrx test3 = TestIntfPrxHelper.uncheckedCast(test1); try { test(test3.ice_getConnection() == test1.ice_getConnection()); test(false); } catch(Ice.ConnectionRefusedException) { } } Console.Out.WriteLine("ok"); Console.Out.Write("testing per request binding with multiple endpoints... "); Console.Out.Flush(); { ArrayList adapters = new ArrayList(); adapters.Add(com.createObjectAdapter("Adapter51", "default")); adapters.Add(com.createObjectAdapter("Adapter52", "default")); adapters.Add(com.createObjectAdapter("Adapter53", "default")); TestIntfPrx obj = TestIntfPrxHelper.uncheckedCast(createTestIntfPrx(adapters).ice_connectionCached(false)); test(!obj.ice_isConnectionCached()); List<string> names = new List<string>(); names.Add("Adapter51"); names.Add("Adapter52"); names.Add("Adapter53"); while(names.Count > 0) { names.Remove(obj.getAdapterName()); } com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[0]); names.Add("Adapter52"); names.Add("Adapter53"); while(names.Count > 0) { names.Remove(obj.getAdapterName()); } com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[2]); test(obj.getAdapterName().Equals("Adapter52")); deactivate(com, adapters); } Console.Out.WriteLine("ok"); Console.Out.Write("testing per request binding with multiple endpoints and AMI... "); Console.Out.Flush(); { ArrayList adapters = new ArrayList(); adapters.Add(com.createObjectAdapter("AdapterAMI51", "default")); adapters.Add(com.createObjectAdapter("AdapterAMI52", "default")); adapters.Add(com.createObjectAdapter("AdapterAMI53", "default")); TestIntfPrx obj = TestIntfPrxHelper.uncheckedCast(createTestIntfPrx(adapters).ice_connectionCached(false)); test(!obj.ice_isConnectionCached()); List<string> names = new List<string>(); names.Add("AdapterAMI51"); names.Add("AdapterAMI52"); names.Add("AdapterAMI53"); while(names.Count > 0) { names.Remove(getAdapterNameWithAMI(obj)); } com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[0]); names.Add("AdapterAMI52"); names.Add("AdapterAMI53"); while(names.Count > 0) { names.Remove(getAdapterNameWithAMI(obj)); } com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[2]); test(getAdapterNameWithAMI(obj).Equals("AdapterAMI52")); deactivate(com, adapters); } Console.Out.WriteLine("ok"); Console.Out.Write("testing per request binding and ordered endpoint selection... "); Console.Out.Flush(); { ArrayList adapters = new ArrayList(); adapters.Add(com.createObjectAdapter("Adapter61", "default")); adapters.Add(com.createObjectAdapter("Adapter62", "default")); adapters.Add(com.createObjectAdapter("Adapter63", "default")); TestIntfPrx obj = createTestIntfPrx(adapters); obj = TestIntfPrxHelper.uncheckedCast(obj.ice_endpointSelection(Ice.EndpointSelectionType.Ordered)); test(obj.ice_getEndpointSelection() == Ice.EndpointSelectionType.Ordered); obj = TestIntfPrxHelper.uncheckedCast(obj.ice_connectionCached(false)); test(!obj.ice_isConnectionCached()); int nRetry = 3; int i; // // Ensure that endpoints are tried in order by deactiving the adapters // one after the other. // for(i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter61"); i++); test(i == nRetry); com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[0]); for(i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter62"); i++); test(i == nRetry); com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[1]); for(i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter63"); i++); test(i == nRetry); com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[2]); try { obj.getAdapterName(); } catch(Ice.ConnectionRefusedException) { } Ice.Endpoint[] endpoints = obj.ice_getEndpoints(); adapters.Clear(); // // Now, re-activate the adapters with the same endpoints in the opposite // order. // adapters.Add(com.createObjectAdapter("Adapter66", endpoints[2].ToString())); for(i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter66"); i++); test(i == nRetry); adapters.Add(com.createObjectAdapter("Adapter65", endpoints[1].ToString())); for(i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter65"); i++); test(i == nRetry); adapters.Add(com.createObjectAdapter("Adapter64", endpoints[0].ToString())); for(i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter64"); i++); test(i == nRetry); deactivate(com, adapters); } Console.Out.WriteLine("ok"); Console.Out.Write("testing per request binding and ordered endpoint selection and AMI... "); Console.Out.Flush(); { ArrayList adapters = new ArrayList(); adapters.Add(com.createObjectAdapter("AdapterAMI61", "default")); adapters.Add(com.createObjectAdapter("AdapterAMI62", "default")); adapters.Add(com.createObjectAdapter("AdapterAMI63", "default")); TestIntfPrx obj = createTestIntfPrx(adapters); obj = TestIntfPrxHelper.uncheckedCast(obj.ice_endpointSelection(Ice.EndpointSelectionType.Ordered)); test(obj.ice_getEndpointSelection() == Ice.EndpointSelectionType.Ordered); obj = TestIntfPrxHelper.uncheckedCast(obj.ice_connectionCached(false)); test(!obj.ice_isConnectionCached()); int nRetry = 3; int i; // // Ensure that endpoints are tried in order by deactiving the adapters // one after the other. // for(i = 0; i < nRetry && getAdapterNameWithAMI(obj).Equals("AdapterAMI61"); i++); test(i == nRetry); com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[0]); for(i = 0; i < nRetry && getAdapterNameWithAMI(obj).Equals("AdapterAMI62"); i++); test(i == nRetry); com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[1]); for(i = 0; i < nRetry && getAdapterNameWithAMI(obj).Equals("AdapterAMI63"); i++); test(i == nRetry); com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[2]); try { obj.getAdapterName(); } catch(Ice.ConnectionRefusedException) { } Ice.Endpoint[] endpoints = obj.ice_getEndpoints(); adapters.Clear(); // // Now, re-activate the adapters with the same endpoints in the opposite // order. // adapters.Add(com.createObjectAdapter("AdapterAMI66", endpoints[2].ToString())); for(i = 0; i < nRetry && getAdapterNameWithAMI(obj).Equals("AdapterAMI66"); i++); test(i == nRetry); adapters.Add(com.createObjectAdapter("AdapterAMI65", endpoints[1].ToString())); for(i = 0; i < nRetry && getAdapterNameWithAMI(obj).Equals("AdapterAMI65"); i++); test(i == nRetry); adapters.Add(com.createObjectAdapter("AdapterAMI64", endpoints[0].ToString())); for(i = 0; i < nRetry && getAdapterNameWithAMI(obj).Equals("AdapterAMI64"); i++); test(i == nRetry); deactivate(com, adapters); } Console.Out.WriteLine("ok"); Console.Out.Write("testing endpoint mode filtering... "); Console.Out.Flush(); { ArrayList adapters = new ArrayList(); adapters.Add(com.createObjectAdapter("Adapter71", "default")); adapters.Add(com.createObjectAdapter("Adapter72", "udp")); TestIntfPrx obj = createTestIntfPrx(adapters); test(obj.getAdapterName().Equals("Adapter71")); TestIntfPrx testUDP = TestIntfPrxHelper.uncheckedCast(obj.ice_datagram()); test(obj.ice_getConnection() != testUDP.ice_getConnection()); try { testUDP.getAdapterName(); } catch(Ice.TwowayOnlyException) { } } Console.Out.WriteLine("ok"); if(communicator.getProperties().getProperty("Ice.Plugin.IceSSL").Length > 0) { Console.Out.Write("testing unsecure vs. secure endpoints... "); Console.Out.Flush(); { ArrayList adapters = new ArrayList(); adapters.Add(com.createObjectAdapter("Adapter81", "ssl")); adapters.Add(com.createObjectAdapter("Adapter82", "tcp")); TestIntfPrx obj = createTestIntfPrx(adapters); int i; for(i = 0; i < 5; i++) { test(obj.getAdapterName().Equals("Adapter82")); obj.ice_getConnection().close(false); } TestIntfPrx testSecure = TestIntfPrxHelper.uncheckedCast(obj.ice_secure(true)); test(testSecure.ice_isSecure()); testSecure = TestIntfPrxHelper.uncheckedCast(obj.ice_secure(false)); test(!testSecure.ice_isSecure()); testSecure = TestIntfPrxHelper.uncheckedCast(obj.ice_secure(true)); test(testSecure.ice_isSecure()); test(obj.ice_getConnection() != testSecure.ice_getConnection()); com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[1]); for(i = 0; i < 5; i++) { test(obj.getAdapterName().Equals("Adapter81")); obj.ice_getConnection().close(false); } com.createObjectAdapter("Adapter83", (obj.ice_getEndpoints()[1]).ToString()); // Reactive tcp OA. for(i = 0; i < 5; i++) { test(obj.getAdapterName().Equals("Adapter83")); obj.ice_getConnection().close(false); } com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[0]); try { testSecure.ice_ping(); test(false); } catch(Ice.ConnectionRefusedException) { } deactivate(com, adapters); } Console.Out.WriteLine("ok"); } com.shutdown(); }
public static void allTests(Ice.Communicator communicator, int num) { List<ControllerPrx> proxies = new List<ControllerPrx>(); List<ControllerPrx> indirectProxies = new List<ControllerPrx>(); for(int i = 0; i < num; ++i) { string id = "controller" + i; proxies.Add(ControllerPrxHelper.uncheckedCast(communicator.stringToProxy(id))); indirectProxies.Add(ControllerPrxHelper.uncheckedCast(communicator.stringToProxy(id + "@control" + i))); } Console.Out.Write("testing indirect proxies... "); Console.Out.Flush(); { foreach(ControllerPrx prx in indirectProxies) { prx.ice_ping(); } } Console.Out.WriteLine("ok"); Console.Out.Write("testing well-known proxies... "); Console.Out.Flush(); { foreach(ControllerPrx prx in proxies) { prx.ice_ping(); } } Console.Out.WriteLine("ok"); Console.Out.Write("testing object adapter registration... "); Console.Out.Flush(); { try { communicator.stringToProxy("object @ oa1").ice_ping(); } catch(Ice.NoEndpointException) { } proxies[0].activateObjectAdapter("oa", "oa1", ""); try { communicator.stringToProxy("object @ oa1").ice_ping(); } catch(Ice.ObjectNotExistException) { } proxies[0].deactivateObjectAdapter("oa"); try { communicator.stringToProxy("object @ oa1").ice_ping(); } catch(Ice.NoEndpointException) { } } Console.Out.WriteLine("ok"); Console.Out.Write("testing object adapter migration..."); Console.Out.Flush(); { proxies[0].activateObjectAdapter("oa", "oa1", ""); proxies[0].addObject("oa", "object"); communicator.stringToProxy("object @ oa1").ice_ping(); proxies[0].removeObject("oa", "object"); proxies[0].deactivateObjectAdapter("oa"); proxies[1].activateObjectAdapter("oa", "oa1", ""); proxies[1].addObject("oa", "object"); communicator.stringToProxy("object @ oa1").ice_ping(); proxies[1].removeObject("oa", "object"); proxies[1].deactivateObjectAdapter("oa"); } Console.Out.WriteLine("ok"); Console.Out.Write("testing object migration..."); Console.Out.Flush(); { proxies[0].activateObjectAdapter("oa", "oa1", ""); proxies[1].activateObjectAdapter("oa", "oa2", ""); proxies[0].addObject("oa", "object"); communicator.stringToProxy("object @ oa1").ice_ping(); communicator.stringToProxy("object").ice_ping(); proxies[0].removeObject("oa", "object"); proxies[1].addObject("oa", "object"); communicator.stringToProxy("object @ oa2").ice_ping(); communicator.stringToProxy("object").ice_ping(); proxies[1].removeObject("oa", "object"); try { communicator.stringToProxy("object @ oa1").ice_ping(); } catch(Ice.ObjectNotExistException) { } try { communicator.stringToProxy("object @ oa2").ice_ping(); } catch(Ice.ObjectNotExistException) { } proxies[0].deactivateObjectAdapter("oa"); proxies[1].deactivateObjectAdapter("oa"); } Console.Out.WriteLine("ok"); Console.Out.Write("testing replica groups..."); Console.Out.Flush(); { proxies[0].activateObjectAdapter("oa", "oa1", "rg"); proxies[1].activateObjectAdapter("oa", "oa2", "rg"); proxies[2].activateObjectAdapter("oa", "oa3", "rg"); proxies[0].addObject("oa", "object"); proxies[1].addObject("oa", "object"); proxies[2].addObject("oa", "object"); communicator.stringToProxy("object @ oa1").ice_ping(); communicator.stringToProxy("object @ oa2").ice_ping(); communicator.stringToProxy("object @ oa3").ice_ping(); communicator.stringToProxy("object @ rg").ice_ping(); List<string> adapterIds = new List<string>(); adapterIds.Add("oa1"); adapterIds.Add("oa2"); adapterIds.Add("oa3"); TestIntfPrx intf = TestIntfPrxHelper.uncheckedCast(communicator.stringToProxy("object")); intf = (TestIntfPrx)intf.ice_connectionCached(false).ice_locatorCacheTimeout(0); while(adapterIds.Count > 0) { adapterIds.Remove(intf.getAdapterId()); } while(true) { adapterIds.Add("oa1"); adapterIds.Add("oa2"); adapterIds.Add("oa3"); intf = TestIntfPrxHelper.uncheckedCast( communicator.stringToProxy("object @ rg").ice_connectionCached(false)); int nRetry = 100; while(adapterIds.Count > 0 && --nRetry > 0) { adapterIds.Remove(intf.getAdapterId()); } if(nRetry > 0) { break; } // The previous locator lookup probably didn't return all the replicas... try again. communicator.stringToProxy("object @ rg").ice_locatorCacheTimeout(0).ice_ping(); } proxies[0].deactivateObjectAdapter("oa"); proxies[1].deactivateObjectAdapter("oa"); test(TestIntfPrxHelper.uncheckedCast( communicator.stringToProxy("object @ rg")).getAdapterId().Equals("oa3")); proxies[2].deactivateObjectAdapter("oa"); proxies[0].activateObjectAdapter("oa", "oa1", "rg"); proxies[0].addObject("oa", "object"); test(TestIntfPrxHelper.uncheckedCast( communicator.stringToProxy("object @ rg")).getAdapterId().Equals("oa1")); proxies[0].deactivateObjectAdapter("oa"); } Console.Out.WriteLine("ok"); Console.Out.Write("shutting down... "); Console.Out.Flush(); foreach(ControllerPrx prx in proxies) { prx.shutdown(); } Console.Out.WriteLine("ok"); }