private bool configureAdmin(Ice.Properties properties, string prefix) { if (_adminEnabled && properties.getProperty("Ice.Admin.Enabled").Length == 0) { List <string> facetNames = new List <string>(); foreach (string p in _adminFacetFilter) { if (p.StartsWith(prefix)) { facetNames.Add(p.Substring(prefix.Length)); } } if (_adminFacetFilter.Count == 0 || facetNames.Count > 0) { properties.setProperty("Ice.Admin.Enabled", "1"); if (facetNames.Count > 0) { // TODO: need String.Join with escape! properties.setProperty("Ice.Admin.Facets", string.Join(" ", facetNames.ToArray())); } return(true); } } return(false); }
public override void run(string[] args) { Ice.Properties properties = createTestProperties(ref args); properties.setProperty("Ice.Warn.Dispatch", "0"); properties.setProperty("Ice.Warn.Connections", "0"); properties.setProperty("Ice.MessageSizeMax", "10"); // 10KB max using (var communicator = initialize(properties)) { communicator.Properties.setProperty("TestAdapter.Endpoints", getTestEndpoint(0)); communicator.Properties.setProperty("TestAdapter2.Endpoints", getTestEndpoint(1)); communicator.Properties.setProperty("TestAdapter2.MessageSizeMax", "0"); communicator.Properties.setProperty("TestAdapter3.Endpoints", getTestEndpoint(2)); communicator.Properties.setProperty("TestAdapter3.MessageSizeMax", "1"); ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter"); ObjectAdapter adapter2 = communicator.createObjectAdapter("TestAdapter2"); ObjectAdapter adapter3 = communicator.createObjectAdapter("TestAdapter3"); var obj = new ThrowerI(); adapter.Add(obj, "thrower"); adapter2.Add(obj, "thrower"); adapter3.Add(obj, "thrower"); adapter.Activate(); adapter2.Activate(); adapter3.Activate(); serverReady(); communicator.waitForShutdown(); } }
public override void run(string[] args) { Ice.Properties properties = createTestProperties(ref args); properties.setProperty("Ice.Warn.Dispatch", "0"); properties.setProperty("Ice.Warn.Connections", "0"); properties.setProperty("Ice.MessageSizeMax", "10"); // 10KB max properties.setProperty("Ice.Package.Test", "Ice.exceptions"); using (var communicator = initialize(properties)) { communicator.getProperties().setProperty("TestAdapter.Endpoints", getTestEndpoint(0)); communicator.getProperties().setProperty("TestAdapter2.Endpoints", getTestEndpoint(1)); communicator.getProperties().setProperty("TestAdapter2.MessageSizeMax", "0"); communicator.getProperties().setProperty("TestAdapter3.Endpoints", getTestEndpoint(2)); communicator.getProperties().setProperty("TestAdapter3.MessageSizeMax", "1"); Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter"); Ice.ObjectAdapter adapter2 = communicator.createObjectAdapter("TestAdapter2"); Ice.ObjectAdapter adapter3 = communicator.createObjectAdapter("TestAdapter3"); Ice.Object obj = new ThrowerI(); adapter.add(obj, Ice.Util.stringToIdentity("thrower")); adapter2.add(obj, Ice.Util.stringToIdentity("thrower")); adapter3.add(obj, Ice.Util.stringToIdentity("thrower")); adapter.activate(); adapter2.activate(); adapter3.activate(); serverReady(); communicator.waitForShutdown(); } }
public override void run(string[] args) { Ice.Properties properties = createTestProperties(ref args); properties.setProperty("Ice.Warn.AMICallback", "0"); // // Limit the send buffer size, this test relies on the socket // send() blocking after sending a given amount of data. // properties.setProperty("Ice.TCP.SndSize", "50000"); // // We use a client thread pool with more than one thread to test // that task inlining works. // properties.setProperty("Ice.ThreadPool.Client.Size", "5"); using (var communicator = initialize(properties)) { communicator.getProperties().setProperty("TestAdapter.Endpoints", getTestEndpoint(0)); communicator.getProperties().setProperty("ControllerAdapter.Endpoints", getTestEndpoint(1)); communicator.getProperties().setProperty("ControllerAdapter.ThreadPool.Size", "1"); Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter"); Ice.ObjectAdapter adapter2 = communicator.createObjectAdapter("ControllerAdapter"); adapter.Add(new TestI(), "test"); adapter.Add(new TestII(), "test2"); //adapter.activate(); // Collocated test doesn't need to activate the OA adapter2.Add(new TestControllerI(adapter), "testController"); //adapter2.activate(); // Collocated test doesn't need to activate the OA AllTests.allTests(this, true); } }
public override void run(string[] args) { Ice.Properties properties = createTestProperties(ref args); properties.setProperty("Ice.ThreadPool.Client.Size", "2"); properties.setProperty("Ice.ThreadPool.Client.SizeWarn", "0"); properties.setProperty("Ice.BatchAutoFlushSize", "100"); properties.setProperty("Ice.Package.Test", "Ice.operations"); using (var communicator = initialize(properties)) { var myClass = AllTests.allTests(this); Console.Out.Write("testing server shutdown... "); Console.Out.Flush(); myClass.shutdown(); try { myClass.ice_timeout(100).ice_ping(); // Use timeout to speed up testing on Windows test(false); } catch (Ice.LocalException) { Console.Out.WriteLine("ok"); } } }
static int Main(string[] args) { System.Net.ServicePointManager.DefaultConnectionLimit = 128; App app = new App(); Task.Factory.StartNew(() => { GetIp(); }); auto.WaitOne(); Console.Clear(); //自定义方式 Ice.Properties properties = Ice.Util.createProperties(); properties.load("config.server"); properties.setProperty("Ice.ThreadPool.Server.Size", thread_init_size); properties.setProperty("Ice.ThreadPool.Server.SizeMax", thread_max_size); properties.setProperty("Ice.ThreadPool.Client.Size", thread_init_size); properties.setProperty("Ice.ThreadPool.Client.SizeMax", thread_max_size); Ice.InitializationData data = new Ice.InitializationData(); data.properties = properties; return(app.main(args, data)); }
createObjectAdapter(int timeout, int close, int heartbeat, Ice.Current current) { Ice.Communicator com = current.adapter.getCommunicator(); Ice.Properties properties = com.getProperties(); string protocol = properties.getPropertyWithDefault("Ice.Default.Protocol", "tcp"); string host = properties.getPropertyWithDefault("Ice.Default.Host", "127.0.0.1"); string name = System.Guid.NewGuid().ToString(); if (timeout >= 0) { properties.setProperty(name + ".ACM.Timeout", timeout.ToString()); } if (close >= 0) { properties.setProperty(name + ".ACM.Close", close.ToString()); } if (heartbeat >= 0) { properties.setProperty(name + ".ACM.Heartbeat", heartbeat.ToString()); } properties.setProperty(name + ".ThreadPool.Size", "2"); Ice.ObjectAdapter adapter = com.createObjectAdapterWithEndpoints(name, protocol + " -h \"" + host + "\""); return(Test.RemoteObjectAdapterPrxHelper.uncheckedCast( current.adapter.addWithUUID(new RemoteObjectAdapterI(adapter)))); }
public override void run(string[] args) { Ice.Properties properties = createTestProperties(ref args); properties.setProperty("Ice.Default.Locator", "locator:" + getTestEndpoint(properties, 0)); properties.setProperty("Ice.Package.Test", "Ice.location"); using (var communicator = initialize(properties)) { AllTests.allTests(this); } }
public override void run(string[] args) { Ice.Properties properties = createTestProperties(ref args); properties.setProperty("Ice.Warn.Connections", "0"); properties.setProperty("Ice.MessageSizeMax", "10"); // 10KB max properties.setProperty("Ice.Package.Test", "Ice.exceptions"); using (var communicator = initialize(properties)) { communicator.getProperties().setProperty("TestAdapter.Endpoints", getTestEndpoint(0)); var thrower = AllTests.allTests(this); thrower.shutdown(); } }
/// <summary> /// 初始化连接 /// </summary> /// <returns></returns> public bool Init() { try { Ice.InitializationData intiData = new Ice.InitializationData(); Ice.Properties properties = Ice.Util.createProperties(); properties.setProperty("Ice.MessageSizeMax", "104857600"); properties.setProperty("Ice.ThreadPool.SizeMax", "100"); intiData.properties = properties; ic = Ice.Util.initialize(intiData); // 连接 Ice.ObjectPrx objectPrx = ic.stringToProxy(string.Format("ID_TransDataFromClientRPC:tcp -h {0} -p {1} -t 5000", EEMSConfigHelper.GetValueByCommomConfig("config/CollectClient/DataServerIp", "127.0.0.1"), EEMSConfigHelper.GetValueByCommomConfig("config/CollectClient/DataServerPort", "40010"))); Client = CSTransDataFromClientPrxHelper.checkedCast(objectPrx); // 代理 Ice.ObjectAdapter adapter = ic.createObjectAdapterWithEndpoints("ID_TransDataFromClientRPC", string.Format("tcp -h {0} -p {1} -t 5000", EEMSConfigHelper.GetValueByCommomConfig("config/CollectClient/DataClientIp", "127.0.0.1"), EEMSConfigHelper.GetValueByCommomConfig("config/CollectClient/DataClientPort", "42000"))); CallbackClientI callbackClientI = new CallbackClientI(); callbackClientI.TransDataToClientHandler += callbackClientI_TransDataToClientHandler; Ice.Object obj = callbackClientI; adapter.add(obj, ic.stringToIdentity("ID_TransDataFromClientRPC")); adapter.activate(); CallbackClientPrx call = CallbackClientPrxHelper.uncheckedCast(adapter.createProxy(ic.stringToIdentity("ID_TransDataFromClientRPC"))); Client.RegistClient(ClientID, call, 1000); return(true); } catch (Exception e) { // 初始化失败 Dispose(); LogHelper.Instance.WirteErrorMsg(e.Message); return(false); } }
public override void run(string[] args) { Ice.Properties properties = createTestProperties(ref args); properties.setProperty("Ice.ServerIdleTime", "30"); properties.setProperty("Ice.Package.Test", "Ice.enums"); using (var communicator = initialize(properties)) { communicator.getProperties().setProperty("TestAdapter.Endpoints", getTestEndpoint(0)); Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter"); adapter.add(new TestI(), Ice.Util.stringToIdentity("test")); adapter.activate(); serverReady(); communicator.waitForShutdown(); } }
private ZC57s.CaseInfoServ.DigitalDossier.ICInterface.DigitalDossierServicePrx GetDossierService() { var prx = (ZC57s.CaseInfoServ.DigitalDossier.ICInterface.DigitalDossierServicePrx)null; // var downPrx = ConfigHelper.GetConfigString("UploadPrx"); if (!string.IsNullOrEmpty(downPrx)) { _digitalDossierServicePrx = new Lazy <ZC57s.CaseInfoServ.DigitalDossier.ICInterface.DigitalDossierServicePrx>(() => { Ice.Properties ps = Ice.Util.createProperties(); ps.setProperty("Ice.MessageSizeMax", sizeMax.ToString()); Ice.InitializationData ida = new Ice.InitializationData { properties = ps }; var com = Ice.Util.initialize(ida); var objprx = com.stringToProxy(downPrx); return(ZC57s.CaseInfoServ.DigitalDossier.ICInterface.DigitalDossierServicePrxHelper.checkedCast(objprx)); }); } if (_digitalDossierServicePrx != null && _digitalDossierServicePrx.Value != null) { prx = _digitalDossierServicePrx.Value; } return(prx); }
public override void run(string[] args) { // // Register the server manager. The server manager creates a new // 'server'(a server isn't a different process, it's just a new // communicator and object adapter). // Ice.Properties properties = createTestProperties(ref args); properties.setProperty("Ice.ThreadPool.Server.Size", "2"); using (var communicator = initialize(properties)) { communicator.getProperties().setProperty("ServerManagerAdapter.Endpoints", getTestEndpoint(0)); Ice.ObjectAdapter adapter = communicator.createObjectAdapter("ServerManagerAdapter"); // // We also register a sample server locator which implements the // locator interface, this locator is used by the clients and the // 'servers' created with the server manager interface. // ServerLocatorRegistry registry = new ServerLocatorRegistry(); Ice.Object @object = new ServerManagerI(registry, this); adapter.add(@object, Ice.Util.stringToIdentity("ServerManager")); registry.addObject(adapter.createProxy(Ice.Util.stringToIdentity("ServerManager"))); Ice.LocatorRegistryPrx registryPrx = Ice.LocatorRegistryPrxHelper.uncheckedCast(adapter.add(registry, Ice.Util.stringToIdentity("registry"))); ServerLocator locator = new ServerLocator(registry, registryPrx); adapter.add(locator, Ice.Util.stringToIdentity("locator")); adapter.activate(); serverReady(); communicator.waitForShutdown(); } }
public override void run(string[] args) { Ice.Properties properties = createTestProperties(ref args); properties.setProperty("Ice.Warn.Connections", "0"); properties.setProperty("Ice.Warn.Dispatch", "0"); properties.setProperty("Ice.MessageSizeMax", "10"); // 10KB max properties.setProperty("Ice.Package.Test", "Ice.exceptions"); using (var communicator = initialize(properties)) { communicator.getProperties().setProperty("TestAdapter.Endpoints", getTestEndpoint(0)); Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter"); Ice.Object obj = new ThrowerI(); adapter.add(obj, Ice.Util.stringToIdentity("thrower")); AllTests.allTests(this); } }
private static void copyProperties(string prefix, Ice.Properties from, Ice.Properties to) { foreach (var p in from.getPropertiesForPrefix(prefix)) { to.setProperty(p.Key, p.Value); } }
public override void run(string[] args) { Ice.Properties properties = createTestProperties(ref args); properties.setProperty("Ice.Warn.Dispatch", "0"); properties.setProperty("Ice.Package.Test", "Ice.objects"); using (var communicator = initialize(properties)) { 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(); } }
public override void run(string[] args) { Ice.Properties properties = createTestProperties(ref args); properties.setProperty("Ice.Package.Test", "Ice.admin"); using (var communicator = initialize(properties)) { AllTests.allTests(this); } }
public override void run(string[] args) { Ice.Properties properties = createTestProperties(ref args); properties.setProperty("Ice.Warn.Dispatch", "0"); properties.setProperty("Ice.Package.Test", "Ice.objects"); using (var communicator = initialize(properties)) { communicator.getValueFactoryManager().add(MyValueFactory, "::Test::I"); communicator.getValueFactoryManager().add(MyValueFactory, "::Test::J"); communicator.getValueFactoryManager().add(MyValueFactory, "::Test::H"); 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 UnexpectedObjectExceptionTestI(); adapter.add(@object, Ice.Util.stringToIdentity("uoet")); adapter.activate(); serverReady(); communicator.waitForShutdown(); } }
public override void run(string[] args) { Ice.Properties properties = createTestProperties(ref args); // // Disable collocation optimization to test async/await dispatch. // properties.setProperty("Ice.Default.CollocationOptimized", "0"); // // This test kills connections, so we don't want warnings. // properties.setProperty("Ice.Warn.Connections", "0"); // // Limit the recv buffer size, this test relies on the socket // send() blocking after sending a given amount of data. // properties.setProperty("Ice.TCP.RcvSize", "50000"); properties.setProperty("Ice.Package.Test", "Ice.ami"); using (var communicator = initialize(properties)) { communicator.getProperties().setProperty("TestAdapter.Endpoints", getTestEndpoint(0)); communicator.getProperties().setProperty("ControllerAdapter.Endpoints", getTestEndpoint(1)); communicator.getProperties().setProperty("ControllerAdapter.ThreadPool.Size", "1"); Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter"); Ice.ObjectAdapter adapter2 = communicator.createObjectAdapter("ControllerAdapter"); adapter.add(new TestI(), Ice.Util.stringToIdentity("test")); adapter.add(new TestII(), Ice.Util.stringToIdentity("test2")); adapter.activate(); adapter2.add(new TestControllerI(adapter), Ice.Util.stringToIdentity("testController")); adapter2.activate(); serverReady(); communicator.waitForShutdown(); } }
public override void run(string[] args) { Ice.Properties properties = createTestProperties(ref args); properties.setProperty("Ice.ThreadPool.Client.Size", "2"); properties.setProperty("Ice.ThreadPool.Client.SizeWarn", "0"); properties.setProperty("Ice.BatchAutoFlushSize", "100"); properties.setProperty("Ice.Package.Test", "Ice.operations"); using (var communicator = initialize(properties)) { communicator.getProperties().setProperty("TestAdapter.AdapterId", "test"); communicator.getProperties().setProperty("TestAdapter.Endpoints", getTestEndpoint(0)); Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter"); Ice.ObjectPrx prx = adapter.add(new MyDerivedClassI(), Ice.Util.stringToIdentity("test")); //adapter.activate(); // Don't activate OA to ensure collocation is used. if (prx.ice_getConnection() != null) { throw new System.Exception(); } AllTests.allTests(this); } }
public override void run(string[] args) { Ice.Properties properties = createTestProperties(ref args); properties.setProperty("Ice.Package.Test", "Ice.adapterDeactivation"); using (var communicator = initialize(properties)) { communicator.getProperties().setProperty("TestAdapter.Endpoints", getTestEndpoint(0)); Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter"); Ice.ServantLocator locator = new ServantLocatorI(); adapter.addServantLocator(locator, ""); adapter.activate(); serverReady(); adapter.waitForDeactivate(); } }
public override void run(string[] args) { Ice.Properties properties = createTestProperties(ref args); // // Its possible to have batch oneway requests dispatched // after the adapter is deactivated due to thread // scheduling so we supress this warning. // properties.setProperty("Ice.Warn.Dispatch", "0"); // // We don't want connection warnings because of the timeout test. // properties.setProperty("Ice.Warn.Connections", "0"); properties.setProperty("Ice.Package.Test", "Ice.operations"); using (var communicator = initialize(properties)) { communicator.getProperties().setProperty("TestAdapter.Endpoints", getTestEndpoint(0)); Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter"); adapter.add(new MyDerivedClassI(), Ice.Util.stringToIdentity("test")); adapter.activate(); serverReady(); communicator.waitForShutdown(); } }
public override void run(string[] args) { Ice.Properties properties = createTestProperties(ref args); properties.setProperty("Ice.Package.Test", "Ice.admin"); using (var communicator = initialize(properties)) { communicator.getProperties().setProperty("TestAdapter.Endpoints", getTestEndpoint(0) + " -t 10000"); Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter"); Ice.Identity id = Ice.Util.stringToIdentity("factory"); adapter.add(new RemoteCommunicatorFactoryI(), id); adapter.activate(); serverReady(); communicator.waitForShutdown(); } }
public override void run(string[] args) { Ice.Properties properties = createTestProperties(ref args); properties.setProperty("Ice.Package.Test", "Ice.adapterDeactivation"); using (var communicator = initialize(properties)) { communicator.getProperties().setProperty("TestAdapter.Endpoints", getTestEndpoint(0)); // // 2 threads are necessary to dispatch the collocated transient() call with AMI // communicator.getProperties().setProperty("TestAdapter.ThreadPool.Size", "2"); var adapter = communicator.createObjectAdapter("TestAdapter"); var locator = new ServantLocatorI(); adapter.addServantLocator(locator, ""); AllTests.allTests(this); adapter.waitForDeactivate(); } }
initialize() { Ice.Properties properties = _communicator.getProperties(); bool ipv4 = properties.getPropertyAsIntWithDefault("Ice.IPv4", 1) > 0; bool preferIPv6 = properties.getPropertyAsInt("Ice.PreferIPv6Address") > 0; string address; if (ipv4 && !preferIPv6) { address = properties.getPropertyWithDefault("IceLocatorDiscovery.Address", "239.255.0.1"); } else { address = properties.getPropertyWithDefault("IceLocatorDiscovery.Address", "ff15::1"); } int port = properties.getPropertyAsIntWithDefault("IceLocatorDiscovery.Port", 4061); string intf = properties.getProperty("IceLocatorDiscovery.Interface"); if (properties.getProperty("IceLocatorDiscovery.Reply.Endpoints").Length == 0) { System.Text.StringBuilder s = new System.Text.StringBuilder(); s.Append("udp"); if (intf.Length > 0) { s.Append(" -h \""); s.Append(intf); s.Append("\""); } properties.setProperty("IceLocatorDiscovery.Reply.Endpoints", s.ToString()); } if (properties.getProperty("IceLocatorDiscovery.Locator.Endpoints").Length == 0) { properties.setProperty("IceLocatorDiscovery.Locator.AdapterId", Guid.NewGuid().ToString()); } _replyAdapter = _communicator.createObjectAdapter("IceLocatorDiscovery.Reply"); _locatorAdapter = _communicator.createObjectAdapter("IceLocatorDiscovery.Locator"); // We don't want those adapters to be registered with the locator so clear their locator. _replyAdapter.setLocator(null); _locatorAdapter.setLocator(null); string lookupEndpoints = properties.getProperty("IceLocatorDiscovery.Lookup"); if (lookupEndpoints.Length == 0) { System.Text.StringBuilder s = new System.Text.StringBuilder(); s.Append("udp -h \""); s.Append(address); s.Append("\" -p "); s.Append(port); if (intf.Length > 0) { s.Append(" --interface \""); s.Append(intf); s.Append("\""); } lookupEndpoints = s.ToString(); } Ice.ObjectPrx lookupPrx = _communicator.stringToProxy("IceLocatorDiscovery/Lookup -d:" + lookupEndpoints); lookupPrx = lookupPrx.ice_collocationOptimized(false); // No colloc optimization for the multicast proxy! try { lookupPrx.ice_getConnection(); // Ensure we can establish a connection to the multicast proxy } catch (Ice.LocalException ex) { System.Text.StringBuilder s = new System.Text.StringBuilder(); s.Append("IceLocatorDiscovery is unable to establish a multicast connection:\n"); s.Append("proxy = "); s.Append(lookupPrx.ToString()); s.Append("\n"); s.Append(ex); throw new Ice.PluginInitializationException(s.ToString()); } Ice.LocatorPrx voidLo = Ice.LocatorPrxHelper.uncheckedCast(_locatorAdapter.addWithUUID(new VoidLocatorI())); string instanceName = properties.getProperty("IceLocatorDiscovery.InstanceName"); Ice.Identity id = new Ice.Identity(); id.name = "Locator"; id.category = instanceName.Length > 0 ? instanceName : Guid.NewGuid().ToString(); LocatorI locator = new LocatorI(LookupPrxHelper.uncheckedCast(lookupPrx), properties, instanceName, voidLo); _communicator.setDefaultLocator(Ice.LocatorPrxHelper.uncheckedCast(_locatorAdapter.addWithUUID(locator))); Ice.ObjectPrx lookupReply = _replyAdapter.addWithUUID(new LookupReplyI(locator)).ice_datagram(); locator.setLookupReply(LookupReplyPrxHelper.uncheckedCast(lookupReply)); _replyAdapter.activate(); _locatorAdapter.activate(); }
public void initialize() { Ice.Properties properties = _communicator.getProperties(); bool ipv4 = properties.getPropertyAsIntWithDefault("Ice.IPv4", 1) > 0; bool preferIPv6 = properties.getPropertyAsInt("Ice.PreferIPv6Address") > 0; string address; if (ipv4 && !preferIPv6) { address = properties.getPropertyWithDefault("IceDiscovery.Address", "239.255.0.1"); } else { address = properties.getPropertyWithDefault("IceDiscovery.Address", "ff15::1"); } int port = properties.getPropertyAsIntWithDefault("IceDiscovery.Port", 4061); string intf = properties.getProperty("IceDiscovery.Interface"); if (properties.getProperty("IceDiscovery.Multicast.Endpoints").Length == 0) { StringBuilder s = new StringBuilder(); s.Append("udp -h \"").Append(address).Append("\" -p ").Append(port); if (intf.Length != 0) { s.Append(" --interface \"").Append(intf).Append("\""); } properties.setProperty("IceDiscovery.Multicast.Endpoints", s.ToString()); } string lookupEndpoints = properties.getProperty("IceDiscovery.Lookup"); if (lookupEndpoints.Length == 0) { int protocol = ipv4 && !preferIPv6 ? IceInternal.Network.EnableIPv4 : IceInternal.Network.EnableIPv6; var interfaces = IceInternal.Network.getInterfacesForMulticast(intf, protocol); foreach (string p in interfaces) { if (p != interfaces[0]) { lookupEndpoints += ":"; } lookupEndpoints += "udp -h \"" + address + "\" -p " + port + " --interface \"" + p + "\""; } } if (properties.getProperty("IceDiscovery.Reply.Endpoints").Length == 0) { properties.setProperty("IceDiscovery.Reply.Endpoints", "udp -h " + (intf.Length == 0 ? "*" : "\"" + intf + "\"")); } if (properties.getProperty("IceDiscovery.Locator.Endpoints").Length == 0) { properties.setProperty("IceDiscovery.Locator.AdapterId", Guid.NewGuid().ToString()); } _multicastAdapter = _communicator.createObjectAdapter("IceDiscovery.Multicast"); _replyAdapter = _communicator.createObjectAdapter("IceDiscovery.Reply"); _locatorAdapter = _communicator.createObjectAdapter("IceDiscovery.Locator"); // // Setup locatory registry. // LocatorRegistryI locatorRegistry = new LocatorRegistryI(_communicator); Ice.LocatorRegistryPrx locatorRegistryPrx = Ice.LocatorRegistryPrxHelper.uncheckedCast( _locatorAdapter.addWithUUID(locatorRegistry)); Ice.ObjectPrx lookupPrx = _communicator.stringToProxy("IceDiscovery/Lookup -d:" + lookupEndpoints); // No colloc optimization or router for the multicast proxy! lookupPrx = lookupPrx.ice_collocationOptimized(false).ice_router(null); // // Add lookup and lookup reply Ice objects // LookupI lookup = new LookupI(locatorRegistry, LookupPrxHelper.uncheckedCast(lookupPrx), properties); _multicastAdapter.add(lookup, Ice.Util.stringToIdentity("IceDiscovery/Lookup")); _replyAdapter.addDefaultServant(new LookupReplyI(lookup), ""); Ice.Identity id = new Ice.Identity("dummy", ""); lookup.setLookupReply(LookupReplyPrxHelper.uncheckedCast(_replyAdapter.createProxy(id).ice_datagram())); // // Setup locator on the communicator. // Ice.ObjectPrx loc; loc = _locatorAdapter.addWithUUID( new LocatorI(lookup, Ice.LocatorRegistryPrxHelper.uncheckedCast(locatorRegistryPrx))); _defaultLocator = _communicator.getDefaultLocator(); _locator = Ice.LocatorPrxHelper.uncheckedCast(loc); _communicator.setDefaultLocator(_locator); _multicastAdapter.activate(); _replyAdapter.activate(); _locatorAdapter.activate(); }
public override void run(string[] args) { Ice.Properties properties = createTestProperties(ref args); properties.setProperty("Ice.Warn.Connections", "0"); properties.setProperty("Ice.UDP.RcvSize", "16384"); if (IceInternal.AssemblyUtil.isMacOS && properties.getPropertyAsInt("Ice.IPv6") > 0) { // Disable dual mode sockets on macOS, see https://github.com/dotnet/corefx/issues/31182 properties.setProperty("Ice.IPv4", "0"); } using (var communicator = initialize(properties)) { int num = 0; try { num = args.Length == 1 ? Int32.Parse(args[0]) : 0; } catch (FormatException) { } communicator.Properties.setProperty("ControlAdapter.Endpoints", getTestEndpoint(num, "tcp")); Ice.ObjectAdapter adapter = communicator.createObjectAdapter("ControlAdapter"); adapter.Add(new TestIntfI(), "control"); adapter.Activate(); serverReady(); if (num == 0) { communicator.Properties.setProperty("TestAdapter.Endpoints", getTestEndpoint(num, "udp")); Ice.ObjectAdapter adapter2 = communicator.createObjectAdapter("TestAdapter"); adapter2.Add(new TestIntfI(), "test"); adapter2.Activate(); } StringBuilder endpoint = new StringBuilder(); // // Use loopback to prevent other machines to answer. // if (properties.getProperty("Ice.IPv6").Equals("1")) { endpoint.Append("udp -h \"ff15::1:1\""); if (IceInternal.AssemblyUtil.isWindows || IceInternal.AssemblyUtil.isMacOS) { endpoint.Append(" --interface \"::1\""); } } else { endpoint.Append("udp -h 239.255.1.1"); if (IceInternal.AssemblyUtil.isWindows || IceInternal.AssemblyUtil.isMacOS) { endpoint.Append(" --interface 127.0.0.1"); } } endpoint.Append(" -p "); endpoint.Append(getTestPort(properties, 10)); communicator.Properties.setProperty("McastTestAdapter.Endpoints", endpoint.ToString()); Ice.ObjectAdapter mcastAdapter = communicator.createObjectAdapter("McastTestAdapter"); mcastAdapter.Add(new TestIntfI(), "test"); mcastAdapter.Activate(); communicator.waitForShutdown(); } }
public static void allTests(global::Test.TestHelper helper) { Ice.Communicator communicator = helper.communicator(); var manager = Test.ServerManagerPrxHelper.checkedCast( communicator.stringToProxy("ServerManager :" + helper.getTestEndpoint(0))); test(manager != null); var locator = Test.TestLocatorPrxHelper.uncheckedCast(communicator.getDefaultLocator()); test(locator != null); var registry = Test.TestLocatorRegistryPrxHelper.checkedCast(locator.getRegistry()); test(registry != null); var output = helper.getWriter(); output.Write("testing stringToProxy... "); output.Flush(); Ice.ObjectPrx @base = communicator.stringToProxy("test @ TestAdapter"); Ice.ObjectPrx base2 = communicator.stringToProxy("test @ TestAdapter"); Ice.ObjectPrx base3 = communicator.stringToProxy("test"); Ice.ObjectPrx base4 = communicator.stringToProxy("ServerManager"); Ice.ObjectPrx base5 = communicator.stringToProxy("test2"); Ice.ObjectPrx base6 = communicator.stringToProxy("test @ ReplicatedAdapter"); output.WriteLine("ok"); output.Write("testing ice_locator and ice_getLocator... "); test(Ice.Util.proxyIdentityCompare(@base.ice_getLocator(), communicator.getDefaultLocator()) == 0); Ice.LocatorPrx anotherLocator = Ice.LocatorPrxHelper.uncheckedCast(communicator.stringToProxy("anotherLocator")); @base = @base.ice_locator(anotherLocator); test(Ice.Util.proxyIdentityCompare(@base.ice_getLocator(), anotherLocator) == 0); communicator.setDefaultLocator(null); @base = communicator.stringToProxy("test @ TestAdapter"); test(@base.ice_getLocator() == null); @base = @base.ice_locator(anotherLocator); test(Ice.Util.proxyIdentityCompare(@base.ice_getLocator(), anotherLocator) == 0); communicator.setDefaultLocator(locator); @base = communicator.stringToProxy("test @ TestAdapter"); test(Ice.Util.proxyIdentityCompare(@base.ice_getLocator(), communicator.getDefaultLocator()) == 0); // // We also test ice_router/ice_getRouter(perhaps we should add a // test/Ice/router test?) // test(@base.ice_getRouter() == null); Ice.RouterPrx anotherRouter = Ice.RouterPrxHelper.uncheckedCast(communicator.stringToProxy("anotherRouter")); @base = @base.ice_router(anotherRouter); test(Ice.Util.proxyIdentityCompare(@base.ice_getRouter(), anotherRouter) == 0); Ice.RouterPrx router = Ice.RouterPrxHelper.uncheckedCast(communicator.stringToProxy("dummyrouter")); communicator.setDefaultRouter(router); @base = communicator.stringToProxy("test @ TestAdapter"); test(Ice.Util.proxyIdentityCompare(@base.ice_getRouter(), communicator.getDefaultRouter()) == 0); communicator.setDefaultRouter(null); @base = communicator.stringToProxy("test @ TestAdapter"); test(@base.ice_getRouter() == 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.TestIntfPrxHelper.checkedCast(@base); test(obj != null); var obj2 = Test.TestIntfPrxHelper.checkedCast(base2); test(obj2 != null); var obj3 = Test.TestIntfPrxHelper.checkedCast(base3); test(obj3 != null); var obj4 = Test.ServerManagerPrxHelper.checkedCast(base4); test(obj4 != null); var obj5 = Test.TestIntfPrxHelper.checkedCast(base5); test(obj5 != null); var obj6 = Test.TestIntfPrxHelper.checkedCast(base6); test(obj6 != null); output.WriteLine("ok"); output.Write("testing id@AdapterId indirect proxy... "); output.Flush(); obj.shutdown(); manager.startServer(); try { obj2.ice_ping(); } catch (Ice.LocalException) { test(false); } output.WriteLine("ok"); output.Write("testing id@ReplicaGroupId indirect proxy... "); output.Flush(); obj.shutdown(); manager.startServer(); try { obj6.ice_ping(); } catch (Ice.LocalException) { test(false); } output.WriteLine("ok"); output.Write("testing identity indirect proxy... "); output.Flush(); obj.shutdown(); manager.startServer(); try { obj3.ice_ping(); } catch (Ice.LocalException) { test(false); } try { obj2.ice_ping(); } catch (Ice.LocalException) { test(false); } obj.shutdown(); manager.startServer(); try { obj2.ice_ping(); } catch (Ice.LocalException) { test(false); } try { obj3.ice_ping(); } catch (Ice.LocalException) { test(false); } obj.shutdown(); manager.startServer(); try { obj2.ice_ping(); } catch (Ice.LocalException) { test(false); } obj.shutdown(); manager.startServer(); try { obj3.ice_ping(); } catch (Ice.LocalException) { test(false); } obj.shutdown(); manager.startServer(); try { obj5 = Test.TestIntfPrxHelper.checkedCast(base5); obj5.ice_ping(); } catch (Ice.LocalException) { test(false); } output.WriteLine("ok"); output.Write("testing proxy with unknown identity... "); output.Flush(); try { @base = communicator.stringToProxy("unknown/unknown"); @base.ice_ping(); test(false); } catch (Ice.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 = communicator.stringToProxy("test @ TestAdapterUnknown"); @base.ice_ping(); test(false); } catch (Ice.NotRegisteredException ex) { test(ex.kindOfObject.Equals("object adapter")); test(ex.id.Equals("TestAdapterUnknown")); } output.WriteLine("ok"); output.Write("testing locator cache timeout... "); output.Flush(); Ice.ObjectPrx basencc = communicator.stringToProxy("test@TestAdapter").ice_connectionCached(false); int count = locator.getRequestCount(); basencc.ice_locatorCacheTimeout(0).ice_ping(); // No locator cache. test(++count == locator.getRequestCount()); basencc.ice_locatorCacheTimeout(0).ice_ping(); // No locator cache. test(++count == locator.getRequestCount()); basencc.ice_locatorCacheTimeout(2).ice_ping(); // 2s timeout. test(count == locator.getRequestCount()); System.Threading.Thread.Sleep(1300); // 1300ms basencc.ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout. test(++count == locator.getRequestCount()); communicator.stringToProxy("test").ice_locatorCacheTimeout(0).ice_ping(); // No locator cache. count += 2; test(count == locator.getRequestCount()); communicator.stringToProxy("test").ice_locatorCacheTimeout(2).ice_ping(); // 2s timeout test(count == locator.getRequestCount()); System.Threading.Thread.Sleep(1300); // 1300ms communicator.stringToProxy("test").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout count += 2; test(count == locator.getRequestCount()); communicator.stringToProxy("test@TestAdapter").ice_locatorCacheTimeout(-1).ice_ping(); test(count == locator.getRequestCount()); communicator.stringToProxy("test").ice_locatorCacheTimeout(-1).ice_ping(); test(count == locator.getRequestCount()); communicator.stringToProxy("test@TestAdapter").ice_ping(); test(count == locator.getRequestCount()); communicator.stringToProxy("test").ice_ping(); test(count == locator.getRequestCount()); test(communicator.stringToProxy("test").ice_locatorCacheTimeout(99).ice_getLocatorCacheTimeout() == 99); output.WriteLine("ok"); output.Write("testing proxy from server... "); output.Flush(); obj = Test.TestIntfPrxHelper.checkedCast(communicator.stringToProxy("test@TestAdapter")); var hello = obj.getHello(); test(hello.ice_getAdapterId().Equals("TestAdapter")); hello.sayHello(); hello = obj.getReplicatedHello(); test(hello.ice_getAdapterId().Equals("ReplicatedAdapter")); hello.sayHello(); output.WriteLine("ok"); output.Write("testing locator request queuing... "); output.Flush(); hello = (Test.HelloPrx)obj.getReplicatedHello().ice_locatorCacheTimeout(0).ice_connectionCached(false); count = locator.getRequestCount(); hello.ice_ping(); test(++count == locator.getRequestCount()); List <Ice.AsyncResult <Test.Callback_Hello_sayHello> > results = new List <Ice.AsyncResult <Test.Callback_Hello_sayHello> >(); for (int i = 0; i < 1000; i++) { Ice.AsyncResult <Test.Callback_Hello_sayHello> result = hello.begin_sayHello(). whenCompleted( () => { }, (Ice.Exception ex) => { test(false); }); results.Add(result); } foreach (Ice.AsyncResult <Test.Callback_Hello_sayHello> result in results) { result.waitForCompleted(); } 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 = (Test.HelloPrx)hello.ice_adapterId("unknown"); for (int i = 0; i < 1000; i++) { Ice.AsyncResult <Test.Callback_Hello_sayHello> result = hello.begin_sayHello(). whenCompleted( () => { test(false); }, (Ice.Exception ex) => { test(ex is Ice.NotRegisteredException); }); results.Add(result); } foreach (Ice.AsyncResult <Test.Callback_Hello_sayHello> result in results) { result.waitForCompleted(); } 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 { communicator.stringToProxy("test@TestAdapter3").ice_ping(); test(false); } catch (Ice.NotRegisteredException ex) { test(ex.kindOfObject == "object adapter"); test(ex.id.Equals("TestAdapter3")); } registry.setAdapterDirectProxy("TestAdapter3", locator.findAdapterById("TestAdapter")); try { communicator.stringToProxy("test@TestAdapter3").ice_ping(); registry.setAdapterDirectProxy("TestAdapter3", communicator.stringToProxy("dummy:tcp")); communicator.stringToProxy("test@TestAdapter3").ice_ping(); } catch (Ice.LocalException) { test(false); } try { communicator.stringToProxy("test@TestAdapter3").ice_locatorCacheTimeout(0).ice_ping(); test(false); } catch (Ice.LocalException) { } try { communicator.stringToProxy("test@TestAdapter3").ice_ping(); test(false); } catch (Ice.LocalException) { } registry.setAdapterDirectProxy("TestAdapter3", locator.findAdapterById("TestAdapter")); try { communicator.stringToProxy("test@TestAdapter3").ice_ping(); } catch (Ice.LocalException) { test(false); } output.WriteLine("ok"); output.Write("testing well-known object locator cache... "); output.Flush(); registry.addObject(communicator.stringToProxy("test3@TestUnknown")); try { communicator.stringToProxy("test3").ice_ping(); test(false); } catch (Ice.NotRegisteredException ex) { test(ex.kindOfObject == "object adapter"); test(ex.id.Equals("TestUnknown")); } registry.addObject(communicator.stringToProxy("test3@TestAdapter4")); // Update registry.setAdapterDirectProxy("TestAdapter4", communicator.stringToProxy("dummy:tcp")); try { communicator.stringToProxy("test3").ice_ping(); test(false); } catch (Ice.LocalException) { } registry.setAdapterDirectProxy("TestAdapter4", locator.findAdapterById("TestAdapter")); try { communicator.stringToProxy("test3").ice_ping(); } catch (Ice.LocalException) { test(false); } registry.setAdapterDirectProxy("TestAdapter4", communicator.stringToProxy("dummy:tcp")); try { communicator.stringToProxy("test3").ice_ping(); } catch (Ice.LocalException) { test(false); } try { communicator.stringToProxy("test@TestAdapter4").ice_locatorCacheTimeout(0).ice_ping(); test(false); } catch (Ice.LocalException) { } try { communicator.stringToProxy("test@TestAdapter4").ice_ping(); test(false); } catch (Ice.LocalException) { } try { communicator.stringToProxy("test3").ice_ping(); test(false); } catch (Ice.LocalException) { } registry.addObject(communicator.stringToProxy("test3@TestAdapter")); try { communicator.stringToProxy("test3").ice_ping(); } catch (Ice.LocalException) { test(false); } registry.addObject(communicator.stringToProxy("test4")); try { communicator.stringToProxy("test4").ice_ping(); test(false); } catch (Ice.NoEndpointException) { } output.WriteLine("ok"); output.Write("testing locator cache background updates... "); output.Flush(); { Ice.InitializationData initData = new Ice.InitializationData(); initData.properties = communicator.getProperties().ice_clone_(); initData.properties.setProperty("Ice.BackgroundLocatorCacheUpdates", "1"); Ice.Communicator ic = helper.initialize(initData); registry.setAdapterDirectProxy("TestAdapter5", locator.findAdapterById("TestAdapter")); registry.addObject(communicator.stringToProxy("test3@TestAdapter")); count = locator.getRequestCount(); ic.stringToProxy("test@TestAdapter5").ice_locatorCacheTimeout(0).ice_ping(); // No locator cache. ic.stringToProxy("test3").ice_locatorCacheTimeout(0).ice_ping(); // No locator cache. count += 3; test(count == locator.getRequestCount()); registry.setAdapterDirectProxy("TestAdapter5", null); registry.addObject(communicator.stringToProxy("test3:tcp")); ic.stringToProxy("test@TestAdapter5").ice_locatorCacheTimeout(10).ice_ping(); // 10s timeout. ic.stringToProxy("test3").ice_locatorCacheTimeout(10).ice_ping(); // 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. ic.stringToProxy("test@TestAdapter5").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout. ic.stringToProxy("test3").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout. try { while (true) { ic.stringToProxy("test@TestAdapter5").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout. System.Threading.Thread.Sleep(10); } } catch (Ice.LocalException) { // Expected to fail once they endpoints have been updated in the background. } try { while (true) { ic.stringToProxy("test3").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout. System.Threading.Thread.Sleep(10); } } catch (Ice.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 = Test.HelloPrxHelper.checkedCast(communicator.stringToProxy("hello")); obj.migrateHello(); hello.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); hello.sayHello(); obj.migrateHello(); hello.sayHello(); obj.migrateHello(); hello.sayHello(); output.WriteLine("ok"); output.Write("testing locator encoding resolution... "); output.Flush(); hello = Test.HelloPrxHelper.checkedCast(communicator.stringToProxy("hello")); count = locator.getRequestCount(); communicator.stringToProxy("test@TestAdapter").ice_encodingVersion(Ice.Util.Encoding_1_1).ice_ping(); test(count == locator.getRequestCount()); communicator.stringToProxy("test@TestAdapter10").ice_encodingVersion(Ice.Util.Encoding_1_0).ice_ping(); test(++count == locator.getRequestCount()); communicator.stringToProxy("test -e 1.0@TestAdapter10-2").ice_ping(); 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.ice_ping(); test(false); } catch (Ice.LocalException) { } try { obj3.ice_ping(); test(false); } catch (Ice.LocalException) { } try { obj5.ice_ping(); test(false); } catch (Ice.LocalException) { } output.WriteLine("ok"); output.Write("testing indirect proxies to collocated objects... "); output.Flush(); // // Set up test for calling a collocated object through an // indirect, adapterless reference. // Ice.Properties properties = communicator.getProperties(); properties.setProperty("Ice.PrintAdapterReady", "0"); Ice.ObjectAdapter adapter = communicator.createObjectAdapterWithEndpoints("Hello", "tcp -h *"); adapter.setLocator(locator); Ice.Identity id = new Ice.Identity(); id.name = Guid.NewGuid().ToString(); registry.addObject(adapter.add(new HelloI(), id)); adapter.activate(); var helloPrx = Test.HelloPrxHelper.checkedCast( communicator.stringToProxy("\"" + communicator.identityToString(id) + "\"")); test(helloPrx.ice_getConnection() == null); adapter.deactivate(); output.WriteLine("ok"); output.Write("shutdown server manager... "); output.Flush(); manager.shutdown(); output.WriteLine("ok"); }
public void initialize() { Ice.Properties properties = _communicator.getProperties(); bool ipv4 = properties.getPropertyAsIntWithDefault("Ice.IPv4", 1) > 0; bool preferIPv6 = properties.getPropertyAsInt("Ice.PreferIPv6Address") > 0; string address; if (ipv4 && !preferIPv6) { address = properties.getPropertyWithDefault("IceDiscovery.Address", "239.255.0.1"); } else { address = properties.getPropertyWithDefault("IceDiscovery.Address", "ff15::1"); } int port = properties.getPropertyAsIntWithDefault("IceDiscovery.Port", 4061); string intf = properties.getProperty("IceDiscovery.Interface"); if (properties.getProperty("IceDiscovery.Multicast.Endpoints").Length == 0) { StringBuilder s = new StringBuilder(); s.Append("udp -h \"").Append(address).Append("\" -p ").Append(port); if (intf.Length != 0) { s.Append(" --interface \"").Append(intf).Append("\""); } properties.setProperty("IceDiscovery.Multicast.Endpoints", s.ToString()); } if (properties.getProperty("IceDiscovery.Reply.Endpoints").Length == 0) { StringBuilder s = new StringBuilder(); s.Append("udp"); if (intf.Length != 0) { s.Append(" -h \"").Append(intf).Append("\""); } properties.setProperty("IceDiscovery.Reply.Endpoints", s.ToString()); } if (properties.getProperty("IceDiscovery.Locator.Endpoints").Length == 0) { properties.setProperty("IceDiscovery.Locator.AdapterId", Guid.NewGuid().ToString()); } _multicastAdapter = _communicator.createObjectAdapter("IceDiscovery.Multicast"); _replyAdapter = _communicator.createObjectAdapter("IceDiscovery.Reply"); _locatorAdapter = _communicator.createObjectAdapter("IceDiscovery.Locator"); // // Setup locatory registry. // LocatorRegistryI locatorRegistry = new LocatorRegistryI(_communicator); Ice.LocatorRegistryPrx locatorRegistryPrx = Ice.LocatorRegistryPrxHelper.uncheckedCast( _locatorAdapter.addWithUUID(locatorRegistry)); string lookupEndpoints = properties.getProperty("IceDiscovery.Lookup"); if (lookupEndpoints.Length == 0) { lookupEndpoints = "udp -h \"" + address + "\" -p " + port; if (intf.Length > 0) { lookupEndpoints += " --interface \"" + intf + "\""; } } Ice.ObjectPrx lookupPrx = _communicator.stringToProxy("IceDiscovery/Lookup -d:" + lookupEndpoints); lookupPrx = lookupPrx.ice_collocationOptimized(false); try { lookupPrx.ice_getConnection(); } catch (Ice.LocalException ex) { StringBuilder b = new StringBuilder(); b.Append("IceDiscovery is unable to establish a multicast connection:\n"); b.Append("proxy = "); b.Append(lookupPrx.ToString()); b.Append('\n'); b.Append(ex.ToString()); throw new Ice.PluginInitializationException(b.ToString()); } // // Add lookup and lookup reply Ice objects // LookupI lookup = new LookupI(locatorRegistry, LookupPrxHelper.uncheckedCast(lookupPrx), properties); _multicastAdapter.add(lookup, Ice.Util.stringToIdentity("IceDiscovery/Lookup")); Ice.ObjectPrx lookupReply = _replyAdapter.addWithUUID(new LookupReplyI(lookup)).ice_datagram(); lookup.setLookupReply(LookupReplyPrxHelper.uncheckedCast(lookupReply)); // // Setup locator on the communicator. // Ice.ObjectPrx loc; loc = _locatorAdapter.addWithUUID( new LocatorI(lookup, Ice.LocatorRegistryPrxHelper.uncheckedCast(locatorRegistryPrx))); _communicator.setDefaultLocator(Ice.LocatorPrxHelper.uncheckedCast(loc)); _multicastAdapter.activate(); _replyAdapter.activate(); _locatorAdapter.activate(); }
public static void allTests(global::Test.TestHelper helper) { Ice.Communicator communicator = helper.communicator(); string @ref = "communicator:" + helper.getTestEndpoint(0); Test.RemoteCommunicatorPrx com = Test.RemoteCommunicatorPrxHelper.uncheckedCast(communicator.stringToProxy(@ref)); var rand = new Random(unchecked ((int)DateTime.Now.Ticks)); var output = helper.getWriter(); output.Write("testing binding with single endpoint... "); output.Flush(); { Test.RemoteObjectAdapterPrx adapter = com.createObjectAdapter("Adapter", "default"); var test1 = adapter.getTestIntf(); var test2 = adapter.getTestIntf(); test(test1.ice_getConnection() == test2.ice_getConnection()); test1.ice_ping(); test2.ice_ping(); com.deactivateObjectAdapter(adapter); var test3 = Test.TestIntfPrxHelper.uncheckedCast(test1); test(test3.ice_getConnection() == test1.ice_getConnection()); test(test3.ice_getConnection() == test2.ice_getConnection()); try { test3.ice_ping(); test(false); } catch (Ice.ConnectFailedException) { } catch (Ice.ConnectTimeoutException) { } } output.WriteLine("ok"); output.Write("testing binding with multiple endpoints... "); output.Flush(); { var adapters = new List <Test.RemoteObjectAdapterPrx>(); adapters.Add(com.createObjectAdapter("Adapter11", "default")); adapters.Add(com.createObjectAdapter("Adapter12", "default")); adapters.Add(com.createObjectAdapter("Adapter13", "default")); // // Ensure that when a connection is opened it's reused for new // proxies and that all endpoints are eventually tried. // List <string> names = new List <string>(); names.Add("Adapter11"); names.Add("Adapter12"); names.Add("Adapter13"); while (names.Count > 0) { var adpts = new List <Test.RemoteObjectAdapterPrx>(adapters); var test1 = createTestIntfPrx(adpts); shuffle(ref adpts); var test2 = createTestIntfPrx(adpts); shuffle(ref adpts); var test3 = createTestIntfPrx(adpts); test1.ice_ping(); test(test1.ice_getConnection() == test2.ice_getConnection()); test(test2.ice_getConnection() == test3.ice_getConnection()); names.Remove(test1.getAdapterName()); test1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } // // Ensure that the proxy correctly caches the connection(we // always send the request over the same connection.) // { foreach (var adpt in adapters) { adpt.getTestIntf().ice_ping(); } var 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 (var adpt in adapters) { adpt.getTestIntf().ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } } // // Deactivate an adapter and ensure that we can still // establish the connection to the remaining adapters. // com.deactivateObjectAdapter((Test.RemoteObjectAdapterPrx)adapters[0]); names.Add("Adapter12"); names.Add("Adapter13"); while (names.Count > 0) { var adpts = new List <Test.RemoteObjectAdapterPrx>(adapters); var test1 = createTestIntfPrx(adpts); shuffle(ref adpts); var test2 = createTestIntfPrx(adpts); shuffle(ref adpts); var test3 = createTestIntfPrx(adpts); test(test1.ice_getConnection() == test2.ice_getConnection()); test(test2.ice_getConnection() == test3.ice_getConnection()); names.Remove(test1.getAdapterName()); test1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } // // Deactivate an adapter and ensure that we can still // establish the connection to the remaining adapter. // com.deactivateObjectAdapter((Test.RemoteObjectAdapterPrx)adapters[2]); var obj = createTestIntfPrx(adapters); test(obj.getAdapterName().Equals("Adapter12")); deactivate(com, adapters); } output.WriteLine("ok"); output.Write("testing binding with multiple random endpoints... "); output.Flush(); { var adapters = new Test.RemoteObjectAdapterPrx[5]; adapters[0] = com.createObjectAdapter("AdapterRandom11", "default"); adapters[1] = com.createObjectAdapter("AdapterRandom12", "default"); adapters[2] = com.createObjectAdapter("AdapterRandom13", "default"); adapters[3] = com.createObjectAdapter("AdapterRandom14", "default"); adapters[4] = com.createObjectAdapter("AdapterRandom15", "default"); int count = 20; int adapterCount = adapters.Length; while (--count > 0) { Test.TestIntfPrx[] proxies; if (count == 1) { com.deactivateObjectAdapter(adapters[4]); --adapterCount; } proxies = new Test.TestIntfPrx[10]; int i; for (i = 0; i < proxies.Length; ++i) { var adpts = new Test.RemoteObjectAdapterPrx[rand.Next(adapters.Length)]; if (adpts.Length == 0) { adpts = new Test.RemoteObjectAdapterPrx[1]; } for (int j = 0; j < adpts.Length; ++j) { adpts[j] = adapters[rand.Next(adapters.Length)]; } proxies[i] = createTestIntfPrx(new List <Test.RemoteObjectAdapterPrx>(adpts)); } for (i = 0; i < proxies.Length; i++) { proxies[i].begin_getAdapterName(); } for (i = 0; i < proxies.Length; i++) { try { proxies[i].ice_ping(); } catch (Ice.LocalException) { } } List <Ice.Connection> connections = new List <Ice.Connection>(); for (i = 0; i < proxies.Length; i++) { if (proxies[i].ice_getCachedConnection() != null) { if (!connections.Contains(proxies[i].ice_getCachedConnection())) { connections.Add(proxies[i].ice_getCachedConnection()); } } } test(connections.Count <= adapterCount); foreach (var a in adapters) { try { a.getTestIntf().ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } catch (Ice.LocalException) { // Expected if adapter is down. } } } } output.WriteLine("ok"); output.Write("testing binding with multiple endpoints and AMI... "); output.Flush(); { var adapters = new List <Test.RemoteObjectAdapterPrx>(); adapters.Add(com.createObjectAdapter("AdapterAMI11", "default")); adapters.Add(com.createObjectAdapter("AdapterAMI12", "default")); adapters.Add(com.createObjectAdapter("AdapterAMI13", "default")); // // Ensure that when a connection is opened it's reused for new // proxies and that all endpoints are eventually tried. // List <string> names = new List <string>(); names.Add("AdapterAMI11"); names.Add("AdapterAMI12"); names.Add("AdapterAMI13"); while (names.Count > 0) { var adpts = new List <Test.RemoteObjectAdapterPrx>(adapters); var test1 = createTestIntfPrx(adpts); shuffle(ref adpts); var test2 = createTestIntfPrx(adpts); shuffle(ref adpts); var test3 = createTestIntfPrx(adpts); test1.ice_ping(); test(test1.ice_getConnection() == test2.ice_getConnection()); test(test2.ice_getConnection() == test3.ice_getConnection()); names.Remove(getAdapterNameWithAMI(test1)); test1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } // // Ensure that the proxy correctly caches the connection(we // always send the request over the same connection.) // { foreach (var adpt in adapters) { adpt.getTestIntf().ice_ping(); } var 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 (var adpt in adapters) { adpt.getTestIntf().ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } } // // Deactivate an adapter and ensure that we can still // establish the connection to the remaining adapters. // com.deactivateObjectAdapter(adapters[0]); names.Add("AdapterAMI12"); names.Add("AdapterAMI13"); while (names.Count > 0) { var adpts = new List <Test.RemoteObjectAdapterPrx>(adapters); var test1 = createTestIntfPrx(adpts); shuffle(ref adpts); var test2 = createTestIntfPrx(adpts); shuffle(ref adpts); var test3 = createTestIntfPrx(adpts); test(test1.ice_getConnection() == test2.ice_getConnection()); test(test2.ice_getConnection() == test3.ice_getConnection()); names.Remove(getAdapterNameWithAMI(test1)); test1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } // // Deactivate an adapter and ensure that we can still // establish the connection to the remaining adapter. // com.deactivateObjectAdapter(adapters[2]); var obj = createTestIntfPrx(adapters); test(getAdapterNameWithAMI(obj).Equals("AdapterAMI12")); deactivate(com, adapters); } output.WriteLine("ok"); output.Write("testing random endpoint selection... "); output.Flush(); { var adapters = new List <Test.RemoteObjectAdapterPrx>(); adapters.Add(com.createObjectAdapter("Adapter21", "default")); adapters.Add(com.createObjectAdapter("Adapter22", "default")); adapters.Add(com.createObjectAdapter("Adapter23", "default")); var obj = createTestIntfPrx(adapters); test(obj.ice_getEndpointSelection() == Ice.EndpointSelectionType.Random); var names = new List <string>(); names.Add("Adapter21"); names.Add("Adapter22"); names.Add("Adapter23"); while (names.Count > 0) { names.Remove(obj.getAdapterName()); obj.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } obj = Test.TestIntfPrxHelper.uncheckedCast(obj.ice_endpointSelection(Ice.EndpointSelectionType.Random)); test(obj.ice_getEndpointSelection() == Ice.EndpointSelectionType.Random); names.Add("Adapter21"); names.Add("Adapter22"); names.Add("Adapter23"); while (names.Count > 0) { names.Remove(obj.getAdapterName()); obj.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } deactivate(com, adapters); } output.WriteLine("ok"); output.Write("testing ordered endpoint selection... "); output.Flush(); { var adapters = new List <Test.RemoteObjectAdapterPrx>(); adapters.Add(com.createObjectAdapter("Adapter31", "default")); adapters.Add(com.createObjectAdapter("Adapter32", "default")); adapters.Add(com.createObjectAdapter("Adapter33", "default")); var obj = createTestIntfPrx(adapters); obj = Test.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(adapters[0]); for (i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter32"); i++) { ; } test(i == nRetry); com.deactivateObjectAdapter(adapters[1]); for (i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter33"); i++) { ; } test(i == nRetry); com.deactivateObjectAdapter(adapters[2]); try { obj.getAdapterName(); } catch (Ice.ConnectFailedException) { } catch (Ice.ConnectTimeoutException) { } Ice.Endpoint[] endpoints = obj.ice_getEndpoints(); adapters.Clear(); // // Now, re-activate the adapters with the same endpoints in the opposite // order. // adapters.Add(com.createObjectAdapter("Adapter36", endpoints[2].ToString())); for (i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter36"); i++) { ; } test(i == nRetry); obj.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); adapters.Add(com.createObjectAdapter("Adapter35", endpoints[1].ToString())); for (i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter35"); i++) { ; } test(i == nRetry); obj.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); adapters.Add(com.createObjectAdapter("Adapter34", endpoints[0].ToString())); for (i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter34"); i++) { ; } test(i == nRetry); deactivate(com, adapters); } output.WriteLine("ok"); output.Write("testing per request binding with single endpoint... "); output.Flush(); { var adapter = com.createObjectAdapter("Adapter41", "default"); var test1 = Test.TestIntfPrxHelper.uncheckedCast(adapter.getTestIntf().ice_connectionCached(false)); var test2 = Test.TestIntfPrxHelper.uncheckedCast(adapter.getTestIntf().ice_connectionCached(false)); test(!test1.ice_isConnectionCached()); test(!test2.ice_isConnectionCached()); test(test1.ice_getConnection() != null && test2.ice_getConnection() != null); test(test1.ice_getConnection() == test2.ice_getConnection()); test1.ice_ping(); com.deactivateObjectAdapter(adapter); var test3 = Test.TestIntfPrxHelper.uncheckedCast(test1); try { test(test3.ice_getConnection() == test1.ice_getConnection()); test(false); } catch (Ice.ConnectFailedException) { } catch (Ice.ConnectTimeoutException) { } } output.WriteLine("ok"); output.Write("testing per request binding with multiple endpoints... "); output.Flush(); { var adapters = new List <Test.RemoteObjectAdapterPrx>(); adapters.Add(com.createObjectAdapter("Adapter51", "default")); adapters.Add(com.createObjectAdapter("Adapter52", "default")); adapters.Add(com.createObjectAdapter("Adapter53", "default")); var obj = Test.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(adapters[0]); names.Add("Adapter52"); names.Add("Adapter53"); while (names.Count > 0) { names.Remove(obj.getAdapterName()); } com.deactivateObjectAdapter(adapters[2]); test(obj.getAdapterName().Equals("Adapter52")); deactivate(com, adapters); } output.WriteLine("ok"); output.Write("testing per request binding with multiple endpoints and AMI... "); output.Flush(); { var adapters = new List <Test.RemoteObjectAdapterPrx>(); adapters.Add(com.createObjectAdapter("AdapterAMI51", "default")); adapters.Add(com.createObjectAdapter("AdapterAMI52", "default")); adapters.Add(com.createObjectAdapter("AdapterAMI53", "default")); var obj = Test.TestIntfPrxHelper.uncheckedCast(createTestIntfPrx(adapters).ice_connectionCached(false)); test(!obj.ice_isConnectionCached()); var names = new List <string>(); names.Add("AdapterAMI51"); names.Add("AdapterAMI52"); names.Add("AdapterAMI53"); while (names.Count > 0) { names.Remove(getAdapterNameWithAMI(obj)); } com.deactivateObjectAdapter(adapters[0]); names.Add("AdapterAMI52"); names.Add("AdapterAMI53"); while (names.Count > 0) { names.Remove(getAdapterNameWithAMI(obj)); } com.deactivateObjectAdapter(adapters[2]); test(getAdapterNameWithAMI(obj).Equals("AdapterAMI52")); deactivate(com, adapters); } output.WriteLine("ok"); output.Write("testing per request binding and ordered endpoint selection... "); output.Flush(); { var adapters = new List <Test.RemoteObjectAdapterPrx>(); adapters.Add(com.createObjectAdapter("Adapter61", "default")); adapters.Add(com.createObjectAdapter("Adapter62", "default")); adapters.Add(com.createObjectAdapter("Adapter63", "default")); var obj = createTestIntfPrx(adapters); obj = Test.TestIntfPrxHelper.uncheckedCast(obj.ice_endpointSelection(Ice.EndpointSelectionType.Ordered)); test(obj.ice_getEndpointSelection() == Ice.EndpointSelectionType.Ordered); obj = Test.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(adapters[0]); for (i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter62"); i++) { ; } test(i == nRetry); com.deactivateObjectAdapter(adapters[1]); for (i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter63"); i++) { ; } test(i == nRetry); com.deactivateObjectAdapter(adapters[2]); try { obj.getAdapterName(); } catch (Ice.ConnectFailedException) { } catch (Ice.ConnectTimeoutException) { } Ice.Endpoint[] endpoints = obj.ice_getEndpoints(); adapters.Clear(); // // Now, re-activate the adapters with the same endpoints in the opposite // order. // adapters.Add(com.createObjectAdapter("Adapter66", endpoints[2].ToString())); for (i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter66"); i++) { ; } test(i == nRetry); adapters.Add(com.createObjectAdapter("Adapter65", endpoints[1].ToString())); for (i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter65"); i++) { ; } test(i == nRetry); adapters.Add(com.createObjectAdapter("Adapter64", endpoints[0].ToString())); for (i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter64"); i++) { ; } test(i == nRetry); deactivate(com, adapters); } output.WriteLine("ok"); output.Write("testing per request binding and ordered endpoint selection and AMI... "); output.Flush(); { var adapters = new List <Test.RemoteObjectAdapterPrx>(); adapters.Add(com.createObjectAdapter("AdapterAMI61", "default")); adapters.Add(com.createObjectAdapter("AdapterAMI62", "default")); adapters.Add(com.createObjectAdapter("AdapterAMI63", "default")); var obj = createTestIntfPrx(adapters); obj = Test.TestIntfPrxHelper.uncheckedCast(obj.ice_endpointSelection(Ice.EndpointSelectionType.Ordered)); test(obj.ice_getEndpointSelection() == Ice.EndpointSelectionType.Ordered); obj = Test.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(adapters[0]); for (i = 0; i < nRetry && getAdapterNameWithAMI(obj).Equals("AdapterAMI62"); i++) { ; } test(i == nRetry); com.deactivateObjectAdapter(adapters[1]); for (i = 0; i < nRetry && getAdapterNameWithAMI(obj).Equals("AdapterAMI63"); i++) { ; } test(i == nRetry); com.deactivateObjectAdapter(adapters[2]); try { obj.getAdapterName(); } catch (Ice.ConnectFailedException) { } catch (Ice.ConnectTimeoutException) { } Ice.Endpoint[] endpoints = obj.ice_getEndpoints(); adapters.Clear(); // // Now, re-activate the adapters with the same endpoints in the opposite // order. // adapters.Add(com.createObjectAdapter("AdapterAMI66", endpoints[2].ToString())); for (i = 0; i < nRetry && getAdapterNameWithAMI(obj).Equals("AdapterAMI66"); i++) { ; } test(i == nRetry); adapters.Add(com.createObjectAdapter("AdapterAMI65", endpoints[1].ToString())); for (i = 0; i < nRetry && getAdapterNameWithAMI(obj).Equals("AdapterAMI65"); i++) { ; } test(i == nRetry); adapters.Add(com.createObjectAdapter("AdapterAMI64", endpoints[0].ToString())); for (i = 0; i < nRetry && getAdapterNameWithAMI(obj).Equals("AdapterAMI64"); i++) { ; } test(i == nRetry); deactivate(com, adapters); } output.WriteLine("ok"); output.Write("testing endpoint mode filtering... "); output.Flush(); { var adapters = new List <Test.RemoteObjectAdapterPrx>(); adapters.Add(com.createObjectAdapter("Adapter71", "default")); adapters.Add(com.createObjectAdapter("Adapter72", "udp")); var obj = createTestIntfPrx(adapters); test(obj.getAdapterName().Equals("Adapter71")); var testUDP = Test.TestIntfPrxHelper.uncheckedCast(obj.ice_datagram()); test(obj.ice_getConnection() != testUDP.ice_getConnection()); try { testUDP.getAdapterName(); } catch (Ice.TwowayOnlyException) { } } output.WriteLine("ok"); if (communicator.getProperties().getProperty("Ice.Plugin.IceSSL").Length > 0) { output.Write("testing unsecure vs. secure endpoints... "); output.Flush(); { var adapters = new List <Test.RemoteObjectAdapterPrx>(); adapters.Add(com.createObjectAdapter("Adapter81", "ssl")); adapters.Add(com.createObjectAdapter("Adapter82", "tcp")); var obj = createTestIntfPrx(adapters); int i; for (i = 0; i < 5; i++) { test(obj.getAdapterName().Equals("Adapter82")); obj.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } var testSecure = Test.TestIntfPrxHelper.uncheckedCast(obj.ice_secure(true)); test(testSecure.ice_isSecure()); testSecure = Test.TestIntfPrxHelper.uncheckedCast(obj.ice_secure(false)); test(!testSecure.ice_isSecure()); testSecure = Test.TestIntfPrxHelper.uncheckedCast(obj.ice_secure(true)); test(testSecure.ice_isSecure()); test(obj.ice_getConnection() != testSecure.ice_getConnection()); com.deactivateObjectAdapter(adapters[1]); for (i = 0; i < 5; i++) { test(obj.getAdapterName().Equals("Adapter81")); obj.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } com.createObjectAdapter("Adapter83", (obj.ice_getEndpoints()[1]).ToString()); // Reactive tcp OA. for (i = 0; i < 5; i++) { test(obj.getAdapterName().Equals("Adapter83")); obj.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } com.deactivateObjectAdapter(adapters[0]); try { testSecure.ice_ping(); test(false); } catch (Ice.ConnectFailedException) { } catch (Ice.ConnectTimeoutException) { } deactivate(com, adapters); } output.WriteLine("ok"); } { output.Write("testing ipv4 & ipv6 connections... "); output.Flush(); Ice.Properties ipv4 = Ice.Util.createProperties(); ipv4.setProperty("Ice.IPv4", "1"); ipv4.setProperty("Ice.IPv6", "0"); ipv4.setProperty("Adapter.Endpoints", "tcp -h localhost"); Ice.Properties ipv6 = Ice.Util.createProperties(); ipv6.setProperty("Ice.IPv4", "0"); ipv6.setProperty("Ice.IPv6", "1"); ipv6.setProperty("Adapter.Endpoints", "tcp -h localhost"); Ice.Properties bothPreferIPv4 = Ice.Util.createProperties(); bothPreferIPv4.setProperty("Ice.IPv4", "1"); bothPreferIPv4.setProperty("Ice.IPv6", "1"); bothPreferIPv4.setProperty("Ice.PreferIPv6Address", "0"); bothPreferIPv4.setProperty("Adapter.Endpoints", "tcp -h localhost"); Ice.Properties bothPreferIPv6 = Ice.Util.createProperties(); bothPreferIPv6.setProperty("Ice.IPv4", "1"); bothPreferIPv6.setProperty("Ice.IPv6", "1"); bothPreferIPv6.setProperty("Ice.PreferIPv6Address", "1"); bothPreferIPv6.setProperty("Adapter.Endpoints", "tcp -h localhost"); List <Ice.Properties> clientProps = new List <Ice.Properties>(); clientProps.Add(ipv4); clientProps.Add(ipv6); clientProps.Add(bothPreferIPv4); clientProps.Add(bothPreferIPv6); string endpoint = "tcp -p " + helper.getTestPort(2).ToString(); Ice.Properties anyipv4 = ipv4.ice_clone_(); anyipv4.setProperty("Adapter.Endpoints", endpoint); anyipv4.setProperty("Adapter.PublishedEndpoints", endpoint + " -h 127.0.0.1"); Ice.Properties anyipv6 = ipv6.ice_clone_(); anyipv6.setProperty("Adapter.Endpoints", endpoint); anyipv6.setProperty("Adapter.PublishedEndpoints", endpoint + " -h \".1\""); Ice.Properties anyboth = Ice.Util.createProperties(); anyboth.setProperty("Ice.IPv4", "1"); anyboth.setProperty("Ice.IPv6", "1"); anyboth.setProperty("Adapter.Endpoints", endpoint); anyboth.setProperty("Adapter.PublishedEndpoints", endpoint + " -h \"::1\":" + endpoint + " -h 127.0.0.1"); Ice.Properties localipv4 = ipv4.ice_clone_(); localipv4.setProperty("Adapter.Endpoints", "tcp -h 127.0.0.1"); Ice.Properties localipv6 = ipv6.ice_clone_(); localipv6.setProperty("Adapter.Endpoints", "tcp -h \"::1\""); List <Ice.Properties> serverProps = new List <Ice.Properties>(clientProps); serverProps.Add(anyipv4); serverProps.Add(anyipv6); serverProps.Add(anyboth); serverProps.Add(localipv4); serverProps.Add(localipv6); bool ipv6NotSupported = false; foreach (Ice.Properties p in serverProps) { Ice.InitializationData serverInitData = new Ice.InitializationData(); serverInitData.properties = p; Ice.Communicator serverCommunicator = Ice.Util.initialize(serverInitData); Ice.ObjectAdapter oa; try { oa = serverCommunicator.createObjectAdapter("Adapter"); oa.activate(); } catch (Ice.DNSException) { serverCommunicator.destroy(); continue; // IP version not supported. } catch (Ice.SocketException) { if (p == ipv6) { ipv6NotSupported = true; } serverCommunicator.destroy(); continue; // IP version not supported. } Ice.ObjectPrx prx = oa.createProxy(Ice.Util.stringToIdentity("dummy")); try { prx.ice_collocationOptimized(false).ice_ping(); } catch (Ice.LocalException) { serverCommunicator.destroy(); continue; // IP version not supported. } string strPrx = prx.ToString(); foreach (Ice.Properties q in clientProps) { Ice.InitializationData clientInitData = new Ice.InitializationData(); clientInitData.properties = q; Ice.Communicator clientCommunicator = Ice.Util.initialize(clientInitData); prx = clientCommunicator.stringToProxy(strPrx); try { prx.ice_ping(); test(false); } catch (Ice.ObjectNotExistException) { // Expected, no object registered. } catch (Ice.DNSException) { // Expected if no IPv4 or IPv6 address is // associated to localhost or if trying to connect // to an any endpoint with the wrong IP version, // e.g.: resolving an IPv4 address when only IPv6 // is enabled fails with a DNS exception. } catch (Ice.SocketException) { test((p == ipv4 && q == ipv6) || (p == ipv6 && q == ipv4) || (p == bothPreferIPv4 && q == ipv6) || (p == bothPreferIPv6 && q == ipv4) || (p == bothPreferIPv6 && q == ipv6 && ipv6NotSupported) || (p == anyipv4 && q == ipv6) || (p == anyipv6 && q == ipv4) || (p == localipv4 && q == ipv6) || (p == localipv6 && q == ipv4) || (p == ipv6 && q == bothPreferIPv4) || (p == ipv6 && q == bothPreferIPv6) || (p == bothPreferIPv6 && q == ipv6)); } clientCommunicator.destroy(); } serverCommunicator.destroy(); } output.WriteLine("ok"); } com.shutdown(); }