use of com.cosylab.acs.maci.plug.ClientProxyImpl in project ACS by ACS-Community.
the class ManagerImplSerializationTest method testClientLogin.
public void testClientLogin() {
// login a client
ClientProxyImpl client = new ClientProxyImpl(clientName, myManager.getManagerEngine().getLogger());
client.login(orb, manager);
// get object as it is stored in recovery store
ManagerImpl newManager = (ManagerImpl) deserializeManager(new ManagerImpl());
// since we used clean recovery store we must have our client only there
HandleDataStore clients = newManager.getClients();
assertEquals(clients.first(), 1);
com.cosylab.acs.maci.ClientInfo clientInfo = (com.cosylab.acs.maci.ClientInfo) clients.get(clients.first());
assertEquals(clientInfo.getName(), clientName);
client.logout();
// read state again
newManager = (ManagerImpl) deserializeManager(new ManagerImpl());
clients = newManager.getClients();
assertEquals(clients.first(), 0);
}
use of com.cosylab.acs.maci.plug.ClientProxyImpl in project ACS by ACS-Community.
the class ManagerImplSerializationTest method testClientDie.
public void testClientDie() {
// should be something else then deafault because
// the default is in use by the Manager
Properties table = new Properties();
table.put("OAPort", "12121");
// new ORB instance
ORB ourOrb = ORB.init(new String[0], table);
try {
POA rootPOA = POAHelper.narrow(ourOrb.resolve_initial_references("RootPOA"));
// activate POA
POAManager manager = rootPOA.the_POAManager();
manager.activate();
} catch (Exception e) {
e.printStackTrace();
}
ClientProxyImpl client = new ClientProxyImpl(clientName, myManager.getManagerEngine().getLogger());
client.login(ourOrb, manager);
// just destroy its ORB
ourOrb.shutdown(true);
// get object as it is stored in recovery store
ManagerImpl newManager = (ManagerImpl) deserializeManager(new ManagerImpl());
HandleDataStore clients = newManager.getClients();
// the client now is still in stored data
assertEquals(clients.first(), 1);
newManager.initialize(null, null, null, null, null);
// now wait for timer task to remove client
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
fail();
}
// since the client died the menager automaticaly log it out
clients = newManager.getClients();
// not any more
assertEquals(clients.first(), 0);
}
Aggregations