public override void run(string[] args) { var properties = createTestProperties(ref args); properties["Ice.Default.Host"] = "127.0.0.1"; using (var communicator = initialize(properties)) { AllTests.allTests(this); // // Shutdown the IceBox server. // IProcessPrx.Parse("DemoIceBox/admin -f Process:default -p 9996", communicator).Shutdown(); } }
public override async Task RunAsync(string[] args) { Dictionary <string, string>?properties = CreateTestProperties(ref args); await using Communicator communicator = Initialize(properties); AllTests.Run(this); // Shutdown the IceBox server. string transport = communicator.DefaultTransport.ToString().ToLowerInvariant(); await IProcessPrx.Parse(communicator.DefaultProtocol == Protocol.Ice1? $"DemoIceBox/admin -f Process:{transport} -h 127.0.0.1 -p 9996" : $"ice+{transport}://127.0.0.1:9996/DemoIceBox/admin#Process", communicator).ShutdownAsync(); }
public static void Run(TestHelper helper) { Communicator?communicator = helper.Communicator(); TestHelper.Assert(communicator != null); TextWriter output = helper.GetWriter(); bool ice1 = communicator.DefaultProtocol == Protocol.Ice1; output.Write("testing communicator operations... "); output.Flush(); { // Test: Exercise AddAdminFacet, FindAdminFacet, RemoveAdminFacet with a typical configuration. var properties = new Dictionary <string, string> { ["Ice.Admin.Endpoints"] = ice1 ? "tcp -h 127.0.0.1" : "ice+tcp://127.0.0.1:0", ["Ice.Admin.InstanceName"] = "Test" }; using var com = new Communicator(properties); TestFacets(com, true, false); } { // Test: Verify that the operations work correctly in the presence of facet filters. var properties = new Dictionary <string, string> { ["Ice.Admin.Endpoints"] = ice1 ? "tcp -h 127.0.0.1" : "ice+tcp://127.0.0.1:0", ["Ice.Admin.InstanceName"] = "Test", ["Ice.Admin.Facets"] = "Properties" }; using var com = new Communicator(properties); TestFacets(com, false, true); } { // Test: Verify that the operations work correctly with the Admin object disabled. using var com = new Communicator(); TestFacets(com, false, false); } { // Test: Verify that the operations work correctly with Ice.Admin.Enabled=1 var properties = new Dictionary <string, string>() { { "Ice.Admin.Enabled", "1" } }; using var com = new Communicator(properties); TestHelper.Assert(com.GetAdmin() == null); var id = Identity.Parse("test-admin"); try { com.CreateAdmin(null, id); TestHelper.Assert(false); } catch (InvalidConfigurationException) { } ObjectAdapter adapter = com.CreateObjectAdapter(); TestHelper.Assert(com.CreateAdmin(adapter, id) != null); TestHelper.Assert(com.GetAdmin() != null); TestFacets(com, true, false); } { // Test: Verify that the operations work correctly when creation of the Admin object is delayed. var properties = new Dictionary <string, string>() { { "Ice.Admin.Endpoints", ice1 ? "tcp -h 127.0.0.1" : "ice+tcp://127.0.0.1:0" }, { "Ice.Admin.InstanceName", "Test" }, { "Ice.Admin.DelayCreation", "1" } }; using var com = new Communicator(properties); TestFacets(com, true, false); com.GetAdmin(); TestFacets(com, true, false); } output.WriteLine("ok"); var factory = IRemoteCommunicatorFactoryPrx.Parse(helper.GetTestProxy("factory", 0), communicator); output.Write("testing process facet... "); output.Flush(); { // Test: Verify that Process.Shutdown() operation shuts down the communicator. var props = new Dictionary <string, string> { { "Ice.Admin.Endpoints", ice1 ? "tcp -h 127.0.0.1" : "ice+tcp://127.0.0.1:0" }, { "Ice.Admin.InstanceName", "Test" } }; IRemoteCommunicatorPrx?com = factory.CreateCommunicator(props); TestHelper.Assert(com != null); IObjectPrx?obj = com.GetAdmin(); TestHelper.Assert(obj != null); IProcessPrx proc = obj.Clone("Process", IProcessPrx.Factory); proc.Shutdown(); com.WaitForShutdown(); com.Destroy(); } output.WriteLine("ok"); output.Write("testing properties facet... "); output.Flush(); { var props = new Dictionary <string, string> { { "Ice.Admin.Endpoints", ice1 ? "tcp -h 127.0.0.1" : "ice+tcp://127.0.0.1:0" }, { "Ice.Admin.InstanceName", "Test" }, { "Prop1", "1" }, { "Prop2", "2" }, { "Prop3", "3" } }; IRemoteCommunicatorPrx?com = factory.CreateCommunicator(props); TestHelper.Assert(com != null); IObjectPrx?obj = com.GetAdmin(); TestHelper.Assert(obj != null); IPropertiesAdminPrx pa = obj.Clone("Properties", IPropertiesAdminPrx.Factory); // Test: PropertiesAdmin.GetProperty() TestHelper.Assert(pa.GetProperty("Prop2") == "2"); TestHelper.Assert(pa.GetProperty("Bogus").Length == 0); // Test: PropertiesAdmin.GetProperties() Dictionary <string, string> pd = pa.GetPropertiesForPrefix(""); TestHelper.Assert(pd.Count == 7); TestHelper.Assert(pd["Ice.ProgramName"] == "server"); TestHelper.Assert(pd["Ice.Admin.Endpoints"] == (ice1 ? "tcp -h 127.0.0.1" : "ice+tcp://127.0.0.1:0")); TestHelper.Assert(pd["Ice.Admin.InstanceName"] == "Test"); TestHelper.Assert(pd["Prop1"] == "1"); TestHelper.Assert(pd["Prop2"] == "2"); TestHelper.Assert(pd["Prop3"] == "3"); TestHelper.Assert(pd["Ice.Default.Protocol"] == communicator.DefaultProtocol.GetName()); Dictionary <string, string> changes; // Test: PropertiesAdmin.SetProperties() var setProps = new Dictionary <string, string> { { "Prop1", "10" }, // Changed { "Prop2", "20" }, // Changed { "Prop3", "" }, // Removed { "Prop4", "4" }, // Added { "Prop5", "5" } // Added }; pa.SetProperties(setProps); TestHelper.Assert(pa.GetProperty("Prop1").Equals("10")); TestHelper.Assert(pa.GetProperty("Prop2").Equals("20")); TestHelper.Assert(pa.GetProperty("Prop3").Length == 0); TestHelper.Assert(pa.GetProperty("Prop4").Equals("4")); TestHelper.Assert(pa.GetProperty("Prop5").Equals("5")); changes = com.GetChanges(); TestHelper.Assert(changes.Count == 5); TestHelper.Assert(changes["Prop1"].Equals("10")); TestHelper.Assert(changes["Prop2"].Equals("20")); TestHelper.Assert(changes["Prop3"].Length == 0); TestHelper.Assert(changes["Prop4"].Equals("4")); TestHelper.Assert(changes["Prop5"].Equals("5")); pa.SetProperties(setProps); changes = com.GetChanges(); TestHelper.Assert(changes.Count == 0); com.Destroy(); } output.WriteLine("ok"); output.Write("testing logger facet... "); output.Flush(); { var props = new Dictionary <string, string> { { "Ice.Admin.Endpoints", ice1 ? "tcp -h 127.0.0.1" : "ice+tcp://127.0.0.1:0" }, { "Ice.Admin.InstanceName", "Test" }, { "NullLogger", "1" } }; IRemoteCommunicatorPrx?com = factory.CreateCommunicator(props); TestHelper.Assert(com != null); com.Trace("testCat", "trace"); com.Warning("warning"); com.Error("error"); com.Print("print"); IObjectPrx?obj = com.GetAdmin(); TestHelper.Assert(obj != null); ILoggerAdminPrx logger = obj.Clone("Logger", ILoggerAdminPrx.Factory); // Get all (LogMessage[] logMessages, string prefix) = logger.GetLog(Array.Empty <LogMessageType>(), Array.Empty <string>(), -1); TestHelper.Assert(logMessages.Length == 4); TestHelper.Assert(prefix.Equals("NullLogger")); TestHelper.Assert(logMessages[0].TraceCategory.Equals("testCat") && logMessages[0].Message.Equals("trace")); TestHelper.Assert(logMessages[1].Message.Equals("warning")); TestHelper.Assert(logMessages[2].Message.Equals("error")); TestHelper.Assert(logMessages[3].Message.Equals("print")); // Get only errors and warnings com.Error("error2"); com.Print("print2"); com.Trace("testCat", "trace2"); com.Warning("warning2"); LogMessageType[] messageTypes = { LogMessageType.ErrorMessage, LogMessageType.WarningMessage }; (logMessages, prefix) = logger.GetLog(messageTypes, Array.Empty <string>(), -1); TestHelper.Assert(logMessages.Length == 4); TestHelper.Assert(prefix.Equals("NullLogger")); foreach (LogMessage msg in logMessages) { TestHelper.Assert(msg.Type == LogMessageType.ErrorMessage || msg.Type == LogMessageType.WarningMessage); } // Get only errors and traces with Cat = "testCat" com.Trace("testCat2", "A"); com.Trace("testCat", "trace3"); com.Trace("testCat2", "B"); messageTypes = new LogMessageType[] { LogMessageType.ErrorMessage, LogMessageType.TraceMessage }; string[] categories = { "testCat" }; (logMessages, prefix) = logger.GetLog(messageTypes, categories, -1); TestHelper.Assert(logMessages.Length == 5); TestHelper.Assert(prefix.Equals("NullLogger")); foreach (LogMessage msg in logMessages) { TestHelper.Assert(msg.Type == LogMessageType.ErrorMessage || (msg.Type == LogMessageType.TraceMessage && msg.TraceCategory.Equals("testCat"))); } // Same, but limited to last 2 messages(trace3 + error3) com.Error("error3"); (logMessages, prefix) = logger.GetLog(messageTypes, categories, 2); TestHelper.Assert(logMessages.Length == 2); TestHelper.Assert(prefix.Equals("NullLogger")); TestHelper.Assert(logMessages[0].Message.Equals("trace3")); TestHelper.Assert(logMessages[1].Message.Equals("error3")); // Now, test RemoteLogger ObjectAdapter adapter = communicator.CreateObjectAdapterWithEndpoints("RemoteLoggerAdapter", ice1 ? "tcp -h localhost" : "ice+tcp://localhost:0", serializeDispatch: true); var remoteLogger = new RemoteLogger(); IRemoteLoggerPrx myProxy = adapter.AddWithUUID(remoteLogger, IRemoteLoggerPrx.Factory); adapter.Activate(); // No filtering (logMessages, prefix) = logger.GetLog(Array.Empty <LogMessageType>(), Array.Empty <string>(), -1); logger.AttachRemoteLogger(myProxy, Array.Empty <LogMessageType>(), Array.Empty <string>(), -1); remoteLogger.Wait(1); foreach (LogMessage m in logMessages) { remoteLogger.CheckNextInit(prefix, m.Type, m.Message, m.TraceCategory); } com.Trace("testCat", "rtrace"); com.Warning("rwarning"); com.Error("rerror"); com.Print("rprint"); remoteLogger.Wait(4); remoteLogger.CheckNextLog(LogMessageType.TraceMessage, "rtrace", "testCat"); remoteLogger.CheckNextLog(LogMessageType.WarningMessage, "rwarning", ""); remoteLogger.CheckNextLog(LogMessageType.ErrorMessage, "rerror", ""); remoteLogger.CheckNextLog(LogMessageType.PrintMessage, "rprint", ""); TestHelper.Assert(logger.DetachRemoteLogger(myProxy)); TestHelper.Assert(!logger.DetachRemoteLogger(myProxy)); // Use Error + Trace with "traceCat" filter with 4 limit (logMessages, prefix) = logger.GetLog(messageTypes, categories, 4); TestHelper.Assert(logMessages.Length == 4); logger.AttachRemoteLogger(myProxy, messageTypes, categories, 4); remoteLogger.Wait(1); foreach (LogMessage m in logMessages) { remoteLogger.CheckNextInit(prefix, m.Type, m.Message, m.TraceCategory); } com.Warning("rwarning2"); com.Trace("testCat", "rtrace2"); com.Warning("rwarning3"); com.Error("rerror2"); com.Print("rprint2"); remoteLogger.Wait(2); remoteLogger.CheckNextLog(LogMessageType.TraceMessage, "rtrace2", "testCat"); remoteLogger.CheckNextLog(LogMessageType.ErrorMessage, "rerror2", ""); // Attempt reconnection with slightly different proxy try { logger.AttachRemoteLogger(myProxy.Clone(oneway: true), messageTypes, categories, 4); TestHelper.Assert(false); } catch (RemoteLoggerAlreadyAttachedException) { // expected } com.Destroy(); } output.WriteLine("ok"); output.Write("testing custom facet... "); output.Flush(); { // Test: Verify that the custom facet is present. var props = new Dictionary <string, string> { { "Ice.Admin.Endpoints", ice1 ? "tcp -h 127.0.0.1" : "ice+tcp://127.0.0.1:0" }, { "Ice.Admin.InstanceName", "Test" } }; IRemoteCommunicatorPrx?com = factory.CreateCommunicator(props); TestHelper.Assert(com != null); IObjectPrx?obj = com.GetAdmin(); TestHelper.Assert(obj != null); ITestFacetPrx tf = obj.Clone("TestFacet", ITestFacetPrx.Factory); tf.Op(); com.Destroy(); } output.WriteLine("ok"); output.Write("testing facet filtering... "); output.Flush(); { // Test: Set Ice.Admin.Facets to expose only the Properties facet, meaning no other facet is available. var props = new Dictionary <string, string> { { "Ice.Admin.Endpoints", ice1 ? "tcp -h 127.0.0.1" : "ice+tcp://127.0.0.1:0" }, { "Ice.Admin.InstanceName", "Test" }, { "Ice.Admin.Facets", "Properties" } }; IRemoteCommunicatorPrx?com = factory.CreateCommunicator(props); TestHelper.Assert(com != null); IObjectPrx?obj = com.GetAdmin(); TestHelper.Assert(obj != null); try { IProcessPrx.CheckedCast(obj.Clone(facet: "Process", IObjectPrx.Factory)); TestHelper.Assert(false); } catch (ObjectNotExistException) { } try { ITestFacetPrx.CheckedCast(obj.Clone(facet: "TestFacet", IObjectPrx.Factory)); TestHelper.Assert(false); } catch (ObjectNotExistException) { } com.Destroy(); } { // Test: Set Ice.Admin.Facets to expose only the Process facet, meaning no other facet is available. var props = new Dictionary <string, string> { { "Ice.Admin.Endpoints", ice1 ? "tcp -h 127.0.0.1" : "ice+tcp://127.0.0.1:0" }, { "Ice.Admin.InstanceName", "Test" }, { "Ice.Admin.Facets", "Process" } }; IRemoteCommunicatorPrx?com = factory.CreateCommunicator(props); TestHelper.Assert(com != null); IObjectPrx?obj = com.GetAdmin(); TestHelper.Assert(obj != null); try { IPropertiesAdminPrx.CheckedCast(obj.Clone(facet: "Properties", IObjectPrx.Factory)); TestHelper.Assert(false); } catch (ObjectNotExistException) { } try { ITestFacetPrx.CheckedCast(obj.Clone(facet: "TestFacet", IObjectPrx.Factory)); TestHelper.Assert(false); } catch (ObjectNotExistException) { } com.Destroy(); } { // Test: Set Ice.Admin.Facets to expose only the TestFacet facet, meaning no other facet is available. var props = new Dictionary <string, string> { { "Ice.Admin.Endpoints", ice1 ? "tcp -h 127.0.0.1" : "ice+tcp://127.0.0.1:0" }, { "Ice.Admin.InstanceName", "Test" }, { "Ice.Admin.Facets", "TestFacet" } }; IRemoteCommunicatorPrx?com = factory.CreateCommunicator(props); TestHelper.Assert(com != null); IObjectPrx?obj = com.GetAdmin(); TestHelper.Assert(obj != null); try { IPropertiesAdminPrx.CheckedCast(obj.Clone(facet: "Properties", IObjectPrx.Factory)); TestHelper.Assert(false); } catch (ObjectNotExistException) { } try { IProcessPrx.CheckedCast(obj.Clone(facet: "Process", IObjectPrx.Factory)); TestHelper.Assert(false); } catch (ObjectNotExistException) { } com.Destroy(); } { // Test: Set Ice.Admin.Facets to expose two facets. Use whitespace to separate the facet names. var props = new Dictionary <string, string> { { "Ice.Admin.Endpoints", ice1 ? "tcp -h 127.0.0.1" : "ice+tcp://127.0.0.1:0" }, { "Ice.Admin.InstanceName", "Test" }, { "Ice.Admin.Facets", "Properties TestFacet" } }; IRemoteCommunicatorPrx?com = factory.CreateCommunicator(props); TestHelper.Assert(com != null); IObjectPrx?obj = com.GetAdmin(); TestHelper.Assert(obj != null); IPropertiesAdminPrx pa = obj.Clone("Properties", IPropertiesAdminPrx.Factory); TestHelper.Assert(pa.GetProperty("Ice.Admin.InstanceName").Equals("Test")); var tf = ITestFacetPrx.CheckedCast(obj.Clone(facet: "TestFacet", IObjectPrx.Factory)); tf !.Op(); try { IProcessPrx.CheckedCast(obj.Clone(facet: "Process", IObjectPrx.Factory)); TestHelper.Assert(false); } catch (ObjectNotExistException) { } com.Destroy(); } { // Test: Set Ice.Admin.Facets to expose two facets. Use a comma to separate the facet names. var props = new Dictionary <string, string> { { "Ice.Admin.Endpoints", ice1 ? "tcp -h 127.0.0.1" : "ice+tcp://127.0.0.1:0" }, { "Ice.Admin.InstanceName", "Test" }, { "Ice.Admin.Facets", "TestFacet, Process" } }; IRemoteCommunicatorPrx?com = factory.CreateCommunicator(props); TestHelper.Assert(com != null); IObjectPrx?obj = com.GetAdmin(); TestHelper.Assert(obj != null); try { IPropertiesAdminPrx.CheckedCast(obj.Clone(facet: "Properties", IObjectPrx.Factory)); TestHelper.Assert(false); } catch (ObjectNotExistException) { } var tf = ITestFacetPrx.CheckedCast(obj.Clone(facet: "TestFacet", IObjectPrx.Factory)); TestHelper.Assert(tf != null); tf.Op(); var proc = IProcessPrx.CheckedCast(obj.Clone(facet: "Process", IObjectPrx.Factory)); TestHelper.Assert(proc != null); proc.Shutdown(); com.WaitForShutdown(); com.Destroy(); } output.WriteLine("ok"); factory.Shutdown(); }
public override async Task RunAsync(string[] args) { Dictionary <string, string> properties = CreateTestProperties(ref args); // We must disable connection warnings, because we attempt to ping the router before session establishment, // as well as after session destruction. Both will cause a ConnectionLostException. properties["Ice.Warn.Connections"] = "0"; properties["Test.Protocol"] = "ice1"; await using Communicator communicator = Initialize(properties); IObjectPrx routerBase; { Console.Out.Write("testing stringToProxy for router... "); Console.Out.Flush(); routerBase = IObjectPrx.Parse(GetTestProxy("Glacier2/router", 50), communicator); Console.Out.WriteLine("ok"); } IRouterPrx?router; { Console.Out.Write("testing checked cast for router... "); Console.Out.Flush(); router = routerBase.CheckedCast(IRouterPrx.Factory); Assert(router != null); Console.Out.WriteLine("ok"); } { Console.Out.Write("testing router finder... "); Console.Out.Flush(); var finder = IRouterFinderPrx.Parse(GetTestProxy("Ice/RouterFinder", 50), communicator); Assert(finder.GetRouter() !.Identity.Equals(router.Identity)); Console.Out.WriteLine("ok"); } { Console.Out.Write("installing router with communicator... "); Console.Out.Flush(); communicator.DefaultRouter = router; Console.Out.WriteLine("ok"); } { Console.Out.Write("getting the session timeout... "); Console.Out.Flush(); long sessionTimeout = router.GetSessionTimeout(); long acmTimeout = router.GetACMTimeout(); Assert(sessionTimeout == 30 && acmTimeout == 30); Console.Out.WriteLine("ok"); } ICallbackPrx twoway; { Console.Out.Write("testing stringToProxy for server object... "); Console.Out.Flush(); twoway = ICallbackPrx.Parse(GetTestProxy("c1/callback", 0), communicator); Console.Out.WriteLine("ok"); } { Console.Out.Write("trying to ping server before session creation... "); Console.Out.Flush(); try { twoway.IcePing(); Assert(false); } catch (ConnectionLostException) { Console.Out.WriteLine("ok"); } catch (TransportException) { Assert(false); } } { Console.Out.Write("trying to create session with wrong password... "); Console.Out.Flush(); try { router.CreateSession("userid", "xxx"); Assert(false); } catch (PermissionDeniedException) { Console.Out.WriteLine("ok"); } catch (CannotCreateSessionException) { Assert(false); } } { Console.Out.Write("trying to destroy non-existing session... "); Console.Out.Flush(); try { router.DestroySession(); Assert(false); } catch (SessionNotExistException) { Console.Out.WriteLine("ok"); } } { Console.Out.Write("creating session with correct password... "); Console.Out.Flush(); try { router.CreateSession("userid", "abc123"); } catch (PermissionDeniedException) { Assert(false); } catch (CannotCreateSessionException) { Assert(false); } Console.Out.WriteLine("ok"); } { Console.Out.Write("trying to create a second session... "); Console.Out.Flush(); try { router.CreateSession("userid", "abc123"); Assert(false); } catch (PermissionDeniedException) { Assert(false); } catch (CannotCreateSessionException) { Console.Out.WriteLine("ok"); } } { Console.Out.Write("pinging server after session creation... "); Console.Out.Flush(); twoway.IcePing(); Console.Out.WriteLine("ok"); } { Console.Out.Write("pinging object with client endpoint... "); var baseC = IObjectPrx.Parse(GetTestProxy("collocated", 50), communicator); try { baseC.IcePing(); } catch (ObjectNotExistException) { } Console.Out.WriteLine("ok"); } ObjectAdapter adapter; { Console.Out.Write("creating and activating callback receiver adapter... "); Console.Out.Flush(); communicator.SetProperty("Ice.PrintAdapterReady", "0"); adapter = communicator.CreateObjectAdapterWithRouter("CallbackReceiverAdapter", router); adapter.Activate(); Console.Out.WriteLine("ok"); } string category; { Console.Out.Write("getting category from router... "); Console.Out.Flush(); category = router.GetCategoryForClient(); Console.Out.WriteLine("ok"); } CallbackReceiver callbackReceiverImpl; ICallbackReceiver callbackReceiver; ICallbackReceiverPrx twowayR; ICallbackReceiverPrx fakeTwowayR; { Console.Out.Write("creating and adding callback receiver object... "); Console.Out.Flush(); callbackReceiverImpl = new CallbackReceiver(); callbackReceiver = callbackReceiverImpl; var callbackReceiverIdent = new Identity("callbackReceiver", category); twowayR = adapter.Add(callbackReceiverIdent, callbackReceiver, ICallbackReceiverPrx.Factory); var fakeCallbackReceiverIdent = new Identity("callbackReceiver", "dummy"); fakeTwowayR = adapter.Add(fakeCallbackReceiverIdent, callbackReceiver, ICallbackReceiverPrx.Factory); Console.Out.WriteLine("ok"); } { Console.Out.Write("testing oneway callback... "); Console.Out.Flush(); ICallbackPrx oneway = twoway.Clone(oneway: true); ICallbackReceiverPrx onewayR = twowayR.Clone(oneway: true); var context = new Dictionary <string, string> { ["_fwd"] = "o" }; oneway.InitiateCallback(onewayR, context); callbackReceiverImpl.CallbackOK(); Console.Out.WriteLine("ok"); } { Console.Out.Write("testing twoway callback... "); Console.Out.Flush(); var context = new Dictionary <string, string> { ["_fwd"] = "t" }; twoway.InitiateCallback(twowayR, context); callbackReceiverImpl.CallbackOK(); Console.Out.WriteLine("ok"); } { Console.Out.Write("ditto, but with user exception... "); Console.Out.Flush(); var context = new Dictionary <string, string> { ["_fwd"] = "t" }; try { twoway.InitiateCallbackEx(twowayR, context); Assert(false); } catch (CallbackException ex) { Assert(ex.SomeValue == 3.14); Assert(ex.SomeString.Equals("3.14")); } callbackReceiverImpl.CallbackOK(); Console.Out.WriteLine("ok"); } { Console.Out.Write("trying twoway callback with fake category... "); Console.Out.Flush(); var context = new Dictionary <string, string> { ["_fwd"] = "t" }; try { twoway.InitiateCallback(fakeTwowayR, context); Assert(false); } catch (ObjectNotExistException) { Console.Out.WriteLine("ok"); } } { Console.Out.Write("testing whether other allowed category is accepted... "); Console.Out.Flush(); var context = new Dictionary <string, string> { ["_fwd"] = "t" }; ICallbackPrx otherCategoryTwoway = twoway.Clone(ICallbackPrx.Factory, identity: Identity.Parse("c2/callback")); otherCategoryTwoway.InitiateCallback(twowayR, context); callbackReceiverImpl.CallbackOK(); Console.Out.WriteLine("ok"); } { Console.Out.Write("testing whether disallowed category gets rejected... "); Console.Out.Flush(); var context = new Dictionary <string, string> { ["_fwd"] = "t" }; try { ICallbackPrx otherCategoryTwoway = twoway.Clone(ICallbackPrx.Factory, identity: Identity.Parse("c3/callback")); otherCategoryTwoway.InitiateCallback(twowayR, context); Assert(false); } catch (ObjectNotExistException) { Console.Out.WriteLine("ok"); } } { Console.Out.Write("testing whether user-id as category is accepted... "); Console.Out.Flush(); var context = new Dictionary <string, string> { ["_fwd"] = "t" }; ICallbackPrx otherCategoryTwoway = twoway.Clone(ICallbackPrx.Factory, identity: Identity.Parse("_userid/callback")); otherCategoryTwoway.InitiateCallback(twowayR, context); callbackReceiverImpl.CallbackOK(); Console.Out.WriteLine("ok"); } if (args.Length >= 1 && args[0].Equals("--shutdown")) { Console.Out.Write("testing server shutdown... "); Console.Out.Flush(); twoway.Shutdown(); // No ping, otherwise the router prints a warning message if it's // started with --Ice.Warn.Connections. Console.Out.WriteLine("ok"); /* * try * { * base.IcePing(); * Assert(false); * } * // If we use the glacier router, the exact exception reason gets * // lost. * catch(Ice.UnknownLocalException ex) * { * Console.Out.WriteLine("ok"); * } */ } { Console.Out.Write("destroying session... "); Console.Out.Flush(); try { router.DestroySession(); } catch { Assert(false); } Console.Out.WriteLine("ok"); } { Console.Out.Write("trying to ping server after session destruction... "); Console.Out.Flush(); try { twoway.IcePing(); Assert(false); } catch (ConnectionLostException) { Console.Out.WriteLine("ok"); } catch (TransportException) { Assert(false); } } if (args.Length >= 1 && args[0].Equals("--shutdown")) { { Console.Out.Write("uninstalling router with communicator... "); Console.Out.Flush(); communicator.DefaultRouter = null; Console.Out.WriteLine("ok"); } IProcessPrx process; { Console.Out.Write("testing stringToProxy for admin object... "); process = IProcessPrx.Parse(GetTestProxy("Glacier2/admin -f Process", 51), communicator); Console.Out.WriteLine("ok"); } /* * { * Console.Out.Write("uninstalling router with process object... "); * processBase.ice_router(null); * Console.Out.WriteLine("ok"); * } */ Console.Out.Write("testing Glacier2 shutdown... "); process.Shutdown(); try { process.IcePing(); Assert(false); } catch { Console.Out.WriteLine("ok"); } } }
public ValueTask SetServerProcessProxyAsync(string id, IProcessPrx proxy, Current current) => new ValueTask(Task.CompletedTask);
public static void allTests(global::Test.TestHelper helper) { Communicator communicator = helper.communicator(); var output = helper.getWriter(); output.Write("testing communicator operations... "); output.Flush(); { // // Test: Exercise AddAdminFacet, FindAdminFacet, RemoveAdminFacet with a typical configuration. // var properties = new Dictionary <string, string>(); properties["Ice.Admin.Endpoints"] = "tcp -h 127.0.0.1"; properties["Ice.Admin.InstanceName"] = "Test"; var com = new Communicator(properties); testFacets(com, true, false); com.Destroy(); } { // // Test: Verify that the operations work correctly in the presence of facet filters. // var properties = new Dictionary <string, string>(); properties["Ice.Admin.Endpoints"] = "tcp -h 127.0.0.1"; properties["Ice.Admin.InstanceName"] = "Test"; properties["Ice.Admin.Facets"] = "Properties"; Communicator com = new Communicator(properties); testFacets(com, false, true); com.Destroy(); } { // // Test: Verify that the operations work correctly with the Admin object disabled. // var com = new Communicator(); testFacets(com, false, false); com.Destroy(); } { // // Test: Verify that the operations work correctly with Ice.Admin.Enabled=1 // var properties = new Dictionary <string, string>() { { "Ice.Admin.Enabled", "1" } }; Communicator com = new Communicator(properties); test(com.GetAdmin() == null); Identity id = Identity.Parse("test-admin"); try { com.CreateAdmin(null, id); test(false); } catch (InvalidConfigurationException) { } ObjectAdapter adapter = com.CreateObjectAdapter(); test(com.CreateAdmin(adapter, id) != null); test(com.GetAdmin() != null); testFacets(com, true, false); com.Destroy(); } { // // Test: Verify that the operations work correctly when creation of the Admin object is delayed. // var properties = new Dictionary <string, string>() { { "Ice.Admin.Endpoints", "tcp -h 127.0.0.1" }, { "Ice.Admin.InstanceName", "Test" }, { "Ice.Admin.DelayCreation", "1" } }; Communicator com = new Communicator(properties); testFacets(com, true, false); com.GetAdmin(); testFacets(com, true, false); com.Destroy(); } output.WriteLine("ok"); var factory = IRemoteCommunicatorFactoryPrx.Parse($"factory:{helper.getTestEndpoint(0)} -t 10000", communicator); output.Write("testing process facet... "); output.Flush(); { // // Test: Verify that Process::shutdown() operation shuts down the communicator. // Dictionary <string, string> props = new Dictionary <string, string>(); props.Add("Ice.Admin.Endpoints", "tcp -h 127.0.0.1"); props.Add("Ice.Admin.InstanceName", "Test"); var com = factory.createCommunicator(props); IObjectPrx obj = com.getAdmin(); IProcessPrx proc = obj.Clone("Process", IProcessPrx.Factory); proc.Shutdown(); com.waitForShutdown(); com.destroy(); } output.WriteLine("ok"); output.Write("testing properties facet... "); output.Flush(); { Dictionary <string, string> props = new Dictionary <string, string>(); props.Add("Ice.Admin.Endpoints", "tcp -h 127.0.0.1"); props.Add("Ice.Admin.InstanceName", "Test"); props.Add("Prop1", "1"); props.Add("Prop2", "2"); props.Add("Prop3", "3"); var com = factory.createCommunicator(props); IObjectPrx obj = com.getAdmin(); IPropertiesAdminPrx pa = obj.Clone("Properties", IPropertiesAdminPrx.Factory); // // Test: PropertiesAdmin::getProperty() // test(pa.GetProperty("Prop2") == "2"); test(pa.GetProperty("Bogus") == ""); // // Test: PropertiesAdmin::getProperties() // Dictionary <string, string> pd = pa.GetPropertiesForPrefix(""); test(pd.Count == 6); test(pd["Ice.ProgramName"] == "server"); test(pd["Ice.Admin.Endpoints"] == "tcp -h 127.0.0.1"); test(pd["Ice.Admin.InstanceName"] == "Test"); test(pd["Prop1"] == "1"); test(pd["Prop2"] == "2"); test(pd["Prop3"] == "3"); Dictionary <string, string> changes; // // Test: PropertiesAdmin::setProperties() // Dictionary <string, string> setProps = new Dictionary <string, string>(); setProps.Add("Prop1", "10"); // Changed setProps.Add("Prop2", "20"); // Changed setProps.Add("Prop3", ""); // Removed setProps.Add("Prop4", "4"); // Added setProps.Add("Prop5", "5"); // Added pa.SetProperties(setProps); test(pa.GetProperty("Prop1").Equals("10")); test(pa.GetProperty("Prop2").Equals("20")); test(pa.GetProperty("Prop3").Equals("")); test(pa.GetProperty("Prop4").Equals("4")); test(pa.GetProperty("Prop5").Equals("5")); changes = com.getChanges(); test(changes.Count == 5); test(changes["Prop1"].Equals("10")); test(changes["Prop2"].Equals("20")); test(changes["Prop3"].Equals("")); test(changes["Prop4"].Equals("4")); test(changes["Prop5"].Equals("5")); pa.SetProperties(setProps); changes = com.getChanges(); test(changes.Count == 0); com.destroy(); } output.WriteLine("ok"); output.Write("testing logger facet... "); output.Flush(); { var props = new Dictionary <string, string>(); props.Add("Ice.Admin.Endpoints", "tcp -h 127.0.0.1"); props.Add("Ice.Admin.InstanceName", "Test"); props.Add("NullLogger", "1"); var com = factory.createCommunicator(props); com.trace("testCat", "trace"); com.warning("warning"); com.error("error"); com.print("print"); IObjectPrx obj = com.getAdmin(); var logger = obj.Clone("Logger", ILoggerAdminPrx.Factory); test(logger != null); // // Get all // var(logMessages, prefix) = logger.GetLog(Array.Empty <LogMessageType>(), Array.Empty <string>(), -1); test(logMessages.Length == 4); test(prefix.Equals("NullLogger")); test(logMessages[0].TraceCategory.Equals("testCat") && logMessages[0].Message.Equals("trace")); test(logMessages[1].Message.Equals("warning")); test(logMessages[2].Message.Equals("error")); test(logMessages[3].Message.Equals("print")); // // Get only errors and warnings // com.error("error2"); com.print("print2"); com.trace("testCat", "trace2"); com.warning("warning2"); LogMessageType[] messageTypes = { LogMessageType.ErrorMessage, LogMessageType.WarningMessage }; (logMessages, prefix) = logger.GetLog(messageTypes, Array.Empty <string>(), -1); test(logMessages.Length == 4); test(prefix.Equals("NullLogger")); foreach (LogMessage msg in logMessages) { test(msg.Type == LogMessageType.ErrorMessage || msg.Type == LogMessageType.WarningMessage); } // // Get only errors and traces with Cat = "testCat" // com.trace("testCat2", "A"); com.trace("testCat", "trace3"); com.trace("testCat2", "B"); messageTypes = new LogMessageType[] { LogMessageType.ErrorMessage, LogMessageType.TraceMessage }; string[] categories = { "testCat" }; (logMessages, prefix) = logger.GetLog(messageTypes, categories, -1); test(logMessages.Length == 5); test(prefix.Equals("NullLogger")); foreach (var msg in logMessages) { test(msg.Type == LogMessageType.ErrorMessage || (msg.Type == LogMessageType.TraceMessage && msg.TraceCategory.Equals("testCat"))); } // // Same, but limited to last 2 messages(trace3 + error3) // com.error("error3"); (logMessages, prefix) = logger.GetLog(messageTypes, categories, 2); test(logMessages.Length == 2); test(prefix.Equals("NullLogger")); test(logMessages[0].Message.Equals("trace3")); test(logMessages[1].Message.Equals("error3")); // // Now, test RemoteLogger // ObjectAdapter adapter = communicator.CreateObjectAdapterWithEndpoints("RemoteLoggerAdapter", "tcp -h localhost"); var remoteLogger = new RemoteLogger(); IRemoteLoggerPrx myProxy = adapter.AddWithUUID(remoteLogger, IRemoteLoggerPrx.Factory); adapter.Activate(); // // No filtering // (logMessages, prefix) = logger.GetLog(Array.Empty <LogMessageType>(), Array.Empty <string>(), -1); logger.AttachRemoteLogger(myProxy, Array.Empty <LogMessageType>(), Array.Empty <string>(), -1); remoteLogger.Wait(1); foreach (var m in logMessages) { remoteLogger.CheckNextInit(prefix, m.Type, m.Message, m.TraceCategory); } com.trace("testCat", "rtrace"); com.warning("rwarning"); com.error("rerror"); com.print("rprint"); remoteLogger.Wait(4); remoteLogger.CheckNextLog(LogMessageType.TraceMessage, "rtrace", "testCat"); remoteLogger.CheckNextLog(LogMessageType.WarningMessage, "rwarning", ""); remoteLogger.CheckNextLog(LogMessageType.ErrorMessage, "rerror", ""); remoteLogger.CheckNextLog(LogMessageType.PrintMessage, "rprint", ""); test(logger.DetachRemoteLogger(myProxy)); test(!logger.DetachRemoteLogger(myProxy)); // // Use Error + Trace with "traceCat" filter with 4 limit // (logMessages, prefix) = logger.GetLog(messageTypes, categories, 4); test(logMessages.Length == 4); logger.AttachRemoteLogger(myProxy, messageTypes, categories, 4); remoteLogger.Wait(1); foreach (var m in logMessages) { remoteLogger.CheckNextInit(prefix, m.Type, m.Message, m.TraceCategory); } com.warning("rwarning2"); com.trace("testCat", "rtrace2"); com.warning("rwarning3"); com.error("rerror2"); com.print("rprint2"); remoteLogger.Wait(2); remoteLogger.CheckNextLog(LogMessageType.TraceMessage, "rtrace2", "testCat"); remoteLogger.CheckNextLog(LogMessageType.ErrorMessage, "rerror2", ""); // // Attempt reconnection with slightly different proxy // try { logger.AttachRemoteLogger(myProxy.Clone(oneway: true), messageTypes, categories, 4); test(false); } catch (RemoteLoggerAlreadyAttachedException) { // expected } com.destroy(); } output.WriteLine("ok"); output.Write("testing custom facet... "); output.Flush(); { // // Test: Verify that the custom facet is present. // Dictionary <string, string> props = new Dictionary <string, string>(); props.Add("Ice.Admin.Endpoints", "tcp -h 127.0.0.1"); props.Add("Ice.Admin.InstanceName", "Test"); var com = factory.createCommunicator(props); IObjectPrx obj = com.getAdmin(); var tf = obj.Clone("TestFacet", ITestFacetPrx.Factory); tf.op(); com.destroy(); } output.WriteLine("ok"); output.Write("testing facet filtering... "); output.Flush(); { // // Test: Set Ice.Admin.Facets to expose only the Properties facet, // meaning no other facet is available. // Dictionary <string, string> props = new Dictionary <string, string>(); props.Add("Ice.Admin.Endpoints", "tcp -h 127.0.0.1"); props.Add("Ice.Admin.InstanceName", "Test"); props.Add("Ice.Admin.Facets", "Properties"); var com = factory.createCommunicator(props); IObjectPrx obj = com.getAdmin(); try { IProcessPrx.CheckedCast(obj.Clone(facet: "Process", IObjectPrx.Factory)); test(false); } catch (ObjectNotExistException) { } try { ITestFacetPrx.CheckedCast(obj.Clone(facet: "TestFacet", IObjectPrx.Factory)); test(false); } catch (ObjectNotExistException) { } com.destroy(); } { // // Test: Set Ice.Admin.Facets to expose only the Process facet, // meaning no other facet is available. // Dictionary <string, string> props = new Dictionary <string, string>(); props.Add("Ice.Admin.Endpoints", "tcp -h 127.0.0.1"); props.Add("Ice.Admin.InstanceName", "Test"); props.Add("Ice.Admin.Facets", "Process"); var com = factory.createCommunicator(props); IObjectPrx obj = com.getAdmin(); try { IPropertiesAdminPrx.CheckedCast(obj.Clone(facet: "Properties", IObjectPrx.Factory)); test(false); } catch (ObjectNotExistException) { } try { ITestFacetPrx.CheckedCast(obj.Clone(facet: "TestFacet", IObjectPrx.Factory)); test(false); } catch (ObjectNotExistException) { } com.destroy(); } { // // Test: Set Ice.Admin.Facets to expose only the TestFacet facet, // meaning no other facet is available. // Dictionary <string, string> props = new Dictionary <string, string>(); props.Add("Ice.Admin.Endpoints", "tcp -h 127.0.0.1"); props.Add("Ice.Admin.InstanceName", "Test"); props.Add("Ice.Admin.Facets", "TestFacet"); var com = factory.createCommunicator(props); IObjectPrx obj = com.getAdmin(); try { IPropertiesAdminPrx.CheckedCast(obj.Clone(facet: "Properties", IObjectPrx.Factory)); test(false); } catch (ObjectNotExistException) { } try { IProcessPrx.CheckedCast(obj.Clone(facet: "Process", IObjectPrx.Factory)); test(false); } catch (ObjectNotExistException) { } com.destroy(); } { // // Test: Set Ice.Admin.Facets to expose two facets. Use whitespace to separate the // facet names. // Dictionary <string, string> props = new Dictionary <string, string>(); props.Add("Ice.Admin.Endpoints", "tcp -h 127.0.0.1"); props.Add("Ice.Admin.InstanceName", "Test"); props.Add("Ice.Admin.Facets", "Properties TestFacet"); var com = factory.createCommunicator(props); IObjectPrx obj = com.getAdmin(); IPropertiesAdminPrx pa = obj.Clone("Properties", IPropertiesAdminPrx.Factory); test(pa.GetProperty("Ice.Admin.InstanceName").Equals("Test")); var tf = ITestFacetPrx.CheckedCast(obj.Clone(facet: "TestFacet", IObjectPrx.Factory)); tf !.op(); try { IProcessPrx.CheckedCast(obj.Clone(facet: "Process", IObjectPrx.Factory)); test(false); } catch (ObjectNotExistException) { } com.destroy(); } { // // Test: Set Ice.Admin.Facets to expose two facets. Use a comma to separate the // facet names. // Dictionary <string, string> props = new Dictionary <string, string>(); props.Add("Ice.Admin.Endpoints", "tcp -h 127.0.0.1"); props.Add("Ice.Admin.InstanceName", "Test"); props.Add("Ice.Admin.Facets", "TestFacet, Process"); var com = factory.createCommunicator(props); IObjectPrx obj = com.getAdmin(); try { IPropertiesAdminPrx.CheckedCast(obj.Clone(facet: "Properties", IObjectPrx.Factory)); test(false); } catch (ObjectNotExistException) { } var tf = ITestFacetPrx.CheckedCast(obj.Clone(facet: "TestFacet", IObjectPrx.Factory)); tf.op(); IProcessPrx proc = IProcessPrx.CheckedCast(obj.Clone(facet: "Process", IObjectPrx.Factory)); proc.Shutdown(); com.waitForShutdown(); com.destroy(); } output.WriteLine("ok"); factory.shutdown(); }
SetServerProcessProxyAsync(string id, IProcessPrx proxy, Current current) => null;
SetServerProcessProxyAsync(string id, IProcessPrx process, Current current) { return(null); }
public override void run(string[] args) { Dictionary <string, string> properties = createTestProperties(ref args); // // We must disable connection warnings, because we attempt to // ping the router before session establishment, as well as // after session destruction. Both will cause a // ConnectionLostException. // properties["Ice.Warn.Connections"] = "0"; using (var communicator = initialize(properties)) { IObjectPrx routerBase; { Console.Out.Write("testing stringToProxy for router... "); Console.Out.Flush(); routerBase = IObjectPrx.Parse($"Glacier2/router:{getTestEndpoint(50)}", communicator); Console.Out.WriteLine("ok"); } Glacier2.IRouterPrx router; { Console.Out.Write("testing checked cast for router... "); Console.Out.Flush(); router = Glacier2.IRouterPrx.CheckedCast(routerBase); test(router != null); Console.Out.WriteLine("ok"); } { Console.Out.Write("testing router finder... "); Console.Out.Flush(); IRouterFinderPrx finder = IRouterFinderPrx.Parse($"Ice/RouterFinder:{getTestEndpoint(50)}", communicator); test(finder.GetRouter().Identity.Equals(router.Identity)); Console.Out.WriteLine("ok"); } { Console.Out.Write("installing router with communicator... "); Console.Out.Flush(); communicator.setDefaultRouter(router); Console.Out.WriteLine("ok"); } { Console.Out.Write("getting the session timeout... "); Console.Out.Flush(); long sessionTimeout = router.GetSessionTimeout(); long acmTimeout = router.GetACMTimeout(); test(sessionTimeout == 30 && acmTimeout == 30); Console.Out.WriteLine("ok"); } IObjectPrx @base; { Console.Out.Write("testing stringToProxy for server object... "); Console.Out.Flush(); @base = IObjectPrx.Parse($"c1/callback:{getTestEndpoint(0)}", communicator); Console.Out.WriteLine("ok"); } { Console.Out.Write("trying to ping server before session creation... "); Console.Out.Flush(); try { @base.IcePing(); test(false); } catch (Ice.ConnectionLostException) { Console.Out.WriteLine("ok"); } catch (Ice.SocketException) { test(false); } } { Console.Out.Write("trying to create session with wrong password... "); Console.Out.Flush(); try { router.CreateSession("userid", "xxx"); test(false); } catch (Glacier2.PermissionDeniedException) { Console.Out.WriteLine("ok"); } catch (Glacier2.CannotCreateSessionException) { test(false); } } { Console.Out.Write("trying to destroy non-existing session... "); Console.Out.Flush(); try { router.DestroySession(); test(false); } catch (Glacier2.SessionNotExistException) { Console.Out.WriteLine("ok"); } } { Console.Out.Write("creating session with correct password... "); Console.Out.Flush(); try { router.CreateSession("userid", "abc123"); } catch (Glacier2.PermissionDeniedException) { test(false); } catch (Glacier2.CannotCreateSessionException) { test(false); } Console.Out.WriteLine("ok"); } { Console.Out.Write("trying to create a second session... "); Console.Out.Flush(); try { router.CreateSession("userid", "abc123"); test(false); } catch (Glacier2.PermissionDeniedException) { test(false); } catch (Glacier2.CannotCreateSessionException) { Console.Out.WriteLine("ok"); } } { Console.Out.Write("pinging server after session creation... "); Console.Out.Flush(); @base.IcePing(); Console.Out.WriteLine("ok"); } { Console.Out.Write("pinging object with client endpoint... "); IObjectPrx baseC = IObjectPrx.Parse($"collocated:{getTestEndpoint(50)}", communicator); try { baseC.IcePing(); } catch (Ice.ObjectNotExistException) { } Console.Out.WriteLine("ok"); } ICallbackPrx twoway; { Console.Out.Write("testing checked cast for server object... "); Console.Out.Flush(); twoway = ICallbackPrx.CheckedCast(@base); test(twoway != null); Console.Out.WriteLine("ok"); } Ice.ObjectAdapter adapter; { Console.Out.Write("creating and activating callback receiver adapter... "); Console.Out.Flush(); communicator.SetProperty("Ice.PrintAdapterReady", "0"); adapter = communicator.createObjectAdapterWithRouter("CallbackReceiverAdapter", router); adapter.Activate(); Console.Out.WriteLine("ok"); } string category; { Console.Out.Write("getting category from router... "); Console.Out.Flush(); category = router.GetCategoryForClient(); Console.Out.WriteLine("ok"); } CallbackReceiverI callbackReceiverImpl; CallbackReceiver callbackReceiver; ICallbackReceiverPrx twowayR; ICallbackReceiverPrx fakeTwowayR; { Console.Out.Write("creating and adding callback receiver object... "); Console.Out.Flush(); callbackReceiverImpl = new CallbackReceiverI(); callbackReceiver = callbackReceiverImpl; Ice.Identity callbackReceiverIdent = new Ice.Identity(); callbackReceiverIdent.name = "callbackReceiver"; callbackReceiverIdent.category = category; twowayR = adapter.Add(callbackReceiver, callbackReceiverIdent); Ice.Identity fakeCallbackReceiverIdent = new Ice.Identity(); fakeCallbackReceiverIdent.name = "callbackReceiver"; fakeCallbackReceiverIdent.category = "dummy"; fakeTwowayR = adapter.Add(callbackReceiver, fakeCallbackReceiverIdent); Console.Out.WriteLine("ok"); } { Console.Out.Write("testing oneway callback... "); Console.Out.Flush(); ICallbackPrx oneway = twoway.Clone(oneway: true); ICallbackReceiverPrx onewayR = twowayR.Clone(oneway: true); Dictionary <string, string> context = new Dictionary <string, string>(); context["_fwd"] = "o"; oneway.initiateCallback(onewayR, context); callbackReceiverImpl.callbackOK(); Console.Out.WriteLine("ok"); } { Console.Out.Write("testing twoway callback... "); Console.Out.Flush(); Dictionary <string, string> context = new Dictionary <string, string>(); context["_fwd"] = "t"; twoway.initiateCallback(twowayR, context); callbackReceiverImpl.callbackOK(); Console.Out.WriteLine("ok"); } { Console.Out.Write("ditto, but with user exception... "); Console.Out.Flush(); Dictionary <string, string> context = new Dictionary <string, string>(); context["_fwd"] = "t"; try { twoway.initiateCallbackEx(twowayR, context); test(false); } catch (CallbackException ex) { test(ex.someValue == 3.14); test(ex.someString.Equals("3.14")); } callbackReceiverImpl.callbackOK(); Console.Out.WriteLine("ok"); } { Console.Out.Write("trying twoway callback with fake category... "); Console.Out.Flush(); Dictionary <string, string> context = new Dictionary <string, string>(); context["_fwd"] = "t"; try { twoway.initiateCallback(fakeTwowayR, context); test(false); } catch (Ice.ObjectNotExistException) { Console.Out.WriteLine("ok"); } } { Console.Out.Write("testing whether other allowed category is accepted... "); Console.Out.Flush(); Dictionary <string, string> context = new Dictionary <string, string>(); context["_fwd"] = "t"; ICallbackPrx otherCategoryTwoway = ICallbackPrx.UncheckedCast(twoway.Clone(Identity.Parse("c2/callback"))); otherCategoryTwoway.initiateCallback(twowayR, context); callbackReceiverImpl.callbackOK(); Console.Out.WriteLine("ok"); } { Console.Out.Write("testing whether disallowed category gets rejected... "); Console.Out.Flush(); Dictionary <string, string> context = new Dictionary <string, string>(); context["_fwd"] = "t"; try { ICallbackPrx otherCategoryTwoway = ICallbackPrx.UncheckedCast(twoway.Clone(Identity.Parse("c3/callback"))); otherCategoryTwoway.initiateCallback(twowayR, context); test(false); } catch (Ice.ObjectNotExistException) { Console.Out.WriteLine("ok"); } } { Console.Out.Write("testing whether user-id as category is accepted... "); Console.Out.Flush(); Dictionary <string, string> context = new Dictionary <string, string>(); context["_fwd"] = "t"; ICallbackPrx otherCategoryTwoway = ICallbackPrx.UncheckedCast(twoway.Clone(Identity.Parse("_userid/callback"))); otherCategoryTwoway.initiateCallback(twowayR, context); callbackReceiverImpl.callbackOK(); Console.Out.WriteLine("ok"); } if (args.Length >= 1 && args[0].Equals("--shutdown")) { Console.Out.Write("testing server shutdown... "); Console.Out.Flush(); twoway.shutdown(); // No ping, otherwise the router prints a warning message if it's // started with --Ice.Warn.Connections. Console.Out.WriteLine("ok"); /* * try * { * base.IcePing(); * test(false); * } * // If we use the glacier router, the exact exception reason gets * // lost. * catch(Ice.UnknownLocalException ex) * { * Console.Out.WriteLine("ok"); * } */ } { Console.Out.Write("destroying session... "); Console.Out.Flush(); try { router.DestroySession(); } catch (Ice.LocalException) { test(false); } Console.Out.WriteLine("ok"); } { Console.Out.Write("trying to ping server after session destruction... "); Console.Out.Flush(); try { @base.IcePing(); test(false); } catch (Ice.ConnectionLostException) { Console.Out.WriteLine("ok"); } catch (Ice.SocketException) { test(false); } } if (args.Length >= 1 && args[0].Equals("--shutdown")) { { Console.Out.Write("uninstalling router with communicator... "); Console.Out.Flush(); communicator.setDefaultRouter(null); Console.Out.WriteLine("ok"); } IObjectPrx processBase; { Console.Out.Write("testing stringToProxy for admin object... "); processBase = IObjectPrx.Parse($"Glacier2/admin -f Process:{getTestEndpoint(51)}", communicator); Console.Out.WriteLine("ok"); } /* * { * Console.Out.Write("uninstalling router with process object... "); * processBase.ice_router(null); * Console.Out.WriteLine("ok"); * } */ IProcessPrx process; { Console.Out.Write("testing checked cast for process object... "); process = IProcessPrx.CheckedCast(processBase); process.IcePing(); Console.Out.WriteLine("ok"); } Console.Out.Write("testing Glacier2 shutdown... "); process.Shutdown(); try { process.IcePing(); test(false); } catch (LocalException) { Console.Out.WriteLine("ok"); } } } }