public Result testExistenceAfterException() throws Exception {
MBeanServer server = MBeanServerFactory.createMBeanServer();
ObjectName unitName = new ObjectName("a:b=c");
server.registerMBean(new Unit(), unitName);
RelationService rService = new RelationService(true);
server.registerMBean(rService, new ObjectName("a:b=d"));
RoleInfo[] rInfo = { new RoleInfo("role", classPath),
new RoleInfo("another role", classPath) };
rService.createRelationType("relationType", rInfo);
RoleList unitRoles = new RoleList();
/*
* "anotherRole is incorrect - the number of MBeans is less than
* default"
*/
unitRoles.add(new Role("role", Collections.singletonList(unitName)));
unitRoles.add(new Role("another role", new ArrayList()));
try {
rService.createRelation("relation", "relationType", unitRoles);
System.out.println("existenceAfterExceptions test failed");
} catch (InvalidRoleValueException e) {
/* this exception should be caught */
} catch (Throwable t) {
System.out.println("existenceAfterExceptions test failed: "
+ t.toString());
}
/* now verify is relation exists */
if (!rService.getAllRelationIds().contains("relation")) {
return passed();
}
return failed("");
}
StructureTest.java 文件源码
java
阅读 19
收藏 0
点赞 0
评论 0
项目:freeVM
作者:
评论列表
文章目录