@Test public void testOperationFromInterface() throws Exception { ModelMBeanInfo inf = getMBeanInfoFromAssembler(); ModelMBeanOperationInfo op = inf.getOperation("fromInterface"); assertNotNull(op); }
@Test public void testOperationOnGetter() throws Exception { ModelMBeanInfo inf = getMBeanInfoFromAssembler(); ModelMBeanOperationInfo op = inf.getOperation("getExpensiveToCalculate"); assertNotNull(op); }
@Test public void testSetNameParameterIsNamed() throws Exception { ModelMBeanInfo info = getMBeanInfoFromAssembler(); MBeanOperationInfo operationSetAge = info.getOperation("setName"); assertEquals("name", operationSetAge.getSignature()[0].getName()); }
@Test public void testOperationParameterMetadata() throws Exception { ModelMBeanInfo info = getMBeanInfoFromAssembler(); ModelMBeanOperationInfo oper = info.getOperation("add"); MBeanParameterInfo[] params = oper.getSignature(); assertEquals("Invalid number of params", 2, params.length); assertEquals("Incorrect name for x param", "x", params[0].getName()); assertEquals("Incorrect type for x param", int.class.getName(), params[0].getType()); assertEquals("Incorrect name for y param", "y", params[1].getName()); assertEquals("Incorrect type for y param", int.class.getName(), params[1].getType()); }
@Test public void testAttributeHasCorrespondingOperations() throws Exception { ModelMBeanInfo info = getMBeanInfoFromAssembler(); ModelMBeanOperationInfo get = info.getOperation("getName"); assertNotNull("get operation should not be null", get); assertEquals("get operation should have visibility of four", get.getDescriptor().getFieldValue("visibility"), new Integer(4)); assertEquals("get operation should have role \"getter\"", "getter", get.getDescriptor().getFieldValue("role")); ModelMBeanOperationInfo set = info.getOperation("setName"); assertNotNull("set operation should not be null", set); assertEquals("set operation should have visibility of four", set.getDescriptor().getFieldValue("visibility"), new Integer(4)); assertEquals("set operation should have role \"setter\"", "setter", set.getDescriptor().getFieldValue("role")); }
@Test public void testOperationDescriptor() throws Exception { ModelMBeanInfo info = getMBeanInfoFromAssembler(); Descriptor desc = info.getOperation("myOperation").getDescriptor(); assertEquals("Currency Time Limit should be 30", "30", desc.getFieldValue("currencyTimeLimit")); assertEquals("Role should be \"operation\"", "operation", desc.getFieldValue("role")); }
@Test public void testMetricDescription() throws Exception { ModelMBeanInfo inf = getMBeanInfoFromAssembler(); ModelMBeanAttributeInfo metric = inf.getAttribute(QUEUE_SIZE_METRIC); ModelMBeanOperationInfo operation = inf.getOperation("getQueueSize"); assertEquals("The description for the queue size metric is incorrect", "The QueueSize metric", metric.getDescription()); assertEquals("The description for the getter operation of the queue size metric is incorrect", "The QueueSize metric", operation.getDescription()); }
@Test public void testRegistrationOnInterface() throws Exception { Object bean = getContext().getBean("testInterfaceBean"); ModelMBeanInfo inf = getAssembler().getMBeanInfo(bean, "bean:name=interfaceTestBean"); assertNotNull(inf); assertEquals("My Managed Bean", inf.getDescription()); ModelMBeanOperationInfo op = inf.getOperation("foo"); assertNotNull("foo operation not exposed", op); assertEquals("invoke foo", op.getDescription()); assertNull("doNotExpose operation should not be exposed", inf.getOperation("doNotExpose")); ModelMBeanAttributeInfo attr = inf.getAttribute("Bar"); assertNotNull("bar attribute not exposed", attr); assertEquals("Bar description", attr.getDescription()); ModelMBeanAttributeInfo attr2 = inf.getAttribute("CacheEntries"); assertNotNull("cacheEntries attribute not exposed", attr2); assertEquals("Metric Type should be COUNTER", "COUNTER", attr2.getDescriptor().getFieldValue("metricType")); }
ModelMBeanOperationInfo operInfo = info.getOperation(method); if (operInfo == null) throw new MBeanException(new ServiceNotFoundException(
ModelMBeanOperationInfo opInfo = info.getOperation(name); if (opInfo == null) throw new MBeanException
ModelMBeanOperationInfo operInfo = info.getOperation(method); if (operInfo == null) throw new MBeanException(new ServiceNotFoundException(LocalizedStrings.MX4JModelMBean_CANNOT_FIND_MODELMBEANOPERATIONINFO_FOR_OPERATION_0.toLocalizedString(method))); if (logger.isEnabledFor(Logger.DEBUG)) logger.debug("Operation info is: " + operInfo);
ModelMBeanOperationInfo operInfo = info.getOperation(method); if (operInfo == null) throw new MBeanException(new ServiceNotFoundException(LocalizedStrings.MX4JModelMBean_CANNOT_FIND_MODELMBEANOPERATIONINFO_FOR_OPERATION_0.toLocalizedString(method))); if (logger.isEnabledFor(Logger.DEBUG)) logger.debug("Operation info is: " + operInfo);