< prev index next >

application/tests/org.openjdk.jmc.rjmx.test/src/test/java/org/openjdk/jmc/rjmx/test/internal/RJMXConnectionTest.java

Print this page

        

*** 64,87 **** * Testing the new RJMXConnection. */ @SuppressWarnings("nls") public class RJMXConnectionTest extends RjmxTestCase { // The MBEANS vital to console functionality. ! public final static String[] MBEAN_NAMES = {"java.lang:type=OperatingSystem", "java.lang:type=ClassLoading", //$NON-NLS-1$ //$NON-NLS-2$ ! "java.lang:type=Threading", "java.lang:type=Compilation", "java.lang:type=Memory", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ ! "java.lang:type=Runtime", "java.lang:type=MemoryPool,*", "java.lang:type=GarbageCollector,*", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ ! "java.lang:type=MemoryManager,*"}; //$NON-NLS-1$ ! public final static String[] MBEAN_CLASS_NAMES = {"sun.management.RuntimeImpl"}; //$NON-NLS-1$ public static final int MIN_CPUS = 1; public static final int MAX_CPUS = 1024; private MRI[] ATTRIBUTES_OS; // Only use this one for testing! ! private final static String[] ATTRIBUTE_SPEC_NAME = {"SpecName"}; //$NON-NLS-1$ private RJMXConnection m_connection; /** * Override to avoid creating RJMXConnectorModels but still use the descriptor from superclass. * --- 64,87 ---- * Testing the new RJMXConnection. */ @SuppressWarnings("nls") public class RJMXConnectionTest extends RjmxTestCase { // The MBEANS vital to console functionality. ! public final static String[] MBEAN_NAMES = {"java.lang:type=OperatingSystem", "java.lang:type=ClassLoading", ! "java.lang:type=Threading", "java.lang:type=Compilation", "java.lang:type=Memory", ! "java.lang:type=Runtime", "java.lang:type=MemoryPool,*", "java.lang:type=GarbageCollector,*", ! "java.lang:type=MemoryManager,*"}; ! public final static String[] MBEAN_CLASS_NAMES = {"sun.management.RuntimeImpl"}; public static final int MIN_CPUS = 1; public static final int MAX_CPUS = 1024; private MRI[] ATTRIBUTES_OS; // Only use this one for testing! ! private final static String[] ATTRIBUTE_SPEC_NAME = {"SpecName"}; private RJMXConnection m_connection; /** * Override to avoid creating RJMXConnectorModels but still use the descriptor from superclass. *
*** 97,109 **** m_connection.connect(); ATTRIBUTES_OS = getOSAttributes(); } public static MRI[] getOSAttributes() { ! return new MRI[] {new MRI(Type.ATTRIBUTE, "java.lang:type=OperatingSystem", "SystemCpuLoad"), //$NON-NLS-1$ //$NON-NLS-2$ ! new MRI(Type.ATTRIBUTE, "java.lang:type=OperatingSystem", "ProcessCpuLoad"), //$NON-NLS-1$ //$NON-NLS-2$ ! new MRI(Type.ATTRIBUTE, "java.lang:type=OperatingSystem", "AvailableProcessors")}; //$NON-NLS-1$ //$NON-NLS-2$ } @After public void tearDown() throws Exception { m_connection.close(); --- 97,109 ---- m_connection.connect(); ATTRIBUTES_OS = getOSAttributes(); } public static MRI[] getOSAttributes() { ! return new MRI[] {new MRI(Type.ATTRIBUTE, "java.lang:type=OperatingSystem", "SystemCpuLoad"), ! new MRI(Type.ATTRIBUTE, "java.lang:type=OperatingSystem", "ProcessCpuLoad"), ! new MRI(Type.ATTRIBUTE, "java.lang:type=OperatingSystem", "AvailableProcessors")}; } @After public void tearDown() throws Exception { m_connection.close();
*** 132,142 **** if (mbeanName.apply(objectName)) { found = true; break; } } ! assertTrue("MBean names did not contain: " + element, found); //$NON-NLS-1$ } } @Test public void testGetMBeanNamesAfterReconnect() throws Exception { --- 132,142 ---- if (mbeanName.apply(objectName)) { found = true; break; } } ! assertTrue("MBean names did not contain: " + element, found); } } @Test public void testGetMBeanNamesAfterReconnect() throws Exception {
*** 180,197 **** MBeanInfo info = (MBeanInfo) iter.next(); infos.put(info.getClassName(), info); } // No longer check all the class names for (String element : MBEAN_CLASS_NAMES) { ! assertTrue("Returned infos did not contain MBean class name: " + element, infos //$NON-NLS-1$ .containsKey(element)); } MBeanInfo loggingInfo = infos.get(MBEAN_CLASS_NAMES[0]); ! assertNotNull("MBeanInfo was null for " + MBEAN_CLASS_NAMES[0], loggingInfo); //$NON-NLS-1$ MBeanAttributeInfo[] attrInfo = loggingInfo.getAttributes(); ! assertNotNull("MBeanAttributeInfo was null for " + MBEAN_CLASS_NAMES[0], attrInfo); //$NON-NLS-1$ } @Test public void testGetAttributes() throws Exception { for (MRI element : ATTRIBUTES_OS) { --- 180,197 ---- MBeanInfo info = (MBeanInfo) iter.next(); infos.put(info.getClassName(), info); } // No longer check all the class names for (String element : MBEAN_CLASS_NAMES) { ! assertTrue("Returned infos did not contain MBean class name: " + element, infos .containsKey(element)); } MBeanInfo loggingInfo = infos.get(MBEAN_CLASS_NAMES[0]); ! assertNotNull("MBeanInfo was null for " + MBEAN_CLASS_NAMES[0], loggingInfo); MBeanAttributeInfo[] attrInfo = loggingInfo.getAttributes(); ! assertNotNull("MBeanAttributeInfo was null for " + MBEAN_CLASS_NAMES[0], attrInfo); } @Test public void testGetAttributes() throws Exception { for (MRI element : ATTRIBUTES_OS) {
*** 208,218 **** @Test public void testGetRuntimeMBeanAttribute() throws Exception { Object attr = m_connection .getAttributeValue(new MRI(Type.ATTRIBUTE, getObjectName(MBEAN_NAMES[5]), ATTRIBUTE_SPEC_NAME[0])); assertNotNull(attr); ! assertTrue(String.valueOf(attr).contains("Virtual Machine")); //$NON-NLS-1$ } public void handleRJMXException(Exception exception) { fail(exception.getMessage()); } --- 208,218 ---- @Test public void testGetRuntimeMBeanAttribute() throws Exception { Object attr = m_connection .getAttributeValue(new MRI(Type.ATTRIBUTE, getObjectName(MBEAN_NAMES[5]), ATTRIBUTE_SPEC_NAME[0])); assertNotNull(attr); ! assertTrue(String.valueOf(attr).contains("Virtual Machine")); } public void handleRJMXException(Exception exception) { fail(exception.getMessage()); }
< prev index next >