Search in sources :

Example 56 with ClientInfo

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

the class ManagerImplTest method testContainerInfo.

public void testContainerInfo() {
    try {
        //test invalid
        try {
            manager.getContainerInfo(0, null, null);
            fail();
        } catch (BadParametersException bpe) {
            System.out.println("This is OK: " + bpe.getMessage());
        }
        //test invalid
        try {
            manager.getContainerInfo(Integer.MAX_VALUE, null, null);
            fail();
        } catch (BadParametersException bpe) {
            System.out.println("This is OK: " + bpe.getMessage());
        }
        //test invalid
        try {
            manager.getContainerInfo(dummyHandle, null, null);
            fail();
        } catch (BadParametersException bpe) {
            System.out.println("This is OK: " + bpe.getMessage());
        }
        //test invalid
        try {
            manager.getContainerInfo(dummyHandle, new int[0], null);
            fail();
        } catch (BadParametersException bpe) {
            System.out.println("This is OK: " + bpe.getMessage());
        }
        //test invalid
        try {
            manager.getContainerInfo(dummyHandle, new int[0], "non-null");
            fail();
        } catch (AcsJNoPermissionEx npe) {
            System.out.println("This is OK: " + npe.toString());
        }
        /*
			//test invalid regular expression
			try {
				manager.getContainerInfo(dummyHandle, new int[0], ")");		
				fail();
			}
			catch (BadParametersException bpe)
			{
	
				System.out.println("This is OK: "+bpe.getMessage());
			}
			*/
        //test valid
        ClientInfo info = manager.login(new TestContainer(containerName));
        int[] handles = { info.getHandle() };
        ContainerInfo[] infos = manager.getContainerInfo(info.getHandle(), handles, null);
        assertNotNull(infos);
        assertEquals(infos.length, 1);
        assertEquals(infos[0].getHandle(), info.getHandle());
        manager.logout(info.getHandle());
        //test inaccessible
        info = manager.login(new TestContainer(containerName));
        ClientInfo anotherInfo = manager.login(new TestContainer(anotherName));
        handles[0] = anotherInfo.getHandle();
        try {
            infos = manager.getContainerInfo(info.getHandle(), handles, null);
            fail();
        } catch (AcsJNoPermissionEx npe) {
            System.out.println("This is OK: " + npe.toString());
        }
        try {
            manager.getClientInfo(info.getHandle(), new int[0], anotherName);
            fail();
        } catch (AcsJNoPermissionEx npe) {
            System.out.println("This is OK: " + npe.toString());
        }
        manager.logout(info.getHandle());
        manager.logout(anotherInfo.getHandle());
        //test with INTROSPECTION_MANAGER rights
        info = manager.login(new TestContainer(containerName));
        ClientInfo adminInfo = manager.login(new TestAdministrator(administratorName));
        handles = new int[3];
        handles[0] = adminInfo.getHandle();
        handles[1] = info.getHandle();
        handles[2] = dummyHandle;
        infos = manager.getContainerInfo(adminInfo.getHandle(), handles, null);
        assertNotNull(infos);
        assertNull(infos[0]);
        assertEquals(infos[1].getHandle(), info.getHandle());
        assertNull(infos[2]);
        manager.logout(info.getHandle());
        manager.logout(adminInfo.getHandle());
        // test wildcard search		
        info = manager.login(new TestContainer("container1"));
        assertNotNull(info);
        ClientInfo info2 = manager.login(new TestContainer("container2a"));
        assertNotNull(info2);
        ClientInfo info3 = manager.login(new TestContainer("container3aa"));
        assertNotNull(info3);
        ClientInfo info4 = manager.login(new TestContainer("other4"));
        assertNotNull(info4);
        adminInfo = manager.login(new TestAdministrator("admin"));
        assertNotNull(adminInfo);
        //infos = manager.getContainerInfo(adminInfo.getHandle(), new int[0], "container.*");
        infos = manager.getContainerInfo(adminInfo.getHandle(), new int[0], "container*");
        assertNotNull(infos);
        assertEquals(3, infos.length);
        assertEquals(info.getHandle(), infos[0].getHandle());
        assertEquals(info2.getHandle(), infos[1].getHandle());
        assertEquals(info3.getHandle(), infos[2].getHandle());
        manager.logout(info.getHandle());
        manager.logout(info2.getHandle());
        manager.logout(info3.getHandle());
        manager.logout(info4.getHandle());
        manager.logout(adminInfo.getHandle());
    } catch (AcsJNoPermissionEx e) {
        fail("No permission");
    }
}
Also used : AcsJNoPermissionEx(alma.maciErrType.wrappers.AcsJNoPermissionEx) ContainerInfo(com.cosylab.acs.maci.ContainerInfo) ClientInfo(com.cosylab.acs.maci.ClientInfo) BadParametersException(com.cosylab.acs.maci.BadParametersException)

Aggregations

ClientInfo (com.cosylab.acs.maci.ClientInfo)56 AcsJNoPermissionEx (alma.maciErrType.wrappers.AcsJNoPermissionEx)39 BadParametersException (com.cosylab.acs.maci.BadParametersException)23 ComponentInfo (com.cosylab.acs.maci.ComponentInfo)23 NoResourcesException (com.cosylab.acs.maci.NoResourcesException)21 HashMap (java.util.HashMap)21 Map (java.util.Map)21 Component (com.cosylab.acs.maci.Component)18 RemoteException (com.cosylab.acs.maci.RemoteException)18 URI (java.net.URI)18 NoDefaultComponentException (com.cosylab.acs.maci.NoDefaultComponentException)17 URISyntaxException (java.net.URISyntaxException)17 StatusHolder (com.cosylab.acs.maci.StatusHolder)16 AcsJBadParameterEx (alma.ACSErrTypeCommon.wrappers.AcsJBadParameterEx)8 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)8 AcsJCannotGetComponentEx (alma.maciErrType.wrappers.AcsJCannotGetComponentEx)7 ContainerInfo (com.cosylab.acs.maci.ContainerInfo)7 ArrayList (java.util.ArrayList)7 Client (com.cosylab.acs.maci.Client)6 Administrator (com.cosylab.acs.maci.Administrator)5