< prev index next >

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

Print this page




  40 import org.junit.Before;
  41 import org.junit.Test;
  42 
  43 import org.openjdk.jmc.rjmx.subscription.IMRIMetadata;
  44 import org.openjdk.jmc.rjmx.subscription.IMRIMetadataService;
  45 import org.openjdk.jmc.rjmx.subscription.MRI;
  46 import org.openjdk.jmc.rjmx.subscription.MRI.Type;
  47 import org.openjdk.jmc.rjmx.subscription.internal.IIntervalUpdatePolicy;
  48 import org.openjdk.jmc.rjmx.subscription.internal.UpdatePolicyToolkit;
  49 import org.openjdk.jmc.rjmx.test.RjmxTestCase;
  50 import org.openjdk.jmc.rjmx.subscription.MRIMetadataToolkit;
  51 
  52 /**
  53  * Tests the attribute manager.
  54  */
  55 public class ConsoleAttributeInfoManagerTest extends RjmxTestCase {
  56         IMRIMetadataService m_manager;
  57 
  58         @Test
  59         public void testGetAttributeInfo() {
  60                 MRI descriptor = new MRI(Type.ATTRIBUTE, "java.lang:type=OperatingSystem", //$NON-NLS-1$
  61                                 "AvailableProcessors"); //$NON-NLS-1$
  62                 IMRIMetadata info = m_manager.getMetadata(descriptor);
  63                 assertNotNull(info);
  64 
  65                 assertEquals(5000,
  66                                 ((IIntervalUpdatePolicy) UpdatePolicyToolkit.getUpdatePolicy(m_connectionHandle, info.getMRI()))
  67                                                 .getIntervalTime());
  68                 assertMin("Description shorter than expected.", 10, info.getDescription().length()); //$NON-NLS-1$
  69                 assertMin("Display name shorter than expected.", 4, MRIMetadataToolkit.getDisplayName(m_connectionHandle, //$NON-NLS-1$
  70                                 info.getMRI()).length());
  71                 assertTrue(info.getMRI().getParentMRIs().length == 0);
  72         }
  73 
  74         @Test
  75         public void testCompositeIsChild() {
  76                 MRI descriptor = new MRI(Type.ATTRIBUTE, "java.lang:type=Memory", "HeapMemoryUsage/committed"); //$NON-NLS-1$ //$NON-NLS-2$
  77                 IMRIMetadata info = m_manager.getMetadata(descriptor);
  78                 assertNotNull(info);
  79                 MRI parent = new MRI(Type.ATTRIBUTE, "java.lang:type=Memory", "HeapMemoryUsage"); //$NON-NLS-1$ //$NON-NLS-2$
  80                 IMRIMetadata parentInfo = m_manager.getMetadata(parent);
  81                 assertNotNull(parentInfo);
  82                 assertTrue("Info not child to parent!", parent.isChild(descriptor)); //$NON-NLS-1$
  83         }
  84 
  85         @Before
  86         public void setUp() throws Exception {
  87                 m_manager = m_connectionHandle.getServiceOrThrow(IMRIMetadataService.class);
  88         }
  89 
  90         @After
  91         public void tearDown() throws Exception {
  92                 m_manager = null;
  93         }
  94 }


  40 import org.junit.Before;
  41 import org.junit.Test;
  42 
  43 import org.openjdk.jmc.rjmx.subscription.IMRIMetadata;
  44 import org.openjdk.jmc.rjmx.subscription.IMRIMetadataService;
  45 import org.openjdk.jmc.rjmx.subscription.MRI;
  46 import org.openjdk.jmc.rjmx.subscription.MRI.Type;
  47 import org.openjdk.jmc.rjmx.subscription.internal.IIntervalUpdatePolicy;
  48 import org.openjdk.jmc.rjmx.subscription.internal.UpdatePolicyToolkit;
  49 import org.openjdk.jmc.rjmx.test.RjmxTestCase;
  50 import org.openjdk.jmc.rjmx.subscription.MRIMetadataToolkit;
  51 
  52 /**
  53  * Tests the attribute manager.
  54  */
  55 public class ConsoleAttributeInfoManagerTest extends RjmxTestCase {
  56         IMRIMetadataService m_manager;
  57 
  58         @Test
  59         public void testGetAttributeInfo() {
  60                 MRI descriptor = new MRI(Type.ATTRIBUTE, "java.lang:type=OperatingSystem",
  61                                 "AvailableProcessors");
  62                 IMRIMetadata info = m_manager.getMetadata(descriptor);
  63                 assertNotNull(info);
  64 
  65                 assertEquals(5000,
  66                                 ((IIntervalUpdatePolicy) UpdatePolicyToolkit.getUpdatePolicy(m_connectionHandle, info.getMRI()))
  67                                                 .getIntervalTime());
  68                 assertMin("Description shorter than expected.", 10, info.getDescription().length());
  69                 assertMin("Display name shorter than expected.", 4, MRIMetadataToolkit.getDisplayName(m_connectionHandle,
  70                                 info.getMRI()).length());
  71                 assertTrue(info.getMRI().getParentMRIs().length == 0);
  72         }
  73 
  74         @Test
  75         public void testCompositeIsChild() {
  76                 MRI descriptor = new MRI(Type.ATTRIBUTE, "java.lang:type=Memory", "HeapMemoryUsage/committed");
  77                 IMRIMetadata info = m_manager.getMetadata(descriptor);
  78                 assertNotNull(info);
  79                 MRI parent = new MRI(Type.ATTRIBUTE, "java.lang:type=Memory", "HeapMemoryUsage");
  80                 IMRIMetadata parentInfo = m_manager.getMetadata(parent);
  81                 assertNotNull(parentInfo);
  82                 assertTrue("Info not child to parent!", parent.isChild(descriptor));
  83         }
  84 
  85         @Before
  86         public void setUp() throws Exception {
  87                 m_manager = m_connectionHandle.getServiceOrThrow(IMRIMetadataService.class);
  88         }
  89 
  90         @After
  91         public void tearDown() throws Exception {
  92                 m_manager = null;
  93         }
  94 }
< prev index next >