/** * This testCase verifies IsActive method. */ public Result testIsActive() throws Exception { MBeanServer mBeanServer = MBeanServerFactory.createMBeanServer(); RelationService relationService = new RelationService(true); ObjectName relationServiceName = new ObjectName( "mBeanServer:type=RelationService,name=rs"); mBeanServer.registerMBean(relationService, relationServiceName); mBeanServer.unregisterMBean(relationServiceName); try { relationService.isActive(); return failed("isActive method incorrect"); } catch (RelationServiceNotRegisteredException e) { return passed(); } }
public Result testNotRegisteredException() throws Exception { /* Initialisation without registering */ MBeanServer server = MBeanServerFactory.createMBeanServer(); ObjectName unitName = new ObjectName("a:b=c"); server.registerMBean(new Unit(), unitName); RelationService rService = new RelationService(true); RoleInfo[] rInfo = { new RoleInfo("role", classPath) }; rService.createRelationType("relationType", rInfo); RoleList unitRoles = new RoleList(); unitRoles.add(new Role("role", Collections.singletonList(unitName))); /* catch RelationServiceNotRegisteredException */ try { rService.createRelation("relation", "relationType", unitRoles); return failed(""); } catch (RelationServiceNotRegisteredException e) { return passed(); } catch (Throwable t) { return failed(t.toString()); } }
void unregisterMBean(ObjectName mBeanName, String roleName) throws RoleNotFoundException, InvalidRoleValueException, RelationServiceNotRegisteredException, RelationTypeNotFoundException, RelationNotFoundException, IllegalArgumentException;