KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > zeus > binding > AtomicPropertyTest


1 /*
2  * Enhydra Java Application Server Project
3  *
4  * The contents of this file are subject to the Enhydra Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License on
7  * the Enhydra web site ( http://www.enhydra.org/ ).
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11  * the License for the specific terms governing rights and limitations
12  * under the License.
13  *
14  * The Initial Developer of the Enhydra Application Server is Lutris
15  * Technologies, Inc. The Enhydra Application Server and portions created
16  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17  * All Rights Reserved.
18  */

19 package org.enhydra.zeus.binding;
20
21 import java.util.BitSet JavaDoc;
22 import java.util.Vector JavaDoc;
23
24 import junit.framework.Test;
25 import junit.framework.TestCase;
26 import junit.framework.TestSuite;
27
28 /**
29  * <p>
30  * This is a test case for the <code>{@link AtomicProperty}</code> class.
31  * </p>
32  *
33  * @author Robert Sese
34  * @author Brett McLaughlin
35  */

36 public class AtomicPropertyTest extends AbstractPropertyTest {
37
38     /** Enumerated values for the test. */
39     private Vector JavaDoc enumeratedValues;
40
41     /**
42      * The modifiers (i.e. public, volatile, etc) for the test AtomicProperty.
43      */

44     private BitSet JavaDoc modifiers;
45
46     /** The test <code>AtomicProperty.</code> */
47     private AtomicProperty atomicProperty;
48
49     /**
50      * <p>
51      * This creates a new <code>{@link Property}</code> object that will be
52      * used to test <code>Property</code>-level methods.
53      * </p>
54      *
55      * @return <code>Property</code> - Property object to test with.
56      */

57     protected Property createProperty() {
58         return new AtomicProperty("xmlName", "xmlType");
59     }
60
61     /**
62      * <p>
63      * This constructs a new <code>AbstractContainerTest</code>.
64      * </p>
65      *
66      * @param name the name of the test case.
67      */

68     public AtomicPropertyTest(String JavaDoc name) {
69         super(name);
70     }
71
72     /**
73      * <p>
74      * This method maeks it easier to call these
75      * tests dynamically.
76      * </p>
77      *
78      * @return <code>TestSuite</code> - corresponds to this
79      * <code>TestCase</code>.
80      */

81     public static Test suite() {
82         return new TestSuite(AtomicPropertyTest.class);
83     }
84
85     /**
86      * <p>
87      * This establishes the test fixture.
88      * </p>
89      */

90     protected void setup() {
91         enumeratedValues = new Vector JavaDoc();
92         enumeratedValues.add("value1");
93         enumeratedValues.add("value2");
94
95         modifiers = new BitSet JavaDoc();
96         modifiers.set(Property.ACCESS_PRIVATE);
97         modifiers.set(Property.SOURCE_ATTLIST);
98
99         atomicProperty = new AtomicProperty("xmlName", "xmlType");
100     }
101
102     /**
103      * <p>
104      * This releases any resources in use.
105      * </p>
106      */

107     protected void teardown() {
108         enumeratedValues = null;
109         modifiers = null;
110         atomicProperty = null;
111     }
112
113     /**
114      * <p>
115      * This tests a valid construction.
116      * </p>
117      */

118     public void testConstructor1() {
119         setup();
120         atomicProperty = new AtomicProperty("xmlName",
121                                             "namespaceURI",
122                                             "xmlType",
123                                             "typeNamespaceURI",
124                                             modifiers,
125                                             enumeratedValues,
126                                             "defaultValue");
127         assertTrue(atomicProperty != null);
128         assertTrue(atomicProperty.getXMLName().equals("xmlName"));
129         assertTrue(atomicProperty.getXMLNamespaceURI().equals("namespaceURI"));
130         assertTrue(atomicProperty.getXMLType().equals("xmlType"));
131         assertTrue(
132             atomicProperty.getXMLTypeNamespaceURI().equals("typeNamespaceURI"));
133         assertTrue(atomicProperty.getModifierString().equals("private"));
134         assertTrue(atomicProperty.getEnumeration() == enumeratedValues);
135         assertTrue(((String JavaDoc)atomicProperty.getDefaultValue())
136             .equals("defaultValue"));
137     }
138
139     /**
140      * <p>
141      * This tests a (different) valid construction.
142      * </p>
143      */

144     public void testConstructor2() {
145         setup();
146         atomicProperty = new AtomicProperty("xmlName",
147                                             "namespaceURI",
148                                             "xmlType",
149                                             "typeNamespaceURI");
150         assertTrue(atomicProperty != null);
151         assertTrue(atomicProperty.getXMLName().equals("xmlName"));
152         assertTrue(atomicProperty.getXMLNamespaceURI().equals("namespaceURI"));
153         assertTrue(atomicProperty.getXMLType().equals("xmlType"));
154         assertTrue(
155             atomicProperty.getXMLTypeNamespaceURI().equals("typeNamespaceURI"));
156         assertTrue(!atomicProperty.hasDefaultValue());
157         assertTrue(atomicProperty.getEnumeration() == null);
158     }
159     
160     /**
161      * <p>
162      * This tests a (different) valid construction.
163      * </p>
164      */

165     public void testConstructor3() {
166         setup();
167         atomicProperty = new AtomicProperty("xmlName", "xmlType");
168         assertTrue(atomicProperty != null);
169         assertTrue(atomicProperty.getXMLName().equals("xmlName"));
170         assertTrue(atomicProperty.getXMLNamespaceURI().equals(""));
171         assertTrue(atomicProperty.getXMLType().equals("xmlType"));
172         assertTrue(atomicProperty.getXMLTypeNamespaceURI().equals(""));
173         assertTrue(!atomicProperty.hasDefaultValue());
174         assertTrue(atomicProperty.getEnumeration() == null);
175     }
176 }
177
178
Popular Tags