01: /* =====================================================================
02: *
03: * Copyright (c) 2004 Jeremy Boynes. All rights reserved.
04: *
05: * =====================================================================
06: */
07: package test.javax.management;
08:
09: 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: /**
17: * @version $Revision: 1.1 $ $Date: 2005/02/08 04:11:49 $
18: */
19: public class MBeanIntrospectionTest extends MX4JTestCase {
20: private MBeanIntrospector introspector;
21:
22: public MBeanIntrospectionTest(String name) {
23: super (name);
24: }
25:
26: public void testOperationInfo() throws Exception {
27: MBeanInfo info = introspect(new Basic());
28: MBeanOperationInfo[] operations = info.getOperations();
29: assertEquals(1, operations.length);
30: }
31:
32: private MBeanMetaData createMBeanMetaData(Object mbean)
33: throws Exception {
34: MBeanMetaData metadata = MBeanMetaData.Factory.create();
35: metadata.setMBean(mbean);
36: metadata.setClassLoader(mbean.getClass().getClassLoader());
37: return metadata;
38: }
39:
40: private MBeanInfo introspect(Object mbean) throws Exception {
41: MBeanMetaData md = createMBeanMetaData(mbean);
42: introspector.introspect(md);
43: return md.getMBeanInfo();
44: }
45:
46: protected void setUp() throws Exception {
47: introspector = new MBeanIntrospector();
48: }
49:
50: public static interface BasicMBean {
51: boolean is();
52: }
53:
54: public static class Basic implements BasicMBean {
55: public boolean is() {
56: throw new UnsupportedOperationException();
57: }
58: }
59: }
|