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");
}
}
Aggregations