KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > zeus > util > CapitalizationUtilsTest


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.util;
20
21 import junit.framework.Test;
22 import junit.framework.TestCase;
23 import junit.framework.TestSuite;
24
25 /**
26  * <p>
27  * This is a test case for the <code>{@link CapitalizationUtils}</code> class.
28  * </p>
29  *
30  * @author Farhat Kaleem
31  * @author Brett McLaughlin
32  */

33 public class CapitalizationUtilsTest extends TestCase {
34
35     /**
36      * <p>
37      * This constructs a new <code>CapitalizationUtilsTest</code>.
38      * </p>
39      *
40      * @param name the name of the test case.
41      */

42     public CapitalizationUtilsTest(String JavaDoc name) {
43         super(name);
44     }
45
46     /**
47      * <p>
48      * This method maeks it easier to call these
49      * tests dynamically.
50      * </p>
51      *
52      * @return <code>TestSuite</code> - corresponds to this
53      * <code>TestCase</code>.
54      */

55     public static Test suite(){
56         return new TestSuite(CapitalizationUtilsTest.class);
57     }
58
59     /**
60      * <p>
61      * This tests the <code>{@link CapitalizationUtils#allLower}</code> method.
62      * </p>
63      */

64     public void testAllLower() {
65         String JavaDoc [] someStrings = {"CanYouReadThisNow", "CANYOUREADTHISNOW"};
66         String JavaDoc expected = "canyoureadthisnow";
67
68         for (int i=0; i<someStrings.length; i++) {
69             assertEquals(expected,
70                          CapitalizationUtils.allLower(someStrings[i]));
71         }
72     }
73
74     /**
75      * <p>
76      * This tests the <code>{@link CapitalizationUtils#allUpper}</code> method.
77      * </p>
78      */

79     public void testAllUpper() {
80         String JavaDoc [] someStrings = {"CanYouReadThisNow", "canyoureadthisnow"};
81         String JavaDoc expected = "CANYOUREADTHISNOW";
82
83         for (int i=0; i<someStrings.length; i++) {
84             assertEquals(expected,
85                          CapitalizationUtils.allUpper(someStrings[i]));
86         }
87     }
88
89     /**
90      * <p>
91      * This tests the <code>{@link CapitalizationUtils#initialLower}</code>
92      * method.
93      * </p>
94      */

95     public void testInitialLower() {
96         String JavaDoc [] someStrings = {"CanYouReadThisNow", "CANYOUREADTHISNOW"};
97         String JavaDoc [] expectedStrings = {"canYouReadThisNow", "cANYOUREADTHISNOW"};
98
99         for (int i=0; i<someStrings.length; i++) {
100             assertEquals(expectedStrings[i],
101                          CapitalizationUtils.initialLower(someStrings[i]));
102         }
103     }
104
105     /**
106      * <p>
107      * This tests the <code>{@link CapitalizationUtils#initialUpper}</code>
108      * method.
109      * </p>
110      */

111     public void testInitialUpper() {
112         String JavaDoc [] someStrings = {"canYouReadThisNow", "canyoureadthisnow"};
113         String JavaDoc [] expectedStrings = {"CanYouReadThisNow", "Canyoureadthisnow"};
114
115         for (int i=0; i<someStrings.length; i++) {
116             assertEquals(expectedStrings[i],
117                          CapitalizationUtils.initialUpper(someStrings[i]));
118         }
119     }
120
121     /**
122      * <p>
123      * This tests the <code>{@link CapitalizationUtils#justInitialUpper}</code>
124      * method.
125      * </p>
126      */

127     public void testJustInitialUpper() {
128         String JavaDoc [] someStrings = {"canYouReadThisNow", "canyoureadTHISnow"};
129         String JavaDoc [] expectedStrings = {"Canyoureadthisnow", "Canyoureadthisnow"};
130
131         for (int i=0; i<someStrings.length; i++) {
132             assertEquals(expectedStrings[i],
133                          CapitalizationUtils.justInitialUpper(someStrings[i]));
134         }
135     }
136 }
137
138
Popular Tags