cons.setProfileLevel(ProfileLevel.MAX);
ObjectName name = new ObjectName(NodeMappingServiceMXBean.MXBEAN_NAME);
// Ensure the object was registered at startup
NodeMappingServiceMXBean bean = (NodeMappingServiceMXBean)
profileCollector.getRegisteredMBean(
NodeMappingServiceMXBean.MXBEAN_NAME);
assertNotNull(bean);
// Get individual fields
long addNodeMapListener =
(Long) mbsc.getAttribute(name, "AddNodeMappingListenerCalls");
long assignNode = (Long) mbsc.getAttribute(name, "AssignNodeCalls");
long getIds = (Long) mbsc.getAttribute(name, "GetIdentitiesCalls");
long getNode = (Long) mbsc.getAttribute(name, "GetNodeCalls");
long setStatus = (Long) mbsc.getAttribute(name, "SetStatusCalls");
// Create the proxy for the object
NodeMappingServiceMXBean proxy =
JMX.newMXBeanProxy(mbsc, name, NodeMappingServiceMXBean.class);
assertTrue(addNodeMapListener <=
proxy.getAddNodeMappingListenerCalls());
assertTrue(assignNode <= proxy.getAssignNodeCalls());
assertTrue(getIds <= proxy.getGetIdentitiesCalls());
assertTrue(getNode <= proxy.getGetNodeCalls());
assertTrue(setStatus <= proxy.getSetStatusCalls());
// Test an API
serverNode.getNodeMappingService().
assignNode(NodeMappingService.class, new IdentityImpl("first"));
assertTrue(assignNode < proxy.getAssignNodeCalls());
assertTrue(assignNode < bean.getAssignNodeCalls());
}