KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.sapia.soto.jmx.config;
2
3 import junit.framework.TestCase;
4
5 import org.sapia.soto.jmx.MBeanDescriptor;
6 import org.sapia.soto.jmx.OperationDescriptor;
7 import org.sapia.soto.jmx.ParameterDescriptor;
8 import org.sapia.soto.jmx.TestBean;
9
10
11 /**
12  * @author Yanick Duchesne
13  *
14  * <dl>
15  * <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>
16  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
17  * <a HREF="http://www.sapia-oss.org/license.html">license page</a> at the Sapia OSS web site</dd></dt>
18  * </dl>
19  */

20 public class OperationsTest extends TestCase {
21   public OperationsTest(String JavaDoc arg0) {
22     super(arg0);
23   }
24
25   public void testExcludes() throws Exception JavaDoc {
26     MBeanDescriptor desc = MBeanDescriptor.newInstanceFor(new TestBean());
27     Operations ops = new Operations();
28     Operation exclude = ops.createExclude();
29     exclude.setName("incrementAge");
30     ops.init(desc);
31     desc.init();
32     super.assertEquals(0,
33       desc.getAttributeDescriptorsFor("incrementAge", null).size());
34   }
35
36   public void testIncludes() throws Exception JavaDoc {
37     MBeanDescriptor desc = MBeanDescriptor.newInstanceFor(new TestBean());
38     Operations ops = new Operations();
39     Operation include = ops.createInclude();
40     include.setName("incrementAge");
41     include.setDescription("Age increment");
42
43     Param p = include.createParam();
44     p.setName("increment");
45     p.setDescription("an increment");
46     ops.init(desc);
47     desc.init();
48
49     OperationDescriptor od = (OperationDescriptor) desc.getOperationDescriptorsFor("incrementAge",
50         null).get(0);
51     super.assertEquals("Age increment", od.getInfo().getDescription());
52
53     ParameterDescriptor pd = (ParameterDescriptor) od.getParameters().get(0);
54     super.assertEquals("an increment", pd.getInfo().getDescription());
55     super.assertEquals("increment", pd.getInfo().getName());
56   }
57 }
58
Popular Tags