01: /*
02: * JBoss, Home of Professional Open Source.
03: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
04: * as indicated by the @author tags. See the copyright.txt file in the
05: * distribution for a full listing of individual contributors.
06: *
07: * This is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU Lesser General Public License as
09: * published by the Free Software Foundation; either version 2.1 of
10: * the License, or (at your option) any later version.
11: *
12: * This software is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: *
17: * You should have received a copy of the GNU Lesser General Public
18: * License along with this software; if not, write to the Free
19: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21: */
22: package test.compliance.relation;
23:
24: import javax.management.relation.RoleStatus;
25:
26: import junit.framework.TestCase;
27:
28: /**
29: * Role Status tests
30: *
31: * @author <a href="mailto:Adrian.Brock@HappeningTimes.com">Adrian Brock</a>.
32: */
33: public class RoleStatusTestCase extends TestCase {
34:
35: // Constants -----------------------------------------------------------------
36:
37: static int[] statii = new int[] {
38: RoleStatus.LESS_THAN_MIN_ROLE_DEGREE,
39: RoleStatus.MORE_THAN_MAX_ROLE_DEGREE,
40: RoleStatus.NO_ROLE_WITH_NAME,
41: RoleStatus.REF_MBEAN_NOT_REGISTERED,
42: RoleStatus.REF_MBEAN_OF_INCORRECT_CLASS,
43: RoleStatus.ROLE_NOT_READABLE, RoleStatus.ROLE_NOT_WRITABLE };
44:
45: static String[] statiiDesc = new String[] {
46: "LESS_THAN_MIN_ROLE_DEGREE", "MORE_THAN_MAX_ROLE_DEGREE",
47: "NO_ROLE_WITH_NAME", "REF_MBEAN_NOT_REGISTERED",
48: "REF_MBEAN_OF_INCORRECT_CLASS", "ROLE_NOT_READABLE",
49: "ROLE_NOT_WRITABLE" };
50:
51: // Attributes ----------------------------------------------------------------
52:
53: // Constructor ---------------------------------------------------------------
54:
55: /**
56: * Construct the test
57: */
58: public RoleStatusTestCase(String s) {
59: super (s);
60: }
61:
62: // Tests ---------------------------------------------------------------------
63:
64: /**
65: * Make sure all the constants are different
66: */
67: public void testDifferent() {
68: for (int i = 0; i < (statii.length - 1); i++) {
69: for (int j = i + 1; j < statii.length; j++)
70: if (statii[i] == statii[j])
71: fail("RoleStatus constants are not unique");
72: }
73: }
74:
75: /**
76: * Make sure all the constants are accepted
77: */
78: public void testRoleStatus() {
79: RoleStatus test = new RoleStatus();
80: for (int i = 0; i < statii.length; i++) {
81: if (RoleStatus.isRoleStatus(statii[i]) == false)
82: fail(statiiDesc + " is not a role status");
83: }
84: }
85: }
|