KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > validation > util > BundleReaderTest


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.j2ee.sun.validation.util;
21
22 import java.io.File JavaDoc;
23
24 import junit.framework.*;
25
26 import org.netbeans.modules.j2ee.sun.validation.Constants;
27 import org.netbeans.modules.j2ee.sun.validation.util.Utils;
28
29
30 /**
31  *
32  * @author Rajeshwar Patil
33  * @version %I%, %G%
34  */

35
36 public class BundleReaderTest extends TestCase{
37     /* A class implementation comment can go here. */
38
39     public BundleReaderTest(String JavaDoc name){
40         super(name);
41     }
42
43
44     public static void main(String JavaDoc args[]){
45         junit.textui.TestRunner.run(suite());
46     }
47
48
49     public void testGetValue() {
50         String JavaDoc str = BundleReader.getValue("non_existing_key"); //NOI18N
51
assertTrue(str.equals("non_existing_key")); //NOI18N
52
str = BundleReader.getValue("MSG_NumberConstraint_Failure"); //NOI18N
53
assertTrue(!str.equals("MSG_NumberConstraint_Failure")); //NOI18N
54
}
55
56
57     public void testCreate() {
58         String JavaDoc bundleFile = "org/netbeans/modules/" + //NOI18N
59
"j2ee/sun/validation/Bundle.properties"; //NOI18N
60
Utils utils = new Utils();
61         boolean fileExists = utils.fileExists(bundleFile);
62         String JavaDoc str =
63             BundleReader.getValue("MSG_NumberConstraint_Failure"); //NOI18N
64

65         if(fileExists){
66             assertTrue(!str.equals("MSG_NumberConstraint_Failure")); //NOI18N
67
} else {
68             assertTrue(str.equals("MSG_NumberConstraint_Failure")); //NOI18N
69
}
70     }
71
72
73     /**
74      * Define suite of all the Tests to run.
75      */

76     public static Test suite(){
77         TestSuite suite = new TestSuite(BundleReaderTest.class);
78         return suite;
79     }
80
81
82     /**
83      * Initialize; allocate any resources needed to perform Tests.
84      */

85     protected void setUp() {
86     }
87
88
89     /**
90      * Free all the resources initilized/allocated to perform Tests.
91      */

92     protected void tearDown() {
93     }
94
95
96     private void nyi() {
97         ///fail("Not yet implemented"); //NOI18N
98
}
99 }
100
Popular Tags