Search in sources :

Example 1 with ClientProxyImpl

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);
}
Also used : ManagerImpl(com.cosylab.acs.maci.manager.ManagerImpl) ClientProxyImpl(com.cosylab.acs.maci.plug.ClientProxyImpl) HandleDataStore(com.cosylab.acs.maci.manager.HandleDataStore)

Example 2 with ClientProxyImpl

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);
}
Also used : POA(org.omg.PortableServer.POA) POAManager(org.omg.PortableServer.POAManager) ManagerImpl(com.cosylab.acs.maci.manager.ManagerImpl) ClientProxyImpl(com.cosylab.acs.maci.plug.ClientProxyImpl) HandleDataStore(com.cosylab.acs.maci.manager.HandleDataStore) Properties(java.util.Properties) ORB(org.omg.CORBA.ORB)

Aggregations

HandleDataStore (com.cosylab.acs.maci.manager.HandleDataStore)2 ManagerImpl (com.cosylab.acs.maci.manager.ManagerImpl)2 ClientProxyImpl (com.cosylab.acs.maci.plug.ClientProxyImpl)2 Properties (java.util.Properties)1 ORB (org.omg.CORBA.ORB)1 POA (org.omg.PortableServer.POA)1 POAManager (org.omg.PortableServer.POAManager)1