1 17 18 package org.apache.geronimo.j2ee.management; 19 20 import java.net.InetAddress ; 21 import javax.management.j2ee.statistics.JVMStats ; 22 import org.apache.geronimo.management.JVM; 23 24 27 public class JVMTest extends Abstract77Test { 28 private JVM jvm; 29 private org.apache.geronimo.management.geronimo.JVM jvmEx; 30 private String node; 31 private Runtime runtime; 32 33 public void testStandardInterface() { 34 assertEquals(JVM_DATA.getAbstractName().getObjectName().getCanonicalName(), jvm.getObjectName()); 35 assertEquals(System.getProperty("java.version"), jvm.getJavaVersion()); 36 assertEquals(System.getProperty("java.vendor"), jvm.getJavaVendor()); 37 assertEquals(node, jvm.getNode()); 38 } 39 40 public void testStandardAttributes() throws Exception { 41 assertEquals(JVM_DATA.getAbstractName().getObjectName().getCanonicalName(), kernel.getAttribute(JVM_DATA.getAbstractName(), "objectName")); 42 assertEquals(System.getProperty("java.version"), kernel.getAttribute(JVM_DATA.getAbstractName(), "javaVersion")); 43 assertEquals(System.getProperty("java.vendor"), kernel.getAttribute(JVM_DATA.getAbstractName(), "javaVendor")); 44 assertEquals(node, kernel.getAttribute(JVM_DATA.getAbstractName(), "node")); 45 } 46 47 public void testGeronimoInterface() { 48 assertEquals(runtime.availableProcessors(), jvmEx.getAvailableProcessors()); 49 50 } 51 52 public void testGeronimoAttributes() throws Exception { 53 assertEquals(new Integer (runtime.availableProcessors()), kernel.getAttribute(JVM_DATA.getAbstractName(), "availableProcessors")); 54 } 55 56 public void testStatistics() throws Exception { 57 assertEquals(Boolean.TRUE, kernel.getAttribute(JVM_DATA.getAbstractName(), "statisticsProvider")); 58 JVMStats stats = (JVMStats ) kernel.getAttribute(JVM_DATA.getAbstractName(), "stats"); 59 assertNotNull(stats.getHeapSize()); 60 assertTrue(stats.getHeapSize().getCurrent() > 0); 61 assertNotNull(stats.getHeapSize().getDescription()); 62 assertTrue(stats.getHeapSize().getHighWaterMark() > 0); 63 assertTrue(stats.getHeapSize().getLastSampleTime() > 0); 64 assertTrue(stats.getHeapSize().getLowerBound() == 0); 65 assertTrue(stats.getHeapSize().getLowWaterMark() > 0); 66 assertNotNull(stats.getHeapSize().getName()); 67 assertTrue(stats.getHeapSize().getStartTime() > 0); 68 assertNotNull(stats.getHeapSize().getUnit()); 69 assertTrue(stats.getHeapSize().getUpperBound() > 0); 70 assertNotNull(stats.getUpTime()); 71 assertTrue(stats.getUpTime().getCount() > 0); 72 assertNotNull(stats.getUpTime().getDescription()); 73 assertTrue(stats.getUpTime().getLastSampleTime() > 0); 74 assertNotNull(stats.getUpTime().getName()); 75 assertTrue(stats.getUpTime().getStartTime() > 0); 76 assertNotNull(stats.getUpTime().getUnit()); 77 } 78 79 protected void setUp() throws Exception { 80 super.setUp(); 81 jvm = (JVM) kernel.getGBean(JVM_DATA.getAbstractName()); 82 jvmEx = (org.apache.geronimo.management.geronimo.JVM) kernel.getGBean(JVM_DATA.getAbstractName()); 83 node = InetAddress.getLocalHost().toString(); 84 runtime = Runtime.getRuntime(); 85 } 86 87 protected void tearDown() throws Exception { 88 super.tearDown(); 89 } 90 } 91 | Popular Tags |