Search in sources :

Example 21 with MBeanConstructorInfo

use of javax.management.MBeanConstructorInfo in project openj9 by eclipse.

the class MyTestListener method testGetMBeanInfo.

@Test
public final void testGetMBeanInfo() {
    MBeanInfo mbi = null;
    try {
        mbi = mbs.getMBeanInfo(objName);
    } catch (InstanceNotFoundException e) {
        Assert.fail("Unexpected InstanceNotFoundException : " + e.getMessage());
    } catch (ReflectionException e) {
        Assert.fail("Unexpected ReflectionException : " + e.getMessage());
        return;
    } catch (IntrospectionException e) {
        Assert.fail("Unexpected IntrospectionException : " + e.getMessage());
    }
    AssertJUnit.assertNotNull(mbi);
    // Now make sure that what we got back is what we expected.
    // Class name
    AssertJUnit.assertTrue(mbi.getClassName().equals(mb.getClass().getName()));
    // No public constructors
    MBeanConstructorInfo[] constructors = mbi.getConstructors();
    AssertJUnit.assertNotNull(constructors);
    AssertJUnit.assertTrue(constructors.length == 0);
    // One public operation (JLM) + five from CILM.
    MBeanOperationInfo[] operations = mbi.getOperations();
    AssertJUnit.assertNotNull(operations);
    AssertJUnit.assertTrue(operations.length == 6);
    // One notification
    MBeanNotificationInfo[] notifications = mbi.getNotifications();
    AssertJUnit.assertNotNull(notifications);
    AssertJUnit.assertTrue(notifications.length == 1);
    // Print description and the class name (not necessarily identical).
    logger.debug("MBean description for " + mb.getClass().getName() + ": " + mbi.getDescription());
    // Eight attributes - some writable.
    MBeanAttributeInfo[] attributes = mbi.getAttributes();
    AssertJUnit.assertNotNull(attributes);
    if (javaVersion >= 16) {
        AssertJUnit.assertTrue(attributes.length == 24);
    } else {
        AssertJUnit.assertTrue(attributes.length == 26);
    }
    for (int i = 0; i < attributes.length; i++) {
        MBeanAttributeInfo info = attributes[i];
        AssertJUnit.assertNotNull(info);
        AllManagementTests.validateAttributeInfo(info, TestMemoryMXBean.ignoredAttributes, attribs);
    }
// end for
}
Also used : ReflectionException(javax.management.ReflectionException) MBeanInfo(javax.management.MBeanInfo) MBeanOperationInfo(javax.management.MBeanOperationInfo) InstanceNotFoundException(javax.management.InstanceNotFoundException) IntrospectionException(javax.management.IntrospectionException) MBeanAttributeInfo(javax.management.MBeanAttributeInfo) MBeanConstructorInfo(javax.management.MBeanConstructorInfo) MBeanNotificationInfo(javax.management.MBeanNotificationInfo) Test(org.testng.annotations.Test)

Example 22 with MBeanConstructorInfo

use of javax.management.MBeanConstructorInfo in project openj9 by eclipse.

the class TestCompilationMXBean method testGetMBeanInfo.

@Test
public final void testGetMBeanInfo() {
    MBeanInfo mbi = null;
    try {
        mbi = mbs.getMBeanInfo(objName);
    } catch (InstanceNotFoundException e) {
        Assert.fail("Unexpected InstanceNotFoundException : " + e.getMessage());
    } catch (ReflectionException e) {
        Assert.fail("Unexpected ReflectionException : " + e.getMessage());
    } catch (IntrospectionException e) {
        Assert.fail("Unexpected IntrospectionException : " + e.getMessage());
    }
    AssertJUnit.assertNotNull(mbi);
    // Now make sure that what we got back is what we expected.
    /* Check the class name. Test substring match (not equals()) since cb.getClass().getName()
		 * typically returns a fully qualified name (prefixing package name).  This should have always
		 * been prefixed by package name, and not being changed as an aftermath of current changes
		 */
    AssertJUnit.assertTrue(cb.getClass().getName().endsWith(mbi.getClassName()));
    // No public constructors
    MBeanConstructorInfo[] constructors = mbi.getConstructors();
    AssertJUnit.assertNotNull(constructors);
    AssertJUnit.assertTrue(constructors.length == 0);
    // No public operations
    MBeanOperationInfo[] operations = mbi.getOperations();
    AssertJUnit.assertNotNull(operations);
    AssertJUnit.assertTrue(operations.length == 0);
    // No notifications
    MBeanNotificationInfo[] notifications = mbi.getNotifications();
    AssertJUnit.assertNotNull(notifications);
    AssertJUnit.assertTrue(notifications.length == 0);
    // Print out the description here.
    logger.debug("MBean description for " + cb.getClass().getName() + ": " + mbi.getDescription());
    // Three attributes - none writable.
    MBeanAttributeInfo[] attributes = mbi.getAttributes();
    AssertJUnit.assertNotNull(attributes);
    AssertJUnit.assertTrue(attributes.length == 4);
    logger.debug("TestCompilationMXBean.java: testGetMBeanInfo: attributes.length: " + attributes.length);
    for (int i = 0; i < attributes.length; i++) {
        MBeanAttributeInfo info = attributes[i];
        AssertJUnit.assertNotNull(info);
        AllManagementTests.validateAttributeInfo(info, TestCompilationMXBean.ignoredAttributes, attribs);
    }
// end for
}
Also used : ReflectionException(javax.management.ReflectionException) MBeanInfo(javax.management.MBeanInfo) MBeanOperationInfo(javax.management.MBeanOperationInfo) InstanceNotFoundException(javax.management.InstanceNotFoundException) IntrospectionException(javax.management.IntrospectionException) MBeanAttributeInfo(javax.management.MBeanAttributeInfo) MBeanConstructorInfo(javax.management.MBeanConstructorInfo) MBeanNotificationInfo(javax.management.MBeanNotificationInfo) Test(org.testng.annotations.Test)

Example 23 with MBeanConstructorInfo

use of javax.management.MBeanConstructorInfo in project openj9 by eclipse.

the class TestGarbageCollectorMXBean method testGetMBeanInfo.

@Test
public final void testGetMBeanInfo() {
    MBeanInfo mbi = null;
    try {
        mbi = mbs.getMBeanInfo(objName);
    } catch (InstanceNotFoundException e) {
        Assert.fail("Unexpected InstanceNotFoundException : " + e.getMessage());
    } catch (ReflectionException e) {
        Assert.fail("Unexpected ReflectionException : " + e.getMessage());
    } catch (IntrospectionException e) {
        Assert.fail("Unexpected IntrospectionException : " + e.getMessage());
    }
    AssertJUnit.assertNotNull(mbi);
    // Now make sure that what we got back is what we expected.
    /* Check the class name. Test substring match (not equals()) since gcb.getClass().getName()
		 * typically returns a fully qualified name (prefixing package name).  This should have always
		 * been prefixed by package name, and not being changed as an aftermath of current changes
		 */
    AssertJUnit.assertTrue(gcb.getClass().getName().endsWith(mbi.getClassName()));
    // No public constructors
    MBeanConstructorInfo[] constructors = mbi.getConstructors();
    AssertJUnit.assertNotNull(constructors);
    AssertJUnit.assertEquals(0, constructors.length);
    // No public operations
    MBeanOperationInfo[] operations = mbi.getOperations();
    AssertJUnit.assertNotNull(operations);
    AssertJUnit.assertEquals(0, operations.length);
    // No notifications
    MBeanNotificationInfo[] notifications = mbi.getNotifications();
    AssertJUnit.assertNotNull(notifications);
    AssertJUnit.assertEquals(1, notifications.length);
    // Print out both, the description as well as the class name.
    logger.debug("MBean description for " + gcb.getClass().getName() + ": " + mbi.getDescription());
    // 10 attributes (5 standard, 6 IBM) - none is writable.
    MBeanAttributeInfo[] attributes = mbi.getAttributes();
    AssertJUnit.assertNotNull(attributes);
    AssertJUnit.assertEquals(12, attributes.length);
    for (int i = 0; i < attributes.length; i++) {
        MBeanAttributeInfo info = attributes[i];
        AssertJUnit.assertNotNull(info);
        AllManagementTests.validateAttributeInfo(info, TestGarbageCollectorMXBean.ignoredAttributes, attribs);
    }
// end for
}
Also used : ReflectionException(javax.management.ReflectionException) MBeanInfo(javax.management.MBeanInfo) MBeanOperationInfo(javax.management.MBeanOperationInfo) InstanceNotFoundException(javax.management.InstanceNotFoundException) IntrospectionException(javax.management.IntrospectionException) MBeanAttributeInfo(javax.management.MBeanAttributeInfo) MBeanConstructorInfo(javax.management.MBeanConstructorInfo) MBeanNotificationInfo(javax.management.MBeanNotificationInfo) Test(org.testng.annotations.Test)

Example 24 with MBeanConstructorInfo

use of javax.management.MBeanConstructorInfo in project openj9 by eclipse.

the class AttributeData method testGetMBeanInfo.

@Test
public final void testGetMBeanInfo() {
    MBeanInfo mbi = null;
    try {
        mbi = mbs.getMBeanInfo(objName);
    } catch (InstanceNotFoundException e) {
        // An unlikely exception - if this occurs, we can't proceed with the test.
        Assert.fail("Unexpected InstanceNotFoundException : " + e.getMessage());
    } catch (ReflectionException e) {
        // An unlikely exception - if this occurs, we can't proceed with the test.
        Assert.fail("Unexpected ReflectionException : " + e.getMessage());
    } catch (IntrospectionException e) {
        // An unlikely exception - if this occurs, we can't proceed with the test.
        Assert.fail("Unexpected IntrospectionException : " + e.getMessage());
    }
    AssertJUnit.assertNotNull(mbi);
    // Now make sure that what we got back is what we expected.
    /* Check the class name. Test substring match (not equals()) since clb.getClass().getName()
		 * typically returns a fully qualified name (prefixing package name).  This should have always
		 * been prefixed by package name, and not being changed as an aftermath of current changes
		 */
    AssertJUnit.assertTrue(clb.getClass().getName().endsWith(mbi.getClassName()));
    // No public constructors
    MBeanConstructorInfo[] constructors = mbi.getConstructors();
    AssertJUnit.assertNotNull(constructors);
    AssertJUnit.assertTrue(constructors.length == 0);
    // No public operations
    MBeanOperationInfo[] operations = mbi.getOperations();
    AssertJUnit.assertNotNull(operations);
    AssertJUnit.assertTrue(operations.length == 0);
    // No notifications
    MBeanNotificationInfo[] notifications = mbi.getNotifications();
    AssertJUnit.assertNotNull(notifications);
    AssertJUnit.assertTrue(notifications.length == 0);
    /* Print out the description and class name as they are not bound to be
		 * the same.
		 */
    logger.debug("MBean description for " + clb.getClass().getName() + ": " + mbi.getDescription());
    // Four attributes - only Verbose is writable.
    MBeanAttributeInfo[] attributes = mbi.getAttributes();
    AssertJUnit.assertNotNull(attributes);
    AssertJUnit.assertTrue(attributes.length == 5);
    for (int i = 0; i < attributes.length; i++) {
        MBeanAttributeInfo info = attributes[i];
        AssertJUnit.assertNotNull(info);
        AllManagementTests.validateAttributeInfo(info, TestClassLoadingMXBean.ignoredAttributes, attribs);
    }
// end for
}
Also used : ReflectionException(javax.management.ReflectionException) MBeanInfo(javax.management.MBeanInfo) MBeanOperationInfo(javax.management.MBeanOperationInfo) InstanceNotFoundException(javax.management.InstanceNotFoundException) IntrospectionException(javax.management.IntrospectionException) MBeanAttributeInfo(javax.management.MBeanAttributeInfo) MBeanConstructorInfo(javax.management.MBeanConstructorInfo) MBeanNotificationInfo(javax.management.MBeanNotificationInfo) Test(org.testng.annotations.Test)

Example 25 with MBeanConstructorInfo

use of javax.management.MBeanConstructorInfo in project openj9 by eclipse.

the class TestOperatingSystemMXBean method testGetMBeanInfo.

@Test
public final void testGetMBeanInfo() {
    MBeanInfo mbi = null;
    try {
        mbi = mbs.getMBeanInfo(objName);
    } catch (InstanceNotFoundException e) {
        Assert.fail("Unexpected InstanceNotFoundException : " + e.getMessage());
    } catch (ReflectionException e) {
        Assert.fail("Unexpected ReflectionException : " + e.getMessage());
    } catch (IntrospectionException e) {
        Assert.fail("Unexpected IntrospectionException : " + e.getMessage());
    }
    AssertJUnit.assertNotNull(mbi);
    // Now make sure that what we got back is what we expected.
    // Class name
    AssertJUnit.assertEquals(mbi.getClassName(), osb.getClass().getName());
    // No public constructors
    MBeanConstructorInfo[] constructors = mbi.getConstructors();
    AssertJUnit.assertNotNull(constructors);
    AssertJUnit.assertEquals(0, constructors.length);
    // No public notifications but 3 in IBM extension
    MBeanNotificationInfo[] notifications = mbi.getNotifications();
    AssertJUnit.assertNotNull(notifications);
    AssertJUnit.assertEquals(3, notifications.length);
    // 12 attributes - 5 standard and 14 from IBM.
    MBeanAttributeInfo[] attributes = mbi.getAttributes();
    AssertJUnit.assertNotNull(attributes);
    /* Under UNIX, we expect a couple more APIs, since the instance would be
		 * that of UnixExtendedOperatingSystem.
		 */
    int attrNbr;
    if (verMajor >= 14) {
        if (TestUtil.isRunningOnUnix()) {
            attrNbr = 27;
        } else {
            attrNbr = 25;
        }
    } else {
        // Java 8 - 13
        if (TestUtil.isRunningOnUnix()) {
            attrNbr = 24;
        } else {
            attrNbr = 22;
        }
    }
    AssertJUnit.assertEquals(attrNbr, attributes.length);
    for (int i = 0; i < attributes.length; i++) {
        MBeanAttributeInfo info = attributes[i];
        AssertJUnit.assertNotNull(info);
        AllManagementTests.validateAttributeInfo(info, TestOperatingSystemMXBean.ignoredAttributes, attribs);
    }
// end for
}
Also used : MBeanConstructorInfo(javax.management.MBeanConstructorInfo) ReflectionException(javax.management.ReflectionException) MBeanNotificationInfo(javax.management.MBeanNotificationInfo) MBeanInfo(javax.management.MBeanInfo) InstanceNotFoundException(javax.management.InstanceNotFoundException) IntrospectionException(javax.management.IntrospectionException) MBeanAttributeInfo(javax.management.MBeanAttributeInfo) Test(org.testng.annotations.Test)

Aggregations

MBeanConstructorInfo (javax.management.MBeanConstructorInfo)25 MBeanAttributeInfo (javax.management.MBeanAttributeInfo)21 MBeanInfo (javax.management.MBeanInfo)21 MBeanNotificationInfo (javax.management.MBeanNotificationInfo)20 MBeanOperationInfo (javax.management.MBeanOperationInfo)20 InstanceNotFoundException (javax.management.InstanceNotFoundException)10 IntrospectionException (javax.management.IntrospectionException)10 ReflectionException (javax.management.ReflectionException)10 Test (org.testng.annotations.Test)10 MBeanParameterInfo (javax.management.MBeanParameterInfo)5 DescriptorSupport (javax.management.modelmbean.DescriptorSupport)3 Constructor (java.lang.reflect.Constructor)2 MemoryManagerMXBean (java.lang.management.MemoryManagerMXBean)1 MemoryPoolMXBean (java.lang.management.MemoryPoolMXBean)1 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 SortedMap (java.util.SortedMap)1 TreeMap (java.util.TreeMap)1 Lock (java.util.concurrent.locks.Lock)1