Java 类javax.management.relation.RelationServiceNotRegisteredException 实例源码

项目:freeVM    文件:StructureTest.java   
/**
 * 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();
    }
}
项目:freeVM    文件:StructureTest.java   
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());
        }
    }
项目:freeVM    文件:ERelationMBean.java   
void unregisterMBean(ObjectName mBeanName, String roleName)
throws RoleNotFoundException, InvalidRoleValueException,
RelationServiceNotRegisteredException,
RelationTypeNotFoundException, RelationNotFoundException,
IllegalArgumentException;