KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > compliance > relation > RoleStatusTestCase


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7
8 package test.compliance.relation;
9
10 import javax.management.relation.RoleStatus;
11
12 import junit.framework.TestCase;
13
14 /**
15  * Role Status tests
16  *
17  * @author <a HREF="mailto:Adrian.Brock@HappeningTimes.com">Adrian Brock</a>.
18  */

19 public class RoleStatusTestCase
20   extends TestCase
21 {
22
23   // Constants -----------------------------------------------------------------
24

25   static int[] statii = new int[]
26   {
27     RoleStatus.LESS_THAN_MIN_ROLE_DEGREE,
28     RoleStatus.MORE_THAN_MAX_ROLE_DEGREE,
29     RoleStatus.NO_ROLE_WITH_NAME,
30     RoleStatus.REF_MBEAN_NOT_REGISTERED,
31     RoleStatus.REF_MBEAN_OF_INCORRECT_CLASS,
32     RoleStatus.ROLE_NOT_READABLE,
33     RoleStatus.ROLE_NOT_WRITABLE
34   };
35
36   static String[] statiiDesc = new String[]
37   {
38     "LESS_THAN_MIN_ROLE_DEGREE",
39     "MORE_THAN_MAX_ROLE_DEGREE",
40     "NO_ROLE_WITH_NAME",
41     "REF_MBEAN_NOT_REGISTERED",
42     "REF_MBEAN_OF_INCORRECT_CLASS",
43     "ROLE_NOT_READABLE",
44     "ROLE_NOT_WRITABLE"
45   };
46
47   // Attributes ----------------------------------------------------------------
48

49   // Constructor ---------------------------------------------------------------
50

51   /**
52    * Construct the test
53    */

54   public RoleStatusTestCase(String s)
55   {
56     super(s);
57   }
58
59   // Tests ---------------------------------------------------------------------
60

61   /**
62    * Make sure all the constants are different
63    */

64   public void testDifferent()
65   {
66     for (int i = 0; i < (statii.length - 1); i++)
67     {
68       for (int j = i + 1; j < statii.length; j++)
69         if (statii[i] == statii[j])
70           fail("RoleStatus constants are not unique");
71     }
72   }
73
74   /**
75    * Make sure all the constants are accepted
76    */

77   public void testRoleStatus()
78   {
79     RoleStatus test = new RoleStatus();
80     for (int i = 0; i < statii.length; i++)
81     {
82        if (RoleStatus.isRoleStatus(statii[i]) == false)
83          fail(statiiDesc + " is not a role status");
84     }
85   }
86 }
87
Popular Tags