1 7 package test.javax.management; 8 9 import test.MX4JTestCase; 10 import mx4j.server.MBeanIntrospector; 11 import mx4j.server.MBeanMetaData; 12 13 import javax.management.MBeanInfo ; 14 import javax.management.MBeanOperationInfo ; 15 16 19 public class MBeanIntrospectionTest extends MX4JTestCase { 20 private MBeanIntrospector introspector; 21 22 public MBeanIntrospectionTest(String name) 23 { 24 super(name); 25 } 26 27 public void testOperationInfo() throws Exception 28 { 29 MBeanInfo info = introspect(new Basic()); 30 MBeanOperationInfo [] operations = info.getOperations(); 31 assertEquals(1, operations.length); 32 } 33 34 private MBeanMetaData createMBeanMetaData(Object mbean) throws Exception 35 { 36 MBeanMetaData metadata = MBeanMetaData.Factory.create(); 37 metadata.setMBean(mbean); 38 metadata.setClassLoader(mbean.getClass().getClassLoader()); 39 return metadata; 40 } 41 42 private MBeanInfo introspect(Object mbean) throws Exception 43 { 44 MBeanMetaData md = createMBeanMetaData(mbean); 45 introspector.introspect(md); 46 return md.getMBeanInfo(); 47 } 48 49 protected void setUp() throws Exception 50 { 51 introspector = new MBeanIntrospector(); 52 } 53 54 public static interface BasicMBean 55 { 56 boolean is(); 57 } 58 59 public static class Basic implements BasicMBean 60 { 61 public boolean is() { 62 throw new UnsupportedOperationException (); 63 } 64 } 65 } 66 | Popular Tags |