public static void allTests(Test.TestHelper helper, List <int> ports) { Ice.Communicator communicator = helper.communicator(); var output = helper.getWriter(); output.Write("testing stringToProxy... "); output.Flush(); string refString = "test"; for (int i = 0; i < ports.Count; i++) { refString += ":" + helper.getTestEndpoint(ports[i]); } Ice.IObjectPrx basePrx = Ice.IObjectPrx.Parse(refString, communicator); test(basePrx != null); output.WriteLine("ok"); output.Write("testing checked cast... "); output.Flush(); ITestIntfPrx obj = ITestIntfPrx.CheckedCast(basePrx); test(obj != null); test(obj.Equals(basePrx)); output.WriteLine("ok"); int oldPid = 0; bool ami = false; for (int i = 1, j = 0; i <= ports.Count; ++i, ++j) { if (j > 3) { j = 0; ami = !ami; } if (!ami) { output.Write("testing server #" + i + "... "); output.Flush(); int pid = obj.pid(); test(pid != oldPid); output.WriteLine("ok"); oldPid = pid; } else { output.Write("testing server #" + i + " with AMI... "); output.Flush(); var pid = obj.pidAsync().Result; test(pid != oldPid); output.WriteLine("ok"); oldPid = pid; } if (j == 0) { if (!ami) { output.Write("shutting down server #" + i + "... "); output.Flush(); obj.shutdown(); output.WriteLine("ok"); } else { output.Write("shutting down server #" + i + " with AMI... "); obj.shutdownAsync().Wait(); output.WriteLine("ok"); } } else if (j == 1 || i + 1 > ports.Count) { if (!ami) { output.Write("aborting server #" + i + "... "); output.Flush(); try { obj.abort(); test(false); } catch (Ice.ConnectionLostException) { output.WriteLine("ok"); } catch (Ice.ConnectFailedException) { output.WriteLine("ok"); } catch (Ice.TransportException) { output.WriteLine("ok"); } } else { output.Write("aborting server #" + i + " with AMI... "); output.Flush(); try { obj.abortAsync().Wait(); test(false); } catch (AggregateException ex) { exceptAbortI(ex.InnerException, output); } output.WriteLine("ok"); } } else if (j == 2 || j == 3) { if (!ami) { output.Write("aborting server #" + i + " and #" + (i + 1) + " with idempotent call... "); output.Flush(); try { obj.idempotentAbort(); test(false); } catch (Ice.ConnectionLostException) { output.WriteLine("ok"); } catch (Ice.ConnectFailedException) { output.WriteLine("ok"); } catch (Ice.TransportException) { output.WriteLine("ok"); } } else { output.Write("aborting server #" + i + " and #" + (i + 1) + " with idempotent AMI call... "); output.Flush(); try { obj.idempotentAbortAsync().Wait(); test(false); } catch (AggregateException ex) { exceptAbortI(ex.InnerException, output); } output.WriteLine("ok"); } ++i; } else { Debug.Assert(false); } } output.Write("testing whether all servers are gone... "); output.Flush(); try { obj.IcePing(); test(false); } catch (System.Exception) { output.WriteLine("ok"); } }
allTestsWithDeploy(Test.TestHelper helper) { Ice.Communicator communicator = helper.communicator(); Console.Out.Write("testing stringToProxy... "); Console.Out.Flush(); IObjectPrx @base = IObjectPrx.Parse("test @ TestAdapter", communicator); test(@base != null); IObjectPrx @base2 = IObjectPrx.Parse("test", communicator); test(@base2 != null); Console.Out.WriteLine("ok"); Console.Out.Write("testing checked cast... "); Console.Out.Flush(); ITestIntfPrx obj = ITestIntfPrx.CheckedCast(@base); test(obj.Equals(@base)); ITestIntfPrx obj2 = ITestIntfPrx.CheckedCast(@base2); test(obj2.Equals(@base2)); Console.Out.WriteLine("ok"); Console.Out.Write("pinging server... "); Console.Out.Flush(); obj.IcePing(); obj2.IcePing(); Console.Out.WriteLine("ok"); Console.Out.Write("testing encoding versioning... "); Console.Out.Flush(); Console.Out.WriteLine("ok"); Console.Out.Write("testing reference with unknown identity... "); Console.Out.Flush(); try { IObjectPrx.Parse("unknown/unknown", communicator).IcePing(); test(false); } catch (NotRegisteredException ex) { test(ex.KindOfObject.Equals("object")); test(ex.Id.Equals("unknown/unknown")); } Console.Out.WriteLine("ok"); Console.Out.Write("testing reference with unknown adapter... "); Console.Out.Flush(); try { IObjectPrx.Parse("test @ TestAdapterUnknown", communicator).IcePing(); test(false); } catch (NotRegisteredException ex) { test(ex.KindOfObject.Equals("object adapter")); test(ex.Id.Equals("TestAdapterUnknown")); } Console.Out.WriteLine("ok"); IceGrid.IRegistryPrx registry = IceGrid.IRegistryPrx.Parse( communicator.GetDefaultLocator().Identity.Category + "/Registry", communicator); IceGrid.IAdminSessionPrx session = registry.CreateAdminSession("foo", "bar"); session.GetConnection().SetACM(registry.GetACMTimeout(), null, ACMHeartbeat.HeartbeatAlways); IceGrid.IAdminPrx admin = session.GetAdmin(); admin.EnableServer("server", false); admin.StopServer("server"); Console.Out.Write("testing whether server is still reachable... "); Console.Out.Flush(); try { obj = ITestIntfPrx.CheckedCast(@base); test(false); } catch (Ice.NoEndpointException) { } try { obj2 = ITestIntfPrx.CheckedCast(@base2); test(false); } catch (Ice.NoEndpointException) { } try { admin.EnableServer("server", true); } catch (IceGrid.ServerNotExistException) { test(false); } catch (IceGrid.NodeUnreachableException) { test(false); } try { obj = ITestIntfPrx.CheckedCast(@base); } catch (Ice.NoEndpointException) { test(false); } try { obj2 = ITestIntfPrx.CheckedCast(@base2); } catch (Ice.NoEndpointException) { test(false); } Console.Out.WriteLine("ok"); try { admin.StopServer("server"); } catch (IceGrid.ServerNotExistException) { test(false); } catch (IceGrid.ServerStopException) { test(false); } catch (IceGrid.NodeUnreachableException) { test(false); } session.Destroy(); }
public static ITestIntfPrx allTests(Test.TestHelper helper, bool collocated) { Communicator communicator = helper.communicator(); var output = helper.getWriter(); output.Write("testing stringToProxy... "); output.Flush(); string @ref = "Test:" + helper.getTestEndpoint(0) + " -t 2000"; var @base = IObjectPrx.Parse(@ref, communicator); test(@base != null); output.WriteLine("ok"); output.Write("testing checked cast... "); output.Flush(); ITestIntfPrx testPrx = ITestIntfPrx.CheckedCast(@base); test(testPrx != null); test(testPrx.Equals(@base)); output.WriteLine("ok"); output.Write("base... "); output.Flush(); { try { testPrx.baseAsBase(); test(false); } catch (Base b) { test(b.b.Equals("Base.b")); test(b.GetType().FullName.Equals("Test.Base")); } catch (System.Exception) { test(false); } } output.WriteLine("ok"); output.Write("base (AMI)... "); output.Flush(); { try { testPrx.baseAsBaseAsync().Wait(); test(false); } catch (AggregateException ae) { try { throw ae.InnerException; } catch (Base b) { test(b.b.Equals("Base.b")); test(b.GetType().Name.Equals("Base")); } catch (System.Exception) { test(false); } } } output.WriteLine("ok"); output.Write("slicing of unknown derived... "); output.Flush(); { try { testPrx.unknownDerivedAsBase(); test(false); } catch (Base b) { test(b.b.Equals("UnknownDerived.b")); test(b.GetType().FullName.Equals("Test.Base")); } catch (System.Exception) { test(false); } } output.WriteLine("ok"); output.Write("slicing of unknown derived (AMI)... "); output.Flush(); { try { testPrx.unknownDerivedAsBaseAsync().Wait(); test(false); } catch (AggregateException ae) { try { throw ae.InnerException; } catch (Base b) { test(b.b.Equals("UnknownDerived.b")); test(b.GetType().Name.Equals("Base")); } catch (System.Exception) { test(false); } } } output.WriteLine("ok"); output.Write("non-slicing of known derived as base... "); output.Flush(); { try { testPrx.knownDerivedAsBase(); test(false); } catch (KnownDerived k) { test(k.b.Equals("KnownDerived.b")); test(k.kd.Equals("KnownDerived.kd")); test(k.GetType().FullName.Equals("Test.KnownDerived")); } catch (System.Exception) { test(false); } } output.WriteLine("ok"); output.Write("non-slicing of known derived as base (AMI)... "); output.Flush(); { try { testPrx.knownDerivedAsBaseAsync().Wait(); test(false); } catch (AggregateException ae) { try { throw ae.InnerException; } catch (KnownDerived k) { test(k.b.Equals("KnownDerived.b")); test(k.kd.Equals("KnownDerived.kd")); test(k.GetType().Name.Equals("KnownDerived")); } catch (System.Exception) { test(false); } } } output.WriteLine("ok"); output.Write("non-slicing of known derived as derived... "); output.Flush(); { try { testPrx.knownDerivedAsKnownDerived(); test(false); } catch (KnownDerived k) { test(k.b.Equals("KnownDerived.b")); test(k.kd.Equals("KnownDerived.kd")); test(k.GetType().FullName.Equals("Test.KnownDerived")); } catch (System.Exception) { test(false); } } output.WriteLine("ok"); output.Write("non-slicing of known derived as derived (AMI)... "); output.Flush(); { try { testPrx.knownDerivedAsKnownDerivedAsync().Wait(); test(false); } catch (AggregateException ae) { try { throw ae.InnerException; } catch (KnownDerived k) { test(k.b.Equals("KnownDerived.b")); test(k.kd.Equals("KnownDerived.kd")); test(k.GetType().Name.Equals("KnownDerived")); } catch (System.Exception) { test(false); } } } output.WriteLine("ok"); output.Write("slicing of unknown intermediate as base... "); output.Flush(); { try { testPrx.unknownIntermediateAsBase(); test(false); } catch (Base b) { test(b.b.Equals("UnknownIntermediate.b")); test(b.GetType().FullName.Equals("Test.Base")); } catch (System.Exception) { test(false); } } output.WriteLine("ok"); output.Write("slicing of unknown intermediate as base (AMI)... "); output.Flush(); { try { testPrx.unknownIntermediateAsBaseAsync().Wait(); test(false); } catch (AggregateException ae) { try { throw ae.InnerException; } catch (Base b) { test(b.b.Equals("UnknownIntermediate.b")); test(b.GetType().Name.Equals("Base")); } catch (System.Exception) { test(false); } } } output.WriteLine("ok"); output.Write("slicing of known intermediate as base... "); output.Flush(); { try { testPrx.knownIntermediateAsBase(); test(false); } catch (KnownIntermediate ki) { test(ki.b.Equals("KnownIntermediate.b")); test(ki.ki.Equals("KnownIntermediate.ki")); test(ki.GetType().FullName.Equals("Test.KnownIntermediate")); } catch (System.Exception) { test(false); } } output.WriteLine("ok"); output.Write("slicing of known intermediate as base (AMI)... "); output.Flush(); { try { testPrx.knownIntermediateAsBaseAsync().Wait(); test(false); } catch (AggregateException ae) { try { throw ae.InnerException; } catch (KnownIntermediate ki) { test(ki.b.Equals("KnownIntermediate.b")); test(ki.ki.Equals("KnownIntermediate.ki")); test(ki.GetType().Name.Equals("KnownIntermediate")); } catch (System.Exception) { test(false); } } } output.WriteLine("ok"); output.Write("slicing of known most derived as base... "); output.Flush(); { try { testPrx.knownMostDerivedAsBase(); test(false); } catch (KnownMostDerived kmd) { test(kmd.b.Equals("KnownMostDerived.b")); test(kmd.ki.Equals("KnownMostDerived.ki")); test(kmd.kmd.Equals("KnownMostDerived.kmd")); test(kmd.GetType().FullName.Equals("Test.KnownMostDerived")); } catch (System.Exception) { test(false); } } output.WriteLine("ok"); output.Write("slicing of known most derived as base (AMI)... "); output.Flush(); { try { testPrx.knownMostDerivedAsBaseAsync().Wait(); test(false); } catch (AggregateException ae) { try { throw ae.InnerException; } catch (KnownMostDerived kmd) { test(kmd.b.Equals("KnownMostDerived.b")); test(kmd.ki.Equals("KnownMostDerived.ki")); test(kmd.kmd.Equals("KnownMostDerived.kmd")); test(kmd.GetType().Name.Equals("KnownMostDerived")); } catch (System.Exception) { test(false); } } } output.WriteLine("ok"); output.Write("non-slicing of known intermediate as intermediate... "); output.Flush(); { try { testPrx.knownIntermediateAsKnownIntermediate(); test(false); } catch (KnownIntermediate ki) { test(ki.b.Equals("KnownIntermediate.b")); test(ki.ki.Equals("KnownIntermediate.ki")); test(ki.GetType().FullName.Equals("Test.KnownIntermediate")); } catch (System.Exception) { test(false); } } output.WriteLine("ok"); output.Write("non-slicing of known intermediate as intermediate (AMI)... "); output.Flush(); { try { testPrx.knownIntermediateAsKnownIntermediateAsync().Wait(); test(false); } catch (AggregateException ae) { try { throw ae.InnerException; } catch (KnownIntermediate ki) { test(ki.b.Equals("KnownIntermediate.b")); test(ki.ki.Equals("KnownIntermediate.ki")); test(ki.GetType().Name.Equals("KnownIntermediate")); } catch (System.Exception) { test(false); } } } output.WriteLine("ok"); output.Write("non-slicing of known most derived as intermediate... "); output.Flush(); { try { testPrx.knownMostDerivedAsKnownIntermediate(); test(false); } catch (KnownMostDerived kmd) { test(kmd.b.Equals("KnownMostDerived.b")); test(kmd.ki.Equals("KnownMostDerived.ki")); test(kmd.kmd.Equals("KnownMostDerived.kmd")); test(kmd.GetType().FullName.Equals("Test.KnownMostDerived")); } catch (System.Exception) { test(false); } } output.WriteLine("ok"); output.Write("non-slicing of known most derived as intermediate (AMI)... "); output.Flush(); { try { testPrx.knownMostDerivedAsKnownIntermediateAsync().Wait(); test(false); } catch (AggregateException ae) { try { throw ae.InnerException; } catch (KnownMostDerived kmd) { test(kmd.b.Equals("KnownMostDerived.b")); test(kmd.ki.Equals("KnownMostDerived.ki")); test(kmd.kmd.Equals("KnownMostDerived.kmd")); test(kmd.GetType().Name.Equals("KnownMostDerived")); } catch (System.Exception) { test(false); } } } output.WriteLine("ok"); output.Write("non-slicing of known most derived as most derived... "); output.Flush(); { try { testPrx.knownMostDerivedAsKnownMostDerived(); test(false); } catch (KnownMostDerived kmd) { test(kmd.b.Equals("KnownMostDerived.b")); test(kmd.ki.Equals("KnownMostDerived.ki")); test(kmd.kmd.Equals("KnownMostDerived.kmd")); test(kmd.GetType().FullName.Equals("Test.KnownMostDerived")); } catch (System.Exception) { test(false); } } output.WriteLine("ok"); output.Write("non-slicing of known most derived as most derived (AMI)... "); output.Flush(); { try { testPrx.knownMostDerivedAsKnownMostDerivedAsync().Wait(); test(false); } catch (AggregateException ae) { try { throw ae.InnerException; } catch (KnownMostDerived kmd) { test(kmd.b.Equals("KnownMostDerived.b")); test(kmd.ki.Equals("KnownMostDerived.ki")); test(kmd.kmd.Equals("KnownMostDerived.kmd")); test(kmd.GetType().Name.Equals("KnownMostDerived")); } catch (System.Exception) { test(false); } } } output.WriteLine("ok"); output.Write("slicing of unknown most derived, known intermediate as base... "); output.Flush(); { try { testPrx.unknownMostDerived1AsBase(); test(false); } catch (KnownIntermediate ki) { test(ki.b.Equals("UnknownMostDerived1.b")); test(ki.ki.Equals("UnknownMostDerived1.ki")); test(ki.GetType().FullName.Equals("Test.KnownIntermediate")); } catch (System.Exception) { test(false); } } output.WriteLine("ok"); output.Write("slicing of unknown most derived, known intermediate as base (AMI)... "); output.Flush(); { try { testPrx.unknownMostDerived1AsBaseAsync().Wait(); test(false); } catch (AggregateException ae) { try { throw ae.InnerException; } catch (KnownIntermediate ki) { test(ki.b.Equals("UnknownMostDerived1.b")); test(ki.ki.Equals("UnknownMostDerived1.ki")); test(ki.GetType().Name.Equals("KnownIntermediate")); } catch (System.Exception) { test(false); } } } output.WriteLine("ok"); output.Write("slicing of unknown most derived, known intermediate as intermediate... "); output.Flush(); { try { testPrx.unknownMostDerived1AsKnownIntermediate(); test(false); } catch (KnownIntermediate ki) { test(ki.b.Equals("UnknownMostDerived1.b")); test(ki.ki.Equals("UnknownMostDerived1.ki")); test(ki.GetType().FullName.Equals("Test.KnownIntermediate")); } catch (System.Exception) { test(false); } } output.WriteLine("ok"); output.Write("slicing of unknown most derived, known intermediate as intermediate (AMI)... "); output.Flush(); { try { testPrx.unknownMostDerived1AsKnownIntermediateAsync().Wait(); test(false); } catch (AggregateException ae) { try { throw ae.InnerException; } catch (KnownIntermediate ki) { test(ki.b.Equals("UnknownMostDerived1.b")); test(ki.ki.Equals("UnknownMostDerived1.ki")); test(ki.GetType().Name.Equals("KnownIntermediate")); } catch (System.Exception) { test(false); } } } output.WriteLine("ok"); output.Write("slicing of unknown most derived, unknown intermediate thrown as base... "); output.Flush(); { try { testPrx.unknownMostDerived2AsBase(); test(false); } catch (Base b) { test(b.b.Equals("UnknownMostDerived2.b")); test(b.GetType().FullName.Equals("Test.Base")); } catch (System.Exception) { test(false); } } output.WriteLine("ok"); output.Write("slicing of unknown most derived, unknown intermediate thrown as base (AMI)... "); output.Flush(); { try { testPrx.unknownMostDerived2AsBaseAsync().Wait(); test(false); } catch (AggregateException ae) { try { throw ae.InnerException; } catch (Base b) { test(b.b.Equals("UnknownMostDerived2.b")); test(b.GetType().Name.Equals("Base")); } catch (System.Exception) { test(false); } } } output.WriteLine("ok"); output.Write("unknown most derived in compact format... "); output.Flush(); { try { testPrx.unknownMostDerived2AsBaseCompact(); test(false); } catch (Base) { test(false); } catch (Ice.UnknownUserException) { // // A MarshalException is raised for the compact format because the // most-derived type is unknown and the exception cannot be sliced. // } catch (Ice.OperationNotExistException) { } catch (System.Exception) { test(false); } } output.WriteLine("ok"); output.Write("preserved exceptions... "); output.Flush(); { try { testPrx.unknownPreservedAsBase(); test(false); } catch (Base ex) { IReadOnlyList <Ice.SliceInfo> slices = ex.GetSlicedData().Value.Slices; test(slices.Count == 2); test(slices[1].TypeId.Equals("::Test::SPreserved1")); test(slices[0].TypeId.Equals("::Test::SPreserved2")); } try { testPrx.unknownPreservedAsKnownPreserved(); test(false); } catch (KnownPreserved ex) { test(ex.kp.Equals("preserved")); IReadOnlyList <Ice.SliceInfo> slices = ex.GetSlicedData().Value.Slices; test(slices.Count == 2); test(slices[1].TypeId.Equals("::Test::SPreserved1")); test(slices[0].TypeId.Equals("::Test::SPreserved2")); } ObjectAdapter adapter = communicator.CreateObjectAdapter(""); IRelayPrx relay = adapter.Add(new Relay(), IRelayPrx.Factory); adapter.Activate(); testPrx.GetConnection().SetAdapter(adapter); try { testPrx.relayKnownPreservedAsBase(relay); test(false); } catch (KnownPreservedDerived ex) { test(ex.b.Equals("base")); test(ex.kp.Equals("preserved")); test(ex.kpd.Equals("derived")); } catch (Ice.OperationNotExistException) { } catch (System.Exception) { test(false); } try { testPrx.relayKnownPreservedAsKnownPreserved(relay); test(false); } catch (KnownPreservedDerived ex) { test(ex.b.Equals("base")); test(ex.kp.Equals("preserved")); test(ex.kpd.Equals("derived")); } catch (Ice.OperationNotExistException) { } catch (System.Exception) { test(false); } try { testPrx.relayUnknownPreservedAsBase(relay); test(false); } catch (Preserved2 ex) { test(ex.b.Equals("base")); test(ex.kp.Equals("preserved")); test(ex.kpd.Equals("derived")); test(ex.p1.GetType().GetIceTypeId().Equals(typeof(PreservedClass).GetIceTypeId())); PreservedClass pc = ex.p1 as PreservedClass; test(pc.bc.Equals("bc")); test(pc.pc.Equals("pc")); test(ex.p2 == ex.p1); } catch (Ice.OperationNotExistException) { } catch (System.Exception) { test(false); } try { testPrx.relayUnknownPreservedAsKnownPreserved(relay); test(false); } catch (Preserved2 ex) { test(ex.b.Equals("base")); test(ex.kp.Equals("preserved")); test(ex.kpd.Equals("derived")); test(ex.p1.GetType().GetIceTypeId().Equals(typeof(PreservedClass).GetIceTypeId())); PreservedClass pc = ex.p1 as PreservedClass; test(pc.bc.Equals("bc")); test(pc.pc.Equals("pc")); test(ex.p2 == ex.p1); } catch (Ice.OperationNotExistException) { } catch (System.Exception) { test(false); } adapter.Destroy(); } output.WriteLine("ok"); return(testPrx); }
public static void allTests(TestHelper helper) { Communicator communicator = helper.communicator(); Console.Out.Write("testing stringToProxy... "); Console.Out.Flush(); string rf = "test @ TestAdapter"; var @base = IObjectPrx.Parse(rf, communicator); Console.Out.WriteLine("ok"); Console.Out.Write("testing IceGrid.Locator is present... "); IceGrid.ILocatorPrx locator = IceGrid.ILocatorPrx.UncheckedCast(@base); Console.Out.WriteLine("ok"); Console.Out.Write("testing checked cast... "); Console.Out.Flush(); ITestIntfPrx obj = ITestIntfPrx.CheckedCast(@base); test(obj.Equals(@base)); Console.Out.WriteLine("ok"); Console.Out.Write("pinging server... "); Console.Out.Flush(); obj.IcePing(); Console.Out.WriteLine("ok"); Console.Out.Write("testing locator finder... "); Identity finderId = new Identity("LocatorFinder", "Ice"); ILocatorFinderPrx finder = ILocatorFinderPrx.CheckedCast(communicator.GetDefaultLocator().Clone(finderId)); test(finder.GetLocator() != null); Console.Out.WriteLine("ok"); Console.Out.Write("testing discovery... "); { // Add test well-known object IceGrid.IRegistryPrx registry = IceGrid.IRegistryPrx.Parse( communicator.GetDefaultLocator().Identity.Category + "/Registry", communicator); IceGrid.IAdminSessionPrx session = registry.CreateAdminSession("foo", "bar"); session.GetAdmin().AddObjectWithType(@base, "::Test"); session.Destroy(); // // Ensure the IceGrid discovery locator can discover the // registries and make sure locator requests are forwarded. // var properties = communicator.GetProperties(); properties.Remove("Ice.Default.Locator"); properties["Ice.Plugin.IceLocatorDiscovery"] = "IceLocatorDiscovery:IceLocatorDiscovery.PluginFactory"; properties["IceLocatorDiscovery.Port"] = helper.getTestPort(99).ToString(); properties["AdapterForDiscoveryTest.AdapterId"] = "discoveryAdapter"; properties["AdapterForDiscoveryTest.Endpoints"] = "default"; Communicator com = new Communicator(properties); test(com.GetDefaultLocator() != null); IObjectPrx.Parse("test @ TestAdapter", com).IcePing(); IObjectPrx.Parse("test", com).IcePing(); test(com.GetDefaultLocator().GetRegistry() != null); test(IceGrid.ILocatorPrx.UncheckedCast(com.GetDefaultLocator()).GetLocalRegistry() != null); test(IceGrid.ILocatorPrx.UncheckedCast(com.GetDefaultLocator()).GetLocalQuery() != null); Ice.ObjectAdapter adapter = com.CreateObjectAdapter("AdapterForDiscoveryTest"); adapter.Activate(); adapter.Deactivate(); com.Destroy(); // // Now, ensure that the IceGrid discovery locator correctly // handles failure to find a locator. // properties["IceLocatorDiscovery.InstanceName"] = "unknown"; properties["IceLocatorDiscovery.RetryCount"] = "1"; properties["IceLocatorDiscovery.Timeout"] = "100"; com = new Communicator(properties); test(com.GetDefaultLocator() != null); try { IObjectPrx.Parse("test @ TestAdapter", com).IcePing(); } catch (NoEndpointException) { } try { IObjectPrx.Parse("test", com).IcePing(); } catch (NoEndpointException) { } test(com.GetDefaultLocator().GetRegistry() == null); test(IceGrid.ILocatorPrx.CheckedCast(com.GetDefaultLocator()) == null); try { IceGrid.ILocatorPrx.UncheckedCast(com.GetDefaultLocator()).GetLocalRegistry(); } catch (Ice.OperationNotExistException) { } adapter = com.CreateObjectAdapter("AdapterForDiscoveryTest"); adapter.Activate(); adapter.Deactivate(); com.Destroy(); string multicast; if (communicator.GetProperty("Ice.IPv6") == "1") { multicast = "\"ff15::1\""; } else { multicast = "239.255.0.1"; } // // Test invalid lookup endpoints // properties = communicator.GetProperties(); properties.Remove("Ice.Default.Locator"); properties["Ice.Plugin.IceLocatorDiscovery"] = "IceLocatorDiscovery:IceLocatorDiscovery.PluginFactory"; properties["IceLocatorDiscovery.Lookup"] = $"udp -h {multicast} --interface unknown"; com = new Communicator(properties); test(com.GetDefaultLocator() != null); try { IObjectPrx.Parse("test @ TestAdapter", com).IcePing(); test(false); } catch (NoEndpointException) { } com.Destroy(); properties = communicator.GetProperties(); properties.Remove("Ice.Default.Locator"); properties["IceLocatorDiscovery.RetryCount"] = "0"; properties["Ice.Plugin.IceLocatorDiscovery"] = "IceLocatorDiscovery:IceLocatorDiscovery.PluginFactory"; properties["IceLocatorDiscovery.Lookup"] = $"udp -h {multicast} --interface unknown"; com = new Communicator(properties); test(com.GetDefaultLocator() != null); try { IObjectPrx.Parse("test @ TestAdapter", com).IcePing(); test(false); } catch (NoEndpointException) { } com.Destroy(); properties = communicator.GetProperties(); properties.Remove("Ice.Default.Locator"); properties["IceLocatorDiscovery.RetryCount"] = "1"; properties["Ice.Plugin.IceLocatorDiscovery"] = "IceLocatorDiscovery:IceLocatorDiscovery.PluginFactory"; { string intf = communicator.GetProperty("IceLocatorDiscovery.Interface") ?? ""; if (intf != "") { intf = $" --interface \"{intf}\""; } string port = helper.getTestPort(99).ToString(); properties["IceLocatorDiscovery.Lookup"] = $"udp -h {multicast} --interface unknown:udp -h {multicast} -p {port}{intf}"; } com = new Communicator(properties); test(com.GetDefaultLocator() != null); try { IObjectPrx.Parse("test @ TestAdapter", com).IcePing(); } catch (NoEndpointException) { test(false); } com.Destroy(); } Console.Out.WriteLine("ok"); Console.Out.Write("shutting down server... "); Console.Out.Flush(); obj.shutdown(); Console.Out.WriteLine("ok"); }