public SessionRefreshThread(SessionHelper session, Glacier2.RouterPrx router, int period) { _session = session; _router = router; _period = period; _done = false; }
disconnected(Glacier2.SessionHelper session) { Console.Out.WriteLine("ok"); lock (me) { wakeUp(); } }
connected(Glacier2.SessionHelper session) { Console.Out.WriteLine("ok"); me.lck.Lock(); try { wakeUp(); } finally { me.lck.Unlock(); } }
connectFailed(Glacier2.SessionHelper session, System.Exception exception) { try { throw exception; } catch (Ice.CommunicatorDestroyedException) { Console.Out.WriteLine("ok"); lock (me) { wakeUp(); } } catch (System.Exception) { test(false); } }
connectFailed(Glacier2.SessionHelper session, System.Exception exception) { try { throw exception; } catch (Glacier2.PermissionDeniedException) { Console.Out.WriteLine("ok"); lock (me) { wakeUp(); } } catch (System.Exception) { test(false); } }
connectFailed(Glacier2.SessionHelper session, System.Exception exception) { try { throw exception; } catch (Ice.ConnectionRefusedException) { Console.Out.WriteLine("ok"); me.lck.Lock(); try { wakeUp(); } finally { me.lck.Unlock(); } } catch (System.Exception) { test(false); } }
createdCommunicator(Glacier2.SessionHelper session) { test(session.communicator() != null); }
connectFailed(Glacier2.SessionHelper session, System.Exception ex) { Console.Out.WriteLine(ex.ToString()); test(false); }
/// <summary> /// Connect the Glacier2 session using user name and password credentials. /// /// Once the connection is established, SessionCallback.connected is called on /// the callback object; upon failure, SessionCallback.connectFailed is called /// with the exception. /// </summary> /// <param name="username">The user name.</param> /// <param name="password">The password.</param> /// <returns>The connected session.</returns> public SessionHelper connect( string username, string password) { lock(this) { SessionHelper session = new SessionHelper(_callback, createInitData(), getRouterFinderStr(), _useCallbacks); session.connect(username, password, _context); return session; } }
/// <summary> /// Connects to the Glacier2 router using the associated SSL credentials. /// /// Once the connection is established, SesssionCallback.connected is called on /// the callback object; upon failure, SessionCallback.connectFailed is called /// with the exception. /// </summary> /// <returns>The connected session.</returns> public SessionHelper connect() { lock(this) { SessionHelper session = new SessionHelper(_callback, createInitData(), getRouterFinderStr(), _useCallbacks); session.connect(_context); return session; } }
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; }
internal ConnectionCallbackI(SessionHelper sessionHelper) { _sessionHelper = sessionHelper; }
public SessionRefreshTask(SessionHelper session, Glacier2.RouterPrx router) { _session = session; _router = router; }
createdCommunicator(Glacier2.SessionHelper session) { Assert(session.Communicator() != null); }
disconnected(Glacier2.SessionHelper session) { test(false); }
RefreshI(SessionHelper helper, SessionRefreshThread thread) { _thread = thread; _helper = helper; }
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; }
disconnected(Glacier2.SessionHelper session) { Console.Out.WriteLine("ok"); _app.wakeUp(); }
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, 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 { if (!Monitor.Wait(this, 30000)) { test(false); } 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 { if (!Monitor.Wait(this, 30000)) { test(false); } 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 { 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(); CallbackPrx twoway = CallbackPrx.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 (Ice.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"); } ProcessPrx process; { Console.Out.Write("testing checked cast for admin object... "); process = Ice.ProcessPrx.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(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 { 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 void CreatedCommunicator(Glacier2.SessionHelper session) => Assert(session.Communicator() != null);
disconnected(Glacier2.SessionHelper session) => Assert(false);
/// <summary> /// Connects to the Glacier2 router using the associated SSL credentials. /// /// Once the connection is established, SesssionCallback.connected is called on /// the callback object; upon failure, SessionCallback.connectFailed is called /// with the exception. /// </summary> /// <returns>The connected session.</returns> public SessionHelper connect() { lock(this) { SessionHelper session = new SessionHelper(_callback, createInitData()); session.connect(_context); return session; } }
public void ConnectFailed(Glacier2.SessionHelper session, Exception ex) { Console.Out.WriteLine(ex.ToString()); Assert(false); }