KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > common > validation > util > BundleReaderTest


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 /*
25  * BundleReaderTest.java June 17, 2003, 3:15 PM
26  *
27  */

28
29 package com.sun.enterprise.tools.common.validation.util;
30
31 import java.io.File JavaDoc;
32
33 import junit.framework.*;
34
35 import com.sun.enterprise.tools.common.validation.Constants;
36 import com.sun.enterprise.tools.common.validation.util.Utils;
37
38
39 /**
40  *
41  * @author Rajeshwar Patil
42  * @version %I%, %G%
43  */

44
45 public class BundleReaderTest extends TestCase{
46     /* A class implementation comment can go here. */
47
48     public BundleReaderTest(String JavaDoc name){
49         super(name);
50     }
51
52
53     public static void main(String JavaDoc args[]){
54         junit.textui.TestRunner.run(suite());
55     }
56
57
58     public void testGetValue() {
59         String JavaDoc str = BundleReader.getValue("non_existing_key"); //NOI18N
60
assertTrue(str.equals("non_existing_key")); //NOI18N
61
str = BundleReader.getValue("MSG_NumberConstraint_Failure"); //NOI18N
62
assertTrue(!str.equals("MSG_NumberConstraint_Failure")); //NOI18N
63
}
64
65
66     public void testCreate() {
67         String JavaDoc bundleFile = "com/sun/enterprise/tools/" + //NOI18N
68
"common/validation/Bundle.properties"; //NOI18N
69
Utils utils = new Utils();
70         boolean fileExists = utils.fileExists(bundleFile);
71         String JavaDoc str =
72             BundleReader.getValue("MSG_NumberConstraint_Failure"); //NOI18N
73

74         if(fileExists){
75             assertTrue(!str.equals("MSG_NumberConstraint_Failure")); //NOI18N
76
} else {
77             assertTrue(str.equals("MSG_NumberConstraint_Failure")); //NOI18N
78
}
79     }
80
81
82     /**
83      * Define suite of all the Tests to run.
84      */

85     public static Test suite(){
86         TestSuite suite = new TestSuite(BundleReaderTest.class);
87         return suite;
88     }
89
90
91     /**
92      * Initialize; allocate any resources needed to perform Tests.
93      */

94     protected void setUp() {
95     }
96
97
98     /**
99      * Free all the resources initilized/allocated to perform Tests.
100      */

101     protected void tearDown() {
102     }
103
104
105     private void nyi() {
106         fail("Not yet implemented"); //NOI18N
107
}
108 }
109
Popular Tags