Java Code Examples for javax.management.modelmbean.ModelMBeanInfo#getOperation()

The following examples show how to use javax.management.modelmbean.ModelMBeanInfo#getOperation() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnnotationMetadataAssemblerTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@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"));
}
 
Example 2
Source File: AbstractJmxAssemblerTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@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"));
}
 
Example 3
Source File: AbstractJmxAssemblerTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@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"));
}
 
Example 4
Source File: AnnotationMetadataAssemblerTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@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"));
}
 
Example 5
Source File: AbstractMetadataAssemblerTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@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());
}
 
Example 6
Source File: MethodNameBasedMBeanInfoAssemblerTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void testSetNameParameterIsNamed() throws Exception {
	ModelMBeanInfo info = getMBeanInfoFromAssembler();

	MBeanOperationInfo operationSetAge = info.getOperation("setName");
	assertEquals("name", operationSetAge.getSignature()[0].getName());
}
 
Example 7
Source File: AbstractMetadataAssemblerTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@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());
}
 
Example 8
Source File: AbstractMetadataAssemblerTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@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());
}
 
Example 9
Source File: MethodNameBasedMBeanInfoAssemblerTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void testSetNameParameterIsNamed() throws Exception {
	ModelMBeanInfo info = getMBeanInfoFromAssembler();

	MBeanOperationInfo operationSetAge = info.getOperation("setName");
	assertEquals("name", operationSetAge.getSignature()[0].getName());
}
 
Example 10
Source File: ModelMBeanAssemblerTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testAttributeHasCorrespondingOperations() throws Exception {
    ModelMBeanInfo info = getMBeanInfoFromAssembler();

    ModelMBeanOperationInfo myOperation = info.getOperation("myOperation");
    assertNotNull("get operation should not be null", myOperation);
    assertEquals("Incorrect myOperation return type", "long", myOperation.getReturnType());

    ModelMBeanOperationInfo add = info.getOperation("add");
    assertNotNull("set operation should not be null", add);
    assertEquals("Incorrect add method description", "Add Two Numbers Together", add.getDescription());

}
 
Example 11
Source File: AbstractMetadataAssemblerTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@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());
}
 
Example 12
Source File: MethodNameBasedMBeanInfoAssemblerTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void testSetNameParameterIsNamed() throws Exception {
	ModelMBeanInfo info = getMBeanInfoFromAssembler();

	MBeanOperationInfo operationSetAge = info.getOperation("setName");
	assertEquals("name", operationSetAge.getSignature()[0].getName());
}
 
Example 13
Source File: AbstractMetadataAssemblerTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@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());
}
 
Example 14
Source File: AbstractMetadataAssemblerTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@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());
}
 
Example 15
Source File: AnnotationMetadataAssemblerTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Test
public void testOperationFromInterface() throws Exception {
	ModelMBeanInfo inf = getMBeanInfoFromAssembler();
	ModelMBeanOperationInfo op = inf.getOperation("fromInterface");
	assertNotNull(op);
}
 
Example 16
Source File: AnnotationMetadataAssemblerTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Test
public void testOperationOnGetter() throws Exception {
	ModelMBeanInfo inf = getMBeanInfoFromAssembler();
	ModelMBeanOperationInfo op = inf.getOperation("getExpensiveToCalculate");
	assertNotNull(op);
}
 
Example 17
Source File: AnnotationMetadataAssemblerTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Test
public void testOperationFromInterface() throws Exception {
	ModelMBeanInfo inf = getMBeanInfoFromAssembler();
	ModelMBeanOperationInfo op = inf.getOperation("fromInterface");
	assertNotNull(op);
}
 
Example 18
Source File: AnnotationMetadataAssemblerTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Test
public void testOperationFromInterface() throws Exception {
	ModelMBeanInfo inf = getMBeanInfoFromAssembler();
	ModelMBeanOperationInfo op = inf.getOperation("fromInterface");
	assertNotNull(op);
}
 
Example 19
Source File: AnnotationMetadataAssemblerTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Test
public void testOperationOnGetter() throws Exception {
	ModelMBeanInfo inf = getMBeanInfoFromAssembler();
	ModelMBeanOperationInfo op = inf.getOperation("getExpensiveToCalculate");
	assertNotNull(op);
}
 
Example 20
Source File: AnnotationMetadataAssemblerTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Test
public void testOperationOnGetter() throws Exception {
	ModelMBeanInfo inf = getMBeanInfoFromAssembler();
	ModelMBeanOperationInfo op = inf.getOperation("getExpensiveToCalculate");
	assertNotNull(op);
}