cons.setProfileLevel(ProfileLevel.MAX);
ObjectName name = new ObjectName(DataServiceMXBean.MXBEAN_NAME);
// Ensure the object was registered at startup
DataServiceMXBean bean = (DataServiceMXBean)
profileCollector.getRegisteredMBean(DataServiceMXBean.MXBEAN_NAME);
assertNotNull(bean);
// Get individual fields
long createRef = (Long) mbsc.getAttribute(name, "CreateReferenceCalls");
long createRefForId =
(Long) mbsc.getAttribute(name, "CreateReferenceForIdCalls");
long getBinding = (Long) mbsc.getAttribute(name, "GetBindingCalls");
long getLocalNodeId =
(Long) mbsc.getAttribute(name, "GetLocalNodeIdCalls");
long getServiceBinding =
(Long) mbsc.getAttribute(name, "GetServiceBindingCalls");
long markForUpdate =
(Long) mbsc.getAttribute(name, "MarkForUpdateCalls");
long nextBoundName =
(Long) mbsc.getAttribute(name, "NextBoundNameCalls");
long nextObjectId = (Long) mbsc.getAttribute(name, "NextObjectIdCalls");
long nextServiceBoundName =
(Long) mbsc.getAttribute(name, "NextServiceBoundNameCalls");
long removeBinding =
(Long) mbsc.getAttribute(name, "RemoveBindingCalls");
long removeObject = (Long) mbsc.getAttribute(name, "RemoveObjectCalls");
long removeServiceBinding =
(Long) mbsc.getAttribute(name, "RemoveServiceBindingCalls");
long setBinding = (Long) mbsc.getAttribute(name, "SetBindingCalls");
long setServiceBinding =
(Long) mbsc.getAttribute(name, "SetServiceBindingCalls");
// Create the proxy for the object
DataServiceMXBean proxy =
JMX.newMXBeanProxy(mbsc, name, DataServiceMXBean.class);
// We might have had some service calls in between getting the
// proxy and objects.
assertTrue(createRef <= proxy.getCreateReferenceCalls());
assertTrue(createRefForId <= proxy.getCreateReferenceForIdCalls());
assertTrue(getBinding <= proxy.getGetBindingCalls());
assertTrue(getLocalNodeId <= proxy.getGetLocalNodeIdCalls());
assertTrue(getServiceBinding <= proxy.getGetServiceBindingCalls());
assertTrue(markForUpdate <= proxy.getMarkForUpdateCalls());
assertTrue(nextBoundName <= proxy.getNextBoundNameCalls());
assertTrue(nextObjectId <= proxy.getNextObjectIdCalls());
assertTrue(nextServiceBoundName <=
proxy.getNextServiceBoundNameCalls());
assertTrue(removeBinding <= proxy.getRemoveBindingCalls());
assertTrue(removeObject <= proxy.getRemoveObjectCalls());
assertTrue(removeServiceBinding <=
proxy.getRemoveServiceBindingCalls());
assertTrue(setBinding <= proxy.getSetBindingCalls());
assertTrue(setServiceBinding <= proxy.getSetServiceBindingCalls());
// We might have some service calls in between creating the
// objects and using the bean.
// The proxy should really be a stand-in for the original bean.
assertTrue(createRef <= bean.getCreateReferenceCalls());
assertTrue(createRefForId <= bean.getCreateReferenceForIdCalls());
assertTrue(getBinding <= bean.getGetBindingCalls());
assertTrue(getLocalNodeId <= bean.getGetLocalNodeIdCalls());
assertTrue(getServiceBinding <= bean.getGetServiceBindingCalls());
assertTrue(markForUpdate <= bean.getMarkForUpdateCalls());
assertTrue(nextBoundName <= bean.getNextBoundNameCalls());
assertTrue(nextObjectId <= bean.getNextObjectIdCalls());
assertTrue(nextServiceBoundName <= bean.getNextServiceBoundNameCalls());
assertTrue(removeBinding <= bean.getRemoveBindingCalls());
assertTrue(removeObject <= bean.getRemoveObjectCalls());
assertTrue(removeServiceBinding <= bean.getRemoveServiceBindingCalls());
assertTrue(setBinding <= bean.getSetBindingCalls());
assertTrue(setServiceBinding <= proxy.getSetServiceBindingCalls());
// Test one of the APIs
txnScheduler.runTask(new TestAbstractKernelRunnable() {
public void run() {
ManagedObject dummy = new DummyManagedObject();
serverNode.getDataService().setBinding("dummy", dummy);
}}, taskOwner);
// Should certainly be greater number, not greater or equal
assertTrue(setBinding < proxy.getSetBindingCalls());
assertTrue(setBinding < bean.getSetBindingCalls());
}