KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > soto > jmx > config > AttributesTest


1 package org.sapia.soto.jmx.config;
2
3 import junit.framework.TestCase;
4
5 import org.sapia.soto.jmx.AttributeDescriptor;
6 import org.sapia.soto.jmx.MBeanDescriptor;
7 import org.sapia.soto.jmx.TestBean;
8
9
10 /**
11  * @author Yanick Duchesne
12  *
13  * <dl>
14  * <dt><b>Copyright:</b><dd>Copyright &#169; 2002-2003 <a HREF="http://www.sapia-oss.org">Sapia Open Source Software</a>. All Rights Reserved.</dd></dt>
15  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
16  * <a HREF="http://www.sapia-oss.org/license.html">license page</a> at the Sapia OSS web site</dd></dt>
17  * </dl>
18  */

19 public class AttributesTest extends TestCase {
20   public AttributesTest(String JavaDoc arg0) {
21     super(arg0);
22   }
23
24   public void testExcludes() throws Exception JavaDoc {
25     MBeanDescriptor desc = MBeanDescriptor.newInstanceFor(new TestBean());
26     Attributes attrs = new Attributes();
27     Attribute exclude = attrs.createExclude();
28     exclude.setName("firstname");
29     attrs.init(desc);
30     desc.init();
31     super.assertEquals(0,
32       desc.getAttributeDescriptorsFor("firstname", null).size());
33   }
34
35   public void testIncludes() throws Exception JavaDoc {
36     MBeanDescriptor desc = MBeanDescriptor.newInstanceFor(new TestBean());
37     Attributes attrs = new Attributes();
38     Attribute exclude = attrs.createInclude();
39     exclude.setName("firstname");
40     exclude.setDescription("The first name");
41     attrs.init(desc);
42     desc.init();
43
44     AttributeDescriptor ad = (AttributeDescriptor) desc.getAttributeDescriptorsFor("firstname",
45         null).get(0);
46     super.assertEquals("The first name", ad.getInfo().getDescription());
47   }
48 }
49
Popular Tags