Search in sources :

Example 56 with MBeanOperationInfo

use of javax.management.MBeanOperationInfo in project kernel by exoplatform.

the class TestExoMBeanAttribute method test3.

public void test3(Bean bean, String getterName, String setterName) throws Exception {
    MBeanOperationInfo[] operationInfos = bean.info.getOperations();
    assertNotNull(operationInfos);
    assertEquals(2, operationInfos.length);
    MBeanOperationInfo setStringInfo = bean.info.getOperation(setterName);
    assertNotNull(setStringInfo);
    assertEquals(setterName, setStringInfo.getName());
    assertEquals("void", setStringInfo.getReturnType());
    MBeanParameterInfo[] setStringParameterInfos = setStringInfo.getSignature();
    assertEquals(1, setStringParameterInfos.length);
    MBeanParameterInfo attributeParameterInfo = setStringParameterInfos[0];
    assertEquals("java.lang.String", attributeParameterInfo.getType());
    MBeanOperationInfo getStringInfo = bean.info.getOperation(getterName);
    assertNotNull(getStringInfo);
    assertEquals(getterName, getStringInfo.getName());
    assertEquals("java.lang.String", getStringInfo.getReturnType());
    assertEquals(0, getStringInfo.getSignature().length);
    MBeanAttributeInfo[] attributeInfos = bean.info.getAttributes();
    assertNotNull(attributeInfos);
    assertEquals(1, attributeInfos.length);
    MBeanAttributeInfo attributeInfo = attributeInfos[0];
    assertEquals("String", attributeInfo.getName());
    assertEquals("java.lang.String", attributeInfo.getType());
    assertEquals(true, attributeInfo.isReadable());
    assertEquals(true, attributeInfo.isWritable());
    MBean3_0.string = null;
    assertEquals(null, server.invoke(bean.name, setterName, new Object[] { "Foo" }, new String[] { "java.lang.String" }));
    assertEquals("Foo", MBean3_0.string);
    server.setAttribute(bean.name, new Attribute("String", "Bar"));
    assertEquals("Bar", MBean3_0.string);
    MBean3_0.string = "Juu";
    assertEquals("Juu", server.invoke(bean.name, getterName, new Object[0], new String[0]));
    MBean3_0.string = "Daa";
    assertEquals("Daa", server.getAttribute(bean.name, "String"));
}
Also used : Attribute(javax.management.Attribute) MBeanOperationInfo(javax.management.MBeanOperationInfo) MBeanAttributeInfo(javax.management.MBeanAttributeInfo) MBeanParameterInfo(javax.management.MBeanParameterInfo)

Example 57 with MBeanOperationInfo

use of javax.management.MBeanOperationInfo in project kernel by exoplatform.

the class TestExoMBeanAttribute method test2.

public void test2(Bean bean, String setterName) throws Exception {
    MBeanOperationInfo[] operationInfos = bean.info.getOperations();
    assertNotNull(operationInfos);
    assertEquals(1, operationInfos.length);
    MBeanOperationInfo operationInfo = operationInfos[0];
    assertNotNull(operationInfo);
    assertEquals(setterName, operationInfo.getName());
    assertEquals("void", operationInfo.getReturnType());
    MBeanParameterInfo[] attributeParameterInfos = operationInfo.getSignature();
    assertEquals(1, attributeParameterInfos.length);
    MBeanParameterInfo attributeParameterInfo = attributeParameterInfos[0];
    assertEquals("java.lang.String", attributeParameterInfo.getType());
    MBeanAttributeInfo[] attributeInfos = bean.info.getAttributes();
    assertNotNull(attributeInfos);
    assertEquals(1, attributeInfos.length);
    MBeanAttributeInfo attributeInfo = attributeInfos[0];
    assertEquals("String", attributeInfo.getName());
    assertEquals("java.lang.String", attributeInfo.getType());
    assertEquals(false, attributeInfo.isReadable());
    assertEquals(true, attributeInfo.isWritable());
    MBean2_0.string = null;
    assertEquals(null, server.invoke(bean.name, setterName, new Object[] { "Foo" }, new String[] { "java.lang.String" }));
    assertEquals("Foo", MBean2_0.string);
    server.setAttribute(bean.name, new Attribute("String", "Bar"));
    assertEquals("Bar", MBean2_0.string);
}
Also used : Attribute(javax.management.Attribute) MBeanOperationInfo(javax.management.MBeanOperationInfo) MBeanAttributeInfo(javax.management.MBeanAttributeInfo) MBeanParameterInfo(javax.management.MBeanParameterInfo)

Example 58 with MBeanOperationInfo

use of javax.management.MBeanOperationInfo in project kernel by exoplatform.

the class TestExoMBeanOperation method test2.

public void test2() throws Exception {
    Bean bean = register("domain:name=mbean", MBean2.class);
    MBeanOperationInfo[] operationInfos = bean.info.getOperations();
    assertNotNull(operationInfos);
    assertEquals(1, operationInfos.length);
    MBeanOperationInfo operationInfo = operationInfos[0];
    assertNotNull(operationInfo);
    assertEquals("op", operationInfo.getName());
    assertEquals("op_desc", operationInfo.getDescription());
    assertEquals("java.lang.String", operationInfo.getReturnType());
    MBeanParameterInfo[] parameterInfos = operationInfo.getSignature();
    assertNotNull(parameterInfos);
    assertEquals(1, parameterInfos.length);
    MBeanParameterInfo parameterInfo = parameterInfos[0];
    assertNotNull(parameterInfo);
    assertEquals("arg_desc", parameterInfo.getDescription());
    assertEquals("java.lang.Integer", parameterInfo.getType());
    MBeanAttributeInfo[] mbeanAttributeInfos = bean.info.getAttributes();
    assertNotNull(mbeanAttributeInfos);
    assertEquals(0, mbeanAttributeInfos.length);
    assertEquals("5", server.invoke(bean.name, "op", new Object[] { 5 }, new String[] { "java.lang.Integer" }));
}
Also used : MBeanOperationInfo(javax.management.MBeanOperationInfo) MBeanAttributeInfo(javax.management.MBeanAttributeInfo) MBeanParameterInfo(javax.management.MBeanParameterInfo)

Example 59 with MBeanOperationInfo

use of javax.management.MBeanOperationInfo in project kernel by exoplatform.

the class TestExoMBeanOperation method test4.

public void test4() throws Exception {
    Bean bean = register("domain:name=mbean", MBean4.class);
    MBeanOperationInfo[] operationInfos = bean.info.getOperations();
    assertNotNull(operationInfos);
    assertEquals(2, operationInfos.length);
    MBeanOperationInfo operation1Info = bean.info.getOperation("op1");
    assertNotNull(operation1Info);
    assertEquals("op1", operation1Info.getName());
    assertEquals("java.lang.String", operation1Info.getReturnType());
    MBeanParameterInfo[] operation1ParameterInfos = operation1Info.getSignature();
    assertNotNull(operation1ParameterInfos);
    assertEquals(1, operation1ParameterInfos.length);
    MBeanParameterInfo operation1ParameterInfo = operation1ParameterInfos[0];
    assertNotNull(operation1ParameterInfo);
    assertEquals("java.lang.Boolean", operation1ParameterInfo.getType());
    MBeanOperationInfo operation2Info = bean.info.getOperation("op2");
    assertNotNull(operation2Info);
    assertEquals("op2", operation2Info.getName());
    assertEquals("java.lang.String", operation2Info.getReturnType());
    MBeanParameterInfo[] operation2ParameterInfos = operation2Info.getSignature();
    assertNotNull(operation2ParameterInfos);
    assertEquals(1, operation2ParameterInfos.length);
    MBeanParameterInfo operation2ParameterInfo = operation2ParameterInfos[0];
    assertNotNull(operation2ParameterInfo);
    assertEquals("java.lang.Integer", operation2ParameterInfo.getType());
    MBeanAttributeInfo[] mbeanAttributeInfos = bean.info.getAttributes();
    assertNotNull(mbeanAttributeInfos);
    assertEquals(0, mbeanAttributeInfos.length);
    assertEquals("true", server.invoke(bean.name, "op1", new Object[] { true }, new String[] { "java.lang.Boolean" }));
    assertEquals("7", server.invoke(bean.name, "op2", new Object[] { 7 }, new String[] { "java.lang.Integer" }));
}
Also used : MBeanOperationInfo(javax.management.MBeanOperationInfo) MBeanAttributeInfo(javax.management.MBeanAttributeInfo) MBeanParameterInfo(javax.management.MBeanParameterInfo)

Example 60 with MBeanOperationInfo

use of javax.management.MBeanOperationInfo in project kernel by exoplatform.

the class TestExoMBeanOperation method test6.

public void test6() throws Exception {
    Bean bean = register("domain:name=mbean", MBean6.class);
    MBeanOperationInfo[] operationInfos = bean.info.getOperations();
    assertNotNull(operationInfos);
    assertEquals(4, operationInfos.length);
    MBeanOperationInfo readInfo = bean.info.getOperation("read");
    assertNotNull(readInfo);
    assertEquals(MBeanOperationInfo.INFO, readInfo.getImpact());
    MBeanOperationInfo writeInfo = bean.info.getOperation("write");
    assertNotNull(writeInfo);
    assertEquals(MBeanOperationInfo.ACTION, writeInfo.getImpact());
    MBeanOperationInfo idempotentWriteInfo = bean.info.getOperation("idempotentWrite");
    assertNotNull(idempotentWriteInfo);
    assertEquals(MBeanOperationInfo.ACTION, idempotentWriteInfo.getImpact());
    MBeanOperationInfo defaultImpactInfo = bean.info.getOperation("defaultImpact");
    assertNotNull(defaultImpactInfo);
    assertEquals(MBeanOperationInfo.ACTION, defaultImpactInfo.getImpact());
}
Also used : MBeanOperationInfo(javax.management.MBeanOperationInfo)

Aggregations

MBeanOperationInfo (javax.management.MBeanOperationInfo)68 MBeanInfo (javax.management.MBeanInfo)39 MBeanAttributeInfo (javax.management.MBeanAttributeInfo)35 MBeanParameterInfo (javax.management.MBeanParameterInfo)25 ObjectName (javax.management.ObjectName)20 Test (org.junit.Test)12 ArrayList (java.util.ArrayList)11 MBeanNotificationInfo (javax.management.MBeanNotificationInfo)9 MBeanConstructorInfo (javax.management.MBeanConstructorInfo)8 MBeanServer (javax.management.MBeanServer)8 Method (java.lang.reflect.Method)7 Descriptor (javax.management.Descriptor)7 Attribute (javax.management.Attribute)5 ReflectionException (javax.management.ReflectionException)5 InstanceNotFoundException (javax.management.InstanceNotFoundException)4 AMX (com.sun.appserv.management.base.AMX)3 IOException (java.io.IOException)3 TreeMap (java.util.TreeMap)3 IntrospectionException (javax.management.IntrospectionException)3 MBeanServerConnection (javax.management.MBeanServerConnection)3