/**
* This testcase verifies MBeanToUnregister field in notifications.
*/
public Result testRemovalNotification() throws Exception {
incorrectNotificationFlag = false;
MBeanServer mBeanServer = MBeanServerFactory.createMBeanServer();
RelationService relationService = new RelationService(true);
ObjectName relationServiceName = new ObjectName(
"mBeanServer:type=RelationService,name=rs");
mBeanServer.registerMBean(relationService, relationServiceName);
NotificationFilterSupport filter = new NotificationFilterSupport();
filter.enableType("jmx.relation");
relationService.addNotificationListener(this, filter, null);
checkNotifications = true;
RoleInfo[] roleInfo = new RoleInfo[1];
roleInfo[0] = new RoleInfo("unitRole", classPath, true, true, 1, 2,
"Unit role");
// Creating an Internal Relation Type
relationService.createRelationType("internalRelationType", roleInfo);
UnitMBean unit = new Unit();
ObjectName unitName = new ObjectName("mBeanServer:type=Unit,name=Unit");
mBeanServer.registerMBean(unit, unitName);
ArrayList unitList = new ArrayList();
unitList.add(unitName);
Role unitRole = new Role("unitRole", unitList);
RoleList unitRoles = new RoleList();
unitRoles.add(unitRole);
// Now Create relations between unit MBeans
// Notification Data
relationNotification = new RelationNotificationForCompare(
"jmx.relation.creation.basic", relationService, 1, 10,
"Creation of relation internalRelation", "internalRelation",
"internalRelationType", null, null);
relationService.createRelation("internalRelation",
"internalRelationType", unitRoles);
// Notification Data
relationNotification = new RelationNotificationForCompare(
"jmx.relation.removal.basic", relationService, 2, 10,
"Removal of relation internalRelation", "internalRelation",
"internalRelationType", null, new ArrayList());
relationService.removeRelation("internalRelation");
if (incorrectNotificationFlag) {
return failed("IncorrectNotifications (see log for more information)");
}
return passed();
}
StructureTest.java 文件源码
java
阅读 18
收藏 0
点赞 0
评论 0
项目:freeVM
作者:
评论列表
文章目录