Search in sources :

Example 66 with ComponentInfo

use of com.cosylab.acs.maci.ComponentInfo in project ACS by ACS-Community.

the class ManagerImplTest method internalTestGetHierarchicalComponent.

public void internalTestGetHierarchicalComponent(boolean activateOnActivation) {
    try {
        TestContainer container = new TestContainer("Container");
        Map supportedComponents = new HashMap();
        TestHierarchicalComponent mount2HierCOB = new TestHierarchicalComponent("HierarchicalCOB2", manager, new String[] { "MOUNT3" }, false, activateOnActivation);
        TestHierarchicalComponent mount3HierCOB = new TestHierarchicalComponent("HierarchicalCOB3", manager, new String[] { "MOUNT4" }, false, activateOnActivation);
        Component mount4COB = new TestComponent("MOUNT4");
        supportedComponents.put("MOUNT2", mount2HierCOB);
        supportedComponents.put("MOUNT3", mount3HierCOB);
        supportedComponents.put("MOUNT4", mount4COB);
        container.setSupportedComponents(supportedComponents);
        // test case when container is unable to activate startup Component - MOUNT1
        ClientInfo containerInfo = manager.login(container);
        TestAdministrator client = new TestAdministrator(administratorName);
        ClientInfo info = manager.login(client);
        // test ordinary activation
        URI mount2URI;
        try {
            mount2URI = new URI("MOUNT2");
            StatusHolder status = new StatusHolder();
            Component ref = manager.getComponent(info.getHandle(), mount2URI, true, status);
            assertEquals(mount2HierCOB, ref);
            assertEquals(ComponentStatus.COMPONENT_ACTIVATED, status.getStatus());
        } catch (Exception ex) {
            fail();
        }
        try {
            Thread.sleep(STARTUP_COBS_SLEEP_TIME_MS);
        } catch (InterruptedException ie) {
        }
        // test activated Components
        // there should be all three Components activated
        ComponentInfo[] infos = manager.getComponentInfo(info.getHandle(), new int[0], "*", "*", true);
        assertEquals(3, infos.length);
        // container logout and login
        manager.logout(containerInfo.getHandle());
        try {
            Thread.sleep(SLEEP_TIME_MS);
        } catch (InterruptedException ie) {
        }
        // test activated Components
        // there should be no Components activated
        infos = manager.getComponentInfo(info.getHandle(), new int[0], "*", "*", true);
        assertEquals(0, infos.length);
        manager.login(container);
        try {
            Thread.sleep(STARTUP_COBS_SLEEP_TIME_MS);
        } catch (InterruptedException ie) {
        }
        // test activated Components
        // there should be all three Components activated
        infos = manager.getComponentInfo(info.getHandle(), new int[0], "*", "*", true);
        assertEquals(3, infos.length);
        // logout client
        manager.logout(info.getHandle());
        try {
            Thread.sleep(SLEEP_TIME_MS);
        } catch (InterruptedException ie) {
        }
    } catch (AcsJNoPermissionEx e) {
        fail("No permission");
    }
}
Also used : HashMap(java.util.HashMap) URI(java.net.URI) RemoteException(com.cosylab.acs.maci.RemoteException) URISyntaxException(java.net.URISyntaxException) BadParametersException(com.cosylab.acs.maci.BadParametersException) NoResourcesException(com.cosylab.acs.maci.NoResourcesException) NoDefaultComponentException(com.cosylab.acs.maci.NoDefaultComponentException) StatusHolder(com.cosylab.acs.maci.StatusHolder) AcsJNoPermissionEx(alma.maciErrType.wrappers.AcsJNoPermissionEx) ClientInfo(com.cosylab.acs.maci.ClientInfo) ComponentInfo(com.cosylab.acs.maci.ComponentInfo) Component(com.cosylab.acs.maci.Component) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

ComponentInfo (com.cosylab.acs.maci.ComponentInfo)66 AcsJNoPermissionEx (alma.maciErrType.wrappers.AcsJNoPermissionEx)24 NoResourcesException (com.cosylab.acs.maci.NoResourcesException)24 BadParametersException (com.cosylab.acs.maci.BadParametersException)23 ClientInfo (com.cosylab.acs.maci.ClientInfo)23 RemoteException (com.cosylab.acs.maci.RemoteException)22 HashMap (java.util.HashMap)20 NoDefaultComponentException (com.cosylab.acs.maci.NoDefaultComponentException)19 Component (com.cosylab.acs.maci.Component)18 URISyntaxException (java.net.URISyntaxException)18 Map (java.util.Map)18 URI (java.net.URI)17 StatusHolder (com.cosylab.acs.maci.StatusHolder)15 AcsJBadParameterEx (alma.ACSErrTypeCommon.wrappers.AcsJBadParameterEx)10 AcsJCannotGetComponentEx (alma.maciErrType.wrappers.AcsJCannotGetComponentEx)10 ContainerInfo (com.cosylab.acs.maci.ContainerInfo)9 ArrayList (java.util.ArrayList)8 TimeoutRemoteException (com.cosylab.acs.maci.TimeoutRemoteException)7 ComponentSpec (com.cosylab.acs.maci.ComponentSpec)6 CoreException (com.cosylab.acs.maci.CoreException)6