1 23 24 28 29 34 35 package com.sun.enterprise.admin.monitor.registry.spi; 36 37 import junit.framework.*; 38 import javax.management.j2ee.statistics.Stats ; 39 import javax.management.j2ee.statistics.Statistic ; 40 import javax.management.*; 41 42 43 48 public class ManagedResourceIntrospectorTest extends TestCase { 49 public void testIntrospection(){ 50 MBeanInfo info = mri.introspect(stats); 51 assertNotNull(info); 52 assertEquals(mbean.getClass().getName(), info.getClassName()); 53 } 54 55 public void testGetParameterInfoWithNull(){ 56 Class [] paramTypes = new Class []{}; 57 MBeanParameterInfo[] info = mri.getParameterInfo(paramTypes); 58 assertEquals(paramTypes.length, info.length); 59 } 60 61 public void testGetParameterInfo(){ 62 Class [] paramTypes = new Class []{java.lang.String .class, java.lang.Integer .class, 63 javax.management.j2ee.statistics.Statistic .class}; 64 MBeanParameterInfo[] info = mri.getParameterInfo(paramTypes); 65 assertEquals(paramTypes.length, info.length); 66 } 67 68 public void testGetAttributeInfoWithNull(){ 69 MBeanAttributeInfo[] info = mri.getAttributeInfo(null); 70 this.assertNull(info); 71 } 72 73 public void testGetAttributeInfo(){ 74 MBeanAttributeInfo[] info = mri.getAttributeInfo(stats); 75 assertNotNull(info); 76 assertEquals(28, info.length); 77 } 78 79 public void testCreation(){ 80 assertNotNull(mbean); 81 assertNotNull(mri); 82 assertNotNull(stats); 83 } 84 85 86 public ManagedResourceIntrospectorTest(java.lang.String testName) { 87 super(testName); 88 } 89 90 DynamicMBean mbean=null; 91 ManagedResourceIntrospector mri=null; 92 Stats stats; 93 protected void setUp() { 94 stats = new S1ASJVMStatsImplMock(); 95 mbean = new GeneratedMonitoringMBeanImpl(stats); 96 mri = new ManagedResourceIntrospector(mbean); 97 } 98 99 protected void tearDown() { 100 101 } 102 public static Test suite() { 103 TestSuite suite = new TestSuite(ManagedResourceIntrospectorTest.class); 104 return suite; 105 } 106 107 public static void main(String [] args){ 108 junit.textui.TestRunner.run(suite()); 109 } 110 } 111 | Popular Tags |