public override int run(string[] args) { String protocol = communicator().getProperties().getPropertyWithDefault("Ice.Default.Protocol", "tcp"); String host = communicator().getProperties().getPropertyWithDefault("Ice.Default.Host", "127.0.0.1"); _factory = new Glacier2.SessionFactoryHelper(_initData, new SessionCalback1()); // // Test to create a session with wrong userid/password // lock (this) { Console.Out.Write("testing SessionHelper connect with wrong userid/password... "); Console.Out.Flush(); _factory.setProtocol(protocol); _session = _factory.connect("userid", "xxx"); while (true) { #if COMPACT System.Threading.Monitor.Wait(this); break; #else try { System.Threading.Monitor.Wait(this); break; } catch (ThreadInterruptedException) { } #endif } } _initData.properties.setProperty("Ice.Default.Router", ""); _factory = new Glacier2.SessionFactoryHelper(_initData, new SessionCalback4()); lock (this) { Console.Out.Write("testing SessionHelper connect interrupt... "); Console.Out.Flush(); _factory.setRouterHost(host); _factory.setPort(12011); _factory.setProtocol(protocol); _session = _factory.connect("userid", "abc123"); System.Threading.Thread.Sleep(100); _session.destroy(); while (true) { #if COMPACT System.Threading.Monitor.Wait(this); break; #else try { System.Threading.Monitor.Wait(this); break; } catch (ThreadInterruptedException) { } #endif } } _factory = new Glacier2.SessionFactoryHelper(_initData, new SessionCalback2()); lock (this) { Console.Out.Write("testing SessionHelper connect... "); Console.Out.Flush(); _factory.setRouterHost(host); _factory.setPort(12347); _factory.setProtocol(protocol); _session = _factory.connect("userid", "abc123"); while (true) { #if COMPACT System.Threading.Monitor.Wait(this); break; #else try { System.Threading.Monitor.Wait(this); break; } catch (ThreadInterruptedException) { } #endif } Console.Out.Write("testing SessionHelper isConnected after connect... "); Console.Out.Flush(); test(_session.isConnected()); Console.Out.WriteLine("ok"); Console.Out.Write("testing SessionHelper categoryForClient after connect... "); Console.Out.Flush(); try { test(!_session.categoryForClient().Equals("")); } catch (Glacier2.SessionNotExistException) { test(false); } Console.Out.WriteLine("ok"); // try // { // test(_session.session() != null); // } // catch(Glacier2.SessionNotExistException ex) // { // test(false); // } Console.Out.Write("testing stringToProxy for server object... "); Console.Out.Flush(); Ice.ObjectPrx @base = _session.communicator().stringToProxy("callback:default -p 12010"); Console.Out.WriteLine("ok"); Console.Out.Write("pinging server after session creation... "); Console.Out.Flush(); @base.ice_ping(); Console.Out.WriteLine("ok"); Console.Out.Write("testing checked cast for server object... "); Console.Out.Flush(); CallbackPrx twoway = CallbackPrxHelper.checkedCast(@base); test(twoway != null); Console.Out.WriteLine("ok"); Console.Out.Write("testing server shutdown... "); Console.Out.Flush(); twoway.shutdown(); Console.Out.WriteLine("ok"); test(_session.communicator() != null); Console.Out.Write("testing SessionHelper destroy... "); Console.Out.Flush(); _session.destroy(); while (true) { #if COMPACT System.Threading.Monitor.Wait(this); break; #else try { System.Threading.Monitor.Wait(this); break; } catch (ThreadInterruptedException) { } #endif } Console.Out.Write("testing SessionHelper isConnected after destroy... "); Console.Out.Flush(); test(_session.isConnected() == false); Console.Out.WriteLine("ok"); Console.Out.Write("testing SessionHelper categoryForClient after destroy... "); Console.Out.Flush(); try { test(!_session.categoryForClient().Equals("")); test(false); } catch (Glacier2.SessionNotExistException) { } Console.Out.WriteLine("ok"); Console.Out.Write("testing SessionHelper session after destroy... "); try { _session.session(); test(false); } catch (Glacier2.SessionNotExistException) { } Console.Out.WriteLine("ok"); Console.Out.Write("testing SessionHelper communicator after destroy... "); Console.Out.Flush(); try { test(_session.communicator() != null); _session.communicator().stringToProxy("dummy"); test(false); } catch (Ice.CommunicatorDestroyedException) { } Console.Out.WriteLine("ok"); Console.Out.Write("uninstalling router with communicator... "); Console.Out.Flush(); communicator().setDefaultRouter(null); Console.Out.WriteLine("ok"); Ice.ObjectPrx processBase; { Console.Out.Write("testing stringToProxy for process object... "); processBase = communicator().stringToProxy("Glacier2/admin -f Process:default -h \"" + host + "\" -p 12348"); Console.Out.WriteLine("ok"); } Ice.ProcessPrx process; { Console.Out.Write("testing checked cast for admin object... "); process = Ice.ProcessPrxHelper.checkedCast(processBase); test(process != null); Console.Out.WriteLine("ok"); } Console.Out.Write("testing Glacier2 shutdown... "); process.shutdown(); try { process.ice_ping(); test(false); } catch (Ice.LocalException) { Console.Out.WriteLine("ok"); } } _factory = new Glacier2.SessionFactoryHelper(_initData, new SessionCalback3()); lock (this) { Console.Out.Write("testing SessionHelper connect after router shutdown... "); Console.Out.Flush(); _factory.setRouterHost(host); _factory.setPort(12347); _factory.setProtocol(protocol); _session = _factory.connect("userid", "abc123"); while (true) { #if COMPACT System.Threading.Monitor.Wait(this); break; #else try { System.Threading.Monitor.Wait(this); break; } catch (ThreadInterruptedException) { } #endif } Console.Out.Write("testing SessionHelper isConnect after connect failure... "); Console.Out.Flush(); test(_session.isConnected() == false); Console.Out.WriteLine("ok"); Console.Out.Write("testing SessionHelper communicator after connect failure... "); Console.Out.Flush(); try { test(_session.communicator() != null); _session.communicator().stringToProxy("dummy"); test(false); } catch (Ice.CommunicatorDestroyedException) { } Console.Out.WriteLine("ok"); Console.Out.Write("testing SessionHelper destroy after connect failure... "); Console.Out.Flush(); _session.destroy(); Console.Out.WriteLine("ok"); } return(0); }
public override int run(string[] args) { _factory = new Glacier2.SessionFactoryHelper(_initData, new SessionCalback1()); // // Test to create a session with wrong userid/password // lck.Lock(); try { Console.Out.Write("testing SessionHelper connect with wrong userid/password... "); Console.Out.Flush(); _factory.setRouterHost("127.0.0.1"); _factory.setPort(12347); _factory.setRouterIdentity(Ice.Util.stringToIdentity("Glacier2/router")); _factory.setSecure(false); _session = _factory.connect("userid", "xxx"); while(true) { #if COMPACT lck.Wait(); break; #else try { lck.Wait(); break; } catch(ThreadInterruptedException) { } #endif } } finally { lck.Unlock(); } _factory = new Glacier2.SessionFactoryHelper(_initData, new SessionCalback2()); lck.Lock(); try { Console.Out.Write("testing SessionHelper connect... "); Console.Out.Flush(); _factory.setRouterHost("127.0.0.1"); _factory.setPort(12347); _factory.setRouterIdentity(Ice.Util.stringToIdentity("Glacier2/router")); _factory.setSecure(false); _session = _factory.connect("userid", "abc123"); while(true) { #if COMPACT lck.Wait(); break; #else try { lck.Wait(); break; } catch(ThreadInterruptedException) { } #endif } Console.Out.Write("testing SessionHelper isConnected after connect... "); Console.Out.Flush(); test(_session.isConnected()); Console.Out.WriteLine("ok"); Console.Out.Write("testing SessionHelper categoryForClient after connect... "); Console.Out.Flush(); try { test(!_session.categoryForClient().Equals("")); } catch(Glacier2.SessionNotExistException) { test(false); } Console.Out.WriteLine("ok"); // try // { // test(_session.session() != null); // } // catch(Glacier2.SessionNotExistException ex) // { // test(false); // } Console.Out.Write("testing stringToProxy for server object... "); Console.Out.Flush(); Ice.ObjectPrx @base = _session.communicator().stringToProxy("callback:tcp -p 12010"); Console.Out.WriteLine("ok"); Console.Out.Write("pinging server after session creation... "); Console.Out.Flush(); @base.ice_ping(); Console.Out.WriteLine("ok"); Console.Out.Write("testing checked cast for server object... "); Console.Out.Flush(); CallbackPrx twoway = CallbackPrxHelper.checkedCast(@base); test(twoway != null); Console.Out.WriteLine("ok"); Console.Out.Write("testing server shutdown... "); Console.Out.Flush(); twoway.shutdown(); Console.Out.WriteLine("ok"); test(_session.communicator() != null); Console.Out.Write("testing SessionHelper destroy... "); Console.Out.Flush(); _session.destroy(); while(true) { #if COMPACT lck.Wait(); break; #else try { lck.Wait(); break; } catch(ThreadInterruptedException) { } #endif } Console.Out.Write("testing SessionHelper isConnected after destroy... "); Console.Out.Flush(); test(_session.isConnected() == false); Console.Out.WriteLine("ok"); Console.Out.Write("testing SessionHelper categoryForClient after destroy... "); Console.Out.Flush(); try { test(!_session.categoryForClient().Equals("")); test(false); } catch(Glacier2.SessionNotExistException) { } Console.Out.WriteLine("ok"); Console.Out.Write("testing SessionHelper session after destroy... "); try { _session.session(); test(false); } catch(Glacier2.SessionNotExistException) { } Console.Out.WriteLine("ok"); Console.Out.Write("testing SessionHelper communicator after destroy... "); Console.Out.Flush(); test(_session.communicator() == null); Console.Out.WriteLine("ok"); Console.Out.Write("uninstalling router with communicator... "); Console.Out.Flush(); communicator().setDefaultRouter(null); Console.Out.WriteLine("ok"); Ice.ObjectPrx processBase; { Console.Out.Write("testing stringToProxy for process object... "); processBase = communicator().stringToProxy("Glacier2/admin -f Process:tcp -h 127.0.0.1 -p 12348"); Console.Out.WriteLine("ok"); } Ice.ProcessPrx process; { Console.Out.Write("testing checked cast for admin object... "); process = Ice.ProcessPrxHelper.checkedCast(processBase); test(process != null); Console.Out.WriteLine("ok"); } Console.Out.Write("testing Glacier2 shutdown... "); process.shutdown(); try { process.ice_ping(); test(false); } catch(Ice.LocalException) { Console.Out.WriteLine("ok"); } } finally { lck.Unlock(); } _factory = new Glacier2.SessionFactoryHelper(_initData, new SessionCalback3()); lck.Lock(); try { Console.Out.Write("testing SessionHelper connect after router shutdown... "); Console.Out.Flush(); _factory.setRouterHost("127.0.0.1"); _factory.setPort(12347); _factory.setRouterIdentity(Ice.Util.stringToIdentity("Glacier2/router")); _factory.setSecure(false); _session = _factory.connect("userid", "abc123"); while(true) { #if COMPACT lck.Wait(); break; #else try { lck.Wait(); break; } catch(ThreadInterruptedException) { } #endif } Console.Out.Write("testing SessionHelper isConnect after connect failure... "); Console.Out.Flush(); test(_session.isConnected() == false); Console.Out.WriteLine("ok"); Console.Out.Write("testing SessionHelper communicator after connect failure... "); Console.Out.Flush(); test(_session.communicator() == null); Console.Out.WriteLine("ok"); Console.Out.Write("testing SessionHelper destroy after connect failure... "); Console.Out.Flush(); _session.destroy(); Console.Out.WriteLine("ok"); } finally { lck.Unlock(); } return 0; }
public override int run(string[] args) { String protocol = communicator().getProperties().getPropertyWithDefault("Ice.Default.Protocol", "tcp"); String host = communicator().getProperties().getPropertyWithDefault("Ice.Default.Host", "127.0.0.1"); _factory = new Glacier2.SessionFactoryHelper(_initData, new SessionCalback1()); // // Test to create a session with wrong userid/password // lock(this) { Console.Out.Write("testing SessionHelper connect with wrong userid/password... "); Console.Out.Flush(); _factory.setProtocol(protocol); _session = _factory.connect("userid", "xxx"); while(true) { #if COMPACT System.Threading.Monitor.Wait(this); break; #else try { System.Threading.Monitor.Wait(this); break; } catch(ThreadInterruptedException) { } #endif } } _initData.properties.setProperty("Ice.Default.Router", ""); _factory = new Glacier2.SessionFactoryHelper(_initData, new SessionCalback4()); lock(this) { Console.Out.Write("testing SessionHelper connect interrupt... "); Console.Out.Flush(); _factory.setRouterHost(host); _factory.setPort(12011); _factory.setProtocol(protocol); _session = _factory.connect("userid", "abc123"); System.Threading.Thread.Sleep(100); _session.destroy(); while(true) { #if COMPACT System.Threading.Monitor.Wait(this); break; #else try { System.Threading.Monitor.Wait(this); break; } catch(ThreadInterruptedException) { } #endif } } _factory = new Glacier2.SessionFactoryHelper(_initData, new SessionCalback2()); lock(this) { Console.Out.Write("testing SessionHelper connect... "); Console.Out.Flush(); _factory.setRouterHost(host); _factory.setPort(12347); _factory.setProtocol(protocol); _session = _factory.connect("userid", "abc123"); while(true) { #if COMPACT System.Threading.Monitor.Wait(this); break; #else try { System.Threading.Monitor.Wait(this); break; } catch(ThreadInterruptedException) { } #endif } Console.Out.Write("testing SessionHelper isConnected after connect... "); Console.Out.Flush(); test(_session.isConnected()); Console.Out.WriteLine("ok"); Console.Out.Write("testing SessionHelper categoryForClient after connect... "); Console.Out.Flush(); try { test(!_session.categoryForClient().Equals("")); } catch(Glacier2.SessionNotExistException) { test(false); } Console.Out.WriteLine("ok"); // try // { // test(_session.session() != null); // } // catch(Glacier2.SessionNotExistException ex) // { // test(false); // } Console.Out.Write("testing stringToProxy for server object... "); Console.Out.Flush(); Ice.ObjectPrx @base = _session.communicator().stringToProxy("callback:default -p 12010"); Console.Out.WriteLine("ok"); Console.Out.Write("pinging server after session creation... "); Console.Out.Flush(); @base.ice_ping(); Console.Out.WriteLine("ok"); Console.Out.Write("testing checked cast for server object... "); Console.Out.Flush(); CallbackPrx twoway = CallbackPrxHelper.checkedCast(@base); test(twoway != null); Console.Out.WriteLine("ok"); Console.Out.Write("testing server shutdown... "); Console.Out.Flush(); twoway.shutdown(); Console.Out.WriteLine("ok"); test(_session.communicator() != null); Console.Out.Write("testing SessionHelper destroy... "); Console.Out.Flush(); _session.destroy(); while(true) { #if COMPACT System.Threading.Monitor.Wait(this); break; #else try { System.Threading.Monitor.Wait(this); break; } catch(ThreadInterruptedException) { } #endif } Console.Out.Write("testing SessionHelper isConnected after destroy... "); Console.Out.Flush(); test(_session.isConnected() == false); Console.Out.WriteLine("ok"); Console.Out.Write("testing SessionHelper categoryForClient after destroy... "); Console.Out.Flush(); try { test(!_session.categoryForClient().Equals("")); test(false); } catch(Glacier2.SessionNotExistException) { } Console.Out.WriteLine("ok"); Console.Out.Write("testing SessionHelper session after destroy... "); try { _session.session(); test(false); } catch(Glacier2.SessionNotExistException) { } Console.Out.WriteLine("ok"); Console.Out.Write("testing SessionHelper communicator after destroy... "); Console.Out.Flush(); try { test(_session.communicator() != null); _session.communicator().stringToProxy("dummy"); test(false); } catch(Ice.CommunicatorDestroyedException) { } Console.Out.WriteLine("ok"); Console.Out.Write("uninstalling router with communicator... "); Console.Out.Flush(); communicator().setDefaultRouter(null); Console.Out.WriteLine("ok"); Ice.ObjectPrx processBase; { Console.Out.Write("testing stringToProxy for process object... "); processBase = communicator().stringToProxy("Glacier2/admin -f Process:default -h \"" + host + "\" -p 12348"); Console.Out.WriteLine("ok"); } Ice.ProcessPrx process; { Console.Out.Write("testing checked cast for admin object... "); process = Ice.ProcessPrxHelper.checkedCast(processBase); test(process != null); Console.Out.WriteLine("ok"); } Console.Out.Write("testing Glacier2 shutdown... "); process.shutdown(); try { process.ice_ping(); test(false); } catch(Ice.LocalException) { Console.Out.WriteLine("ok"); } } _factory = new Glacier2.SessionFactoryHelper(_initData, new SessionCalback3()); lock(this) { Console.Out.Write("testing SessionHelper connect after router shutdown... "); Console.Out.Flush(); _factory.setRouterHost(host); _factory.setPort(12347); _factory.setProtocol(protocol); _session = _factory.connect("userid", "abc123"); while(true) { #if COMPACT System.Threading.Monitor.Wait(this); break; #else try { System.Threading.Monitor.Wait(this); break; } catch(ThreadInterruptedException) { } #endif } Console.Out.Write("testing SessionHelper isConnect after connect failure... "); Console.Out.Flush(); test(_session.isConnected() == false); Console.Out.WriteLine("ok"); Console.Out.Write("testing SessionHelper communicator after connect failure... "); Console.Out.Flush(); try { test(_session.communicator() != null); _session.communicator().stringToProxy("dummy"); test(false); } catch(Ice.CommunicatorDestroyedException) { } Console.Out.WriteLine("ok"); Console.Out.Write("testing SessionHelper destroy after connect failure... "); Console.Out.Flush(); _session.destroy(); Console.Out.WriteLine("ok"); } return 0; }
public override void run(string[] args) { Ice.InitializationData initData = new Ice.InitializationData(); initData.properties = createTestProperties(ref args); initData.properties.setProperty("Ice.Warn.Connections", "0"); initData.properties.setProperty("Ice.Default.Router", "Glacier2/router:" + getTestEndpoint(initData.properties, 50)); initData.dispatcher = delegate(Action action, Ice.Connection connection) { action(); }; using (var communicator = initialize(initData)) { string protocol = getTestProtocol(); string host = getTestHost(); Glacier2.SessionFactoryHelper factory = new Glacier2.SessionFactoryHelper(initData, new SessionCallback1(this)); Glacier2.SessionHelper session = null; // // Test to create a session with wrong userid/password // lock (this) { Console.Out.Write("testing SessionHelper connect with wrong userid/password... "); Console.Out.Flush(); factory.setProtocol(protocol); session = factory.connect("userid", "xxx"); while (true) { try { Monitor.Wait(this, 30000); break; } catch (ThreadInterruptedException) { } } test(!session.isConnected()); } initData.properties.setProperty("Ice.Default.Router", ""); factory = new Glacier2.SessionFactoryHelper(initData, new SessionCallback4(this)); lock (this) { Console.Out.Write("testing SessionHelper connect interrupt... "); Console.Out.Flush(); factory.setRouterHost(host); factory.setPort(getTestPort(1)); factory.setProtocol(protocol); session = factory.connect("userid", "abc123"); Thread.Sleep(100); session.destroy(); while (true) { try { Monitor.Wait(this, 30000); break; } catch (ThreadInterruptedException) { } } test(!session.isConnected()); } factory = new Glacier2.SessionFactoryHelper(initData, new SessionCallback2(this)); lock (this) { Console.Out.Write("testing SessionHelper connect... "); Console.Out.Flush(); factory.setRouterHost(host); factory.setPort(getTestPort(50)); factory.setProtocol(protocol); session = factory.connect("userid", "abc123"); while (true) { try { Monitor.Wait(this, 30000); break; } catch (ThreadInterruptedException) { } } Console.Out.Write("testing SessionHelper isConnected after connect... "); Console.Out.Flush(); test(session.isConnected()); Console.Out.WriteLine("ok"); Console.Out.Write("testing SessionHelper categoryForClient after connect... "); Console.Out.Flush(); try { test(!session.categoryForClient().Equals("")); } catch (Glacier2.SessionNotExistException) { test(false); } Console.Out.WriteLine("ok"); test(session.session() == null); Console.Out.Write("testing stringToProxy for server object... "); Console.Out.Flush(); Ice.ObjectPrx @base = session.communicator().stringToProxy("callback:" + getTestEndpoint(0)); Console.Out.WriteLine("ok"); Console.Out.Write("pinging server after session creation... "); Console.Out.Flush(); @base.ice_ping(); Console.Out.WriteLine("ok"); Console.Out.Write("testing checked cast for server object... "); Console.Out.Flush(); CallbackPrx twoway = CallbackPrxHelper.checkedCast(@base); test(twoway != null); Console.Out.WriteLine("ok"); Console.Out.Write("testing server shutdown... "); Console.Out.Flush(); twoway.shutdown(); Console.Out.WriteLine("ok"); test(session.communicator() != null); Console.Out.Write("testing SessionHelper destroy... "); Console.Out.Flush(); session.destroy(); while (true) { try { Monitor.Wait(this); break; } catch (ThreadInterruptedException) { } } Console.Out.Write("testing SessionHelper isConnected after destroy... "); Console.Out.Flush(); test(session.isConnected() == false); Console.Out.WriteLine("ok"); Console.Out.Write("testing SessionHelper categoryForClient after destroy... "); Console.Out.Flush(); try { test(!session.categoryForClient().Equals("")); test(false); } catch (Glacier2.SessionNotExistException) { } Console.Out.WriteLine("ok"); Console.Out.Write("testing SessionHelper session after destroy... "); test(session.session() == null); Console.Out.WriteLine("ok"); Console.Out.Write("testing SessionHelper communicator after destroy... "); Console.Out.Flush(); try { test(session.communicator() != null); session.communicator().stringToProxy("dummy"); test(false); } catch (Ice.CommunicatorDestroyedException) { } Console.Out.WriteLine("ok"); Console.Out.Write("uninstalling router with communicator... "); Console.Out.Flush(); communicator.setDefaultRouter(null); Console.Out.WriteLine("ok"); Ice.ObjectPrx processBase; { Console.Out.Write("testing stringToProxy for process object... "); processBase = communicator.stringToProxy("Glacier2/admin -f Process:" + getTestEndpoint(51)); Console.Out.WriteLine("ok"); } Ice.ProcessPrx process; { Console.Out.Write("testing checked cast for admin object... "); process = Ice.ProcessPrxHelper.checkedCast(processBase); test(process != null); Console.Out.WriteLine("ok"); } Console.Out.Write("testing Glacier2 shutdown... "); process.shutdown(); try { process.ice_ping(); test(false); } catch (Ice.LocalException) { Console.Out.WriteLine("ok"); } } factory = new Glacier2.SessionFactoryHelper(initData, new SessionCallback3(this)); lock (this) { Console.Out.Write("testing SessionHelper connect after router shutdown... "); Console.Out.Flush(); factory.setRouterHost(host); factory.setPort(getTestPort(50)); factory.setProtocol(protocol); session = factory.connect("userid", "abc123"); while (true) { try { Monitor.Wait(this); break; } catch (ThreadInterruptedException) { } } Console.Out.Write("testing SessionHelper isConnect after connect failure... "); Console.Out.Flush(); test(session.isConnected() == false); Console.Out.WriteLine("ok"); Console.Out.Write("testing SessionHelper communicator after connect failure... "); Console.Out.Flush(); try { test(session.communicator() != null); session.communicator().stringToProxy("dummy"); test(false); } catch (Ice.CommunicatorDestroyedException) { } Console.Out.WriteLine("ok"); Console.Out.Write("testing SessionHelper destroy after connect failure... "); Console.Out.Flush(); session.destroy(); Console.Out.WriteLine("ok"); } } }
public override void run(string[] args) { var properties = createTestProperties(ref args); properties["Ice.Warn.Connections"] = "0"; properties["Ice.Default.Router"] = $"Glacier2/router:{getTestEndpoint(properties, 50)}"; using var communicator = initialize(properties); string transport = getTestTransport(); string host = getTestHost(); Glacier2.SessionFactoryHelper factory = new Glacier2.SessionFactoryHelper(new SessionCallback1(this), properties); Glacier2.SessionHelper? session = null; // // Test to create a session with wrong userid/password // lock (this) { Console.Out.Write("testing SessionHelper connect with wrong userid/password... "); Console.Out.Flush(); factory.setTransport(transport); session = factory.connect("userid", "xxx"); while (true) { try { if (!Monitor.Wait(this, 30000)) { test(false); } break; } catch (ThreadInterruptedException) { } } test(!session.IsConnected()); } properties.Remove("Ice.Default.Router"); factory = new Glacier2.SessionFactoryHelper(new SessionCallback4(this), properties); lock (this) { Console.Out.Write("testing SessionHelper connect interrupt... "); Console.Out.Flush(); factory.setRouterHost(host); factory.setPort(getTestPort(1)); factory.setTransport(transport); session = factory.connect("userid", "abc123"); Thread.Sleep(100); session.Destroy(); while (true) { try { if (!Monitor.Wait(this, 30000)) { test(false); } break; } catch (ThreadInterruptedException) { } } test(!session.IsConnected()); } factory = new Glacier2.SessionFactoryHelper(new SessionCallback2(this), properties); lock (this) { Console.Out.Write("testing SessionHelper connect... "); Console.Out.Flush(); factory.setRouterHost(host); factory.setPort(getTestPort(50)); factory.setTransport(transport); session = factory.connect("userid", "abc123"); while (true) { try { if (!Monitor.Wait(this, 30000)) { test(false); } break; } catch (ThreadInterruptedException) { } } Console.Out.Write("testing SessionHelper isConnected after connect... "); Console.Out.Flush(); test(session.IsConnected()); Console.Out.WriteLine("ok"); Console.Out.Write("testing SessionHelper categoryForClient after connect... "); Console.Out.Flush(); try { test(!session.CategoryForClient().Equals("")); } catch (Glacier2.SessionNotExistException) { test(false); } Console.Out.WriteLine("ok"); test(session.Session() == null); Console.Out.Write("testing stringToProxy for server object... "); Console.Out.Flush(); var @base = IObjectPrx.Parse($"callback:{getTestEndpoint(0)}", session.Communicator()); Console.Out.WriteLine("ok"); Console.Out.Write("pinging server after session creation... "); Console.Out.Flush(); @base.IcePing(); Console.Out.WriteLine("ok"); Console.Out.Write("testing checked cast for server object... "); Console.Out.Flush(); var twoway = ICallbackPrx.CheckedCast(@base); Console.Out.WriteLine("ok"); Console.Out.Write("testing server shutdown... "); Console.Out.Flush(); twoway.shutdown(); Console.Out.WriteLine("ok"); test(session.Communicator() != null); Console.Out.Write("testing SessionHelper destroy... "); Console.Out.Flush(); session.Destroy(); while (true) { try { if (!Monitor.Wait(this, 30000)) { test(false); } break; } catch (ThreadInterruptedException) { } } Console.Out.Write("testing SessionHelper isConnected after destroy... "); Console.Out.Flush(); test(session.IsConnected() == false); Console.Out.WriteLine("ok"); Console.Out.Write("testing SessionHelper categoryForClient after destroy... "); Console.Out.Flush(); try { test(!session.CategoryForClient().Equals("")); test(false); } catch (Glacier2.SessionNotExistException) { } Console.Out.WriteLine("ok"); Console.Out.Write("testing SessionHelper session after destroy... "); test(session.Session() == null); Console.Out.WriteLine("ok"); Console.Out.Write("testing SessionHelper communicator after destroy... "); Console.Out.Flush(); try { test(session.Communicator() != null); IObjectPrx.Parse("dummy", session.Communicator()); test(false); } catch (CommunicatorDestroyedException) { } Console.Out.WriteLine("ok"); 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 process object... "); processBase = IObjectPrx.Parse($"Glacier2/admin -f Process:{getTestEndpoint(51)}", communicator); Console.Out.WriteLine("ok"); } IProcessPrx process; { Console.Out.Write("testing checked cast for admin object... "); process = Ice.IProcessPrx.CheckedCast(processBase); test(process != null); Console.Out.WriteLine("ok"); } Console.Out.Write("testing Glacier2 shutdown... "); process.Shutdown(); try { process.IcePing(); test(false); } catch (LocalException) { Console.Out.WriteLine("ok"); } } factory = new Glacier2.SessionFactoryHelper(new SessionCallback3(this), properties); lock (this) { Console.Out.Write("testing SessionHelper connect after router shutdown... "); Console.Out.Flush(); factory.setRouterHost(host); factory.setPort(getTestPort(50)); factory.setTransport(transport); session = factory.connect("userid", "abc123"); while (true) { try { if (!Monitor.Wait(this, 30000)) { test(false); } break; } catch (ThreadInterruptedException) { } } Console.Out.Write("testing SessionHelper isConnect after connect failure... "); Console.Out.Flush(); test(session.IsConnected() == false); Console.Out.WriteLine("ok"); Console.Out.Write("testing SessionHelper communicator after connect failure... "); Console.Out.Flush(); try { test(session.Communicator() != null); IObjectPrx.Parse("dummy", session.Communicator()); test(false); } catch (CommunicatorDestroyedException) { } Console.Out.WriteLine("ok"); Console.Out.Write("testing SessionHelper destroy after connect failure... "); Console.Out.Flush(); session.Destroy(); Console.Out.WriteLine("ok"); } }
public override int run(string[] args) { _factory = new Glacier2.SessionFactoryHelper(_initData, new SessionCalback1()); // // Test to create a session with wrong userid/password // lck.Lock(); try { Console.Out.Write("testing SessionHelper connect with wrong userid/password... "); Console.Out.Flush(); _factory.setRouterHost("127.0.0.1"); _factory.setPort(12347); _factory.setRouterIdentity(Ice.Util.stringToIdentity("Glacier2/router")); _factory.setSecure(false); _session = _factory.connect("userid", "xxx"); while (true) { #if COMPACT lck.Wait(); break; #else try { lck.Wait(); break; } catch (ThreadInterruptedException) { } #endif } } finally { lck.Unlock(); } _factory = new Glacier2.SessionFactoryHelper(_initData, new SessionCalback2()); lck.Lock(); try { Console.Out.Write("testing SessionHelper connect... "); Console.Out.Flush(); _factory.setRouterHost("127.0.0.1"); _factory.setPort(12347); _factory.setRouterIdentity(Ice.Util.stringToIdentity("Glacier2/router")); _factory.setSecure(false); _session = _factory.connect("userid", "abc123"); while (true) { #if COMPACT lck.Wait(); break; #else try { lck.Wait(); break; } catch (ThreadInterruptedException) { } #endif } Console.Out.Write("testing SessionHelper isConnected after connect... "); Console.Out.Flush(); test(_session.isConnected()); Console.Out.WriteLine("ok"); Console.Out.Write("testing SessionHelper categoryForClient after connect... "); Console.Out.Flush(); try { test(!_session.categoryForClient().Equals("")); } catch (Glacier2.SessionNotExistException) { test(false); } Console.Out.WriteLine("ok"); // try // { // test(_session.session() != null); // } // catch(Glacier2.SessionNotExistException ex) // { // test(false); // } Console.Out.Write("testing stringToProxy for server object... "); Console.Out.Flush(); Ice.ObjectPrx @base = _session.communicator().stringToProxy("callback:tcp -p 12010"); Console.Out.WriteLine("ok"); Console.Out.Write("pinging server after session creation... "); Console.Out.Flush(); @base.ice_ping(); Console.Out.WriteLine("ok"); Console.Out.Write("testing checked cast for server object... "); Console.Out.Flush(); CallbackPrx twoway = CallbackPrxHelper.checkedCast(@base); test(twoway != null); Console.Out.WriteLine("ok"); Console.Out.Write("testing server shutdown... "); Console.Out.Flush(); twoway.shutdown(); Console.Out.WriteLine("ok"); test(_session.communicator() != null); Console.Out.Write("testing SessionHelper destroy... "); Console.Out.Flush(); _session.destroy(); while (true) { #if COMPACT lck.Wait(); break; #else try { lck.Wait(); break; } catch (ThreadInterruptedException) { } #endif } Console.Out.Write("testing SessionHelper isConnected after destroy... "); Console.Out.Flush(); test(_session.isConnected() == false); Console.Out.WriteLine("ok"); Console.Out.Write("testing SessionHelper categoryForClient after destroy... "); Console.Out.Flush(); try { test(!_session.categoryForClient().Equals("")); test(false); } catch (Glacier2.SessionNotExistException) { } Console.Out.WriteLine("ok"); Console.Out.Write("testing SessionHelper session after destroy... "); try { _session.session(); test(false); } catch (Glacier2.SessionNotExistException) { } Console.Out.WriteLine("ok"); Console.Out.Write("testing SessionHelper communicator after destroy... "); Console.Out.Flush(); test(_session.communicator() != null); Console.Out.WriteLine("ok"); Console.Out.Write("uninstalling router with communicator... "); Console.Out.Flush(); communicator().setDefaultRouter(null); Console.Out.WriteLine("ok"); Ice.ObjectPrx processBase; { Console.Out.Write("testing stringToProxy for process object... "); processBase = communicator().stringToProxy("Glacier2/admin -f Process:tcp -h 127.0.0.1 -p 12348"); Console.Out.WriteLine("ok"); } Ice.ProcessPrx process; { Console.Out.Write("testing checked cast for admin object... "); process = Ice.ProcessPrxHelper.checkedCast(processBase); test(process != null); Console.Out.WriteLine("ok"); } Console.Out.Write("testing Glacier2 shutdown... "); process.shutdown(); try { process.ice_ping(); test(false); } catch (Ice.LocalException) { Console.Out.WriteLine("ok"); } } finally { lck.Unlock(); } _factory = new Glacier2.SessionFactoryHelper(_initData, new SessionCalback3()); lck.Lock(); try { Console.Out.Write("testing SessionHelper connect after router shutdown... "); Console.Out.Flush(); _factory.setRouterHost("127.0.0.1"); _factory.setPort(12347); _factory.setRouterIdentity(Ice.Util.stringToIdentity("Glacier2/router")); _factory.setSecure(false); _session = _factory.connect("userid", "abc123"); while (true) { #if COMPACT lck.Wait(); break; #else try { lck.Wait(); break; } catch (ThreadInterruptedException) { } #endif } Console.Out.Write("testing SessionHelper isConnect after connect failure... "); Console.Out.Flush(); test(_session.isConnected() == false); Console.Out.WriteLine("ok"); Console.Out.Write("testing SessionHelper communicator after connect failure... "); Console.Out.Flush(); test(_session.communicator() != null); Console.Out.WriteLine("ok"); Console.Out.Write("testing SessionHelper destroy after connect failure... "); Console.Out.Flush(); _session.destroy(); Console.Out.WriteLine("ok"); } finally { lck.Unlock(); } return(0); }