KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jetspeed > services > customlocalization > TestLocalization


1 /*
2  * Copyright 2000-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.jetspeed.services.customlocalization;
17
18 // Junit imports
19
import junit.framework.Test;
20 import junit.framework.TestSuite;
21
22 // Java APIs
23
import java.util.Locale JavaDoc;
24
25 import org.apache.jetspeed.services.customlocalization.CustomLocalization;
26 import org.apache.jetspeed.test.HeadlessBaseTest;
27
28 /**
29  * Command Line Test Localization routines.
30  *
31  * @author <a HREF="mailto:morciuch@">Mark Orciuch</a>
32  * @version $Id: TestLocalization.java,v 1.1 2004/04/07 22:02:43 jford Exp $
33  */

34
35 public class TestLocalization extends HeadlessBaseTest
36 {
37     /**
38      * Defines the testcase name for JUnit.
39      *
40      * @param name the testcase's name.
41      */

42     public TestLocalization(String JavaDoc name)
43     {
44         super(name);
45     }
46
47     /**
48      * Start the tests.
49      *
50      * @param args the arguments. Not used
51      */

52     public static void main(String JavaDoc args[])
53     {
54         junit.awtui.TestRunner.main(new String JavaDoc[] {TestLocalization.class.getName()});
55     }
56
57     /**
58      */

59     public void setup()
60     {
61         System.out.println("Setup: Testing Localization");
62     }
63
64     /**
65      *
66      * @return
67      */

68     public static Test suite()
69     {
70         // All methods starting with "test" will be executed in the test suite.
71
return new TestSuite(TestLocalization.class);
72     }
73
74
75     ///////////////////////////////////////////////////////////////////////////
76

77     public void testGoodTranslation() throws Exception JavaDoc
78     {
79         Locale JavaDoc locale = null;
80         String JavaDoc test = null;
81
82         // Test English translation
83
locale = new Locale JavaDoc("en", "US");
84         test = CustomLocalization.getString(null, locale, "LOGIN_USERNAME");
85         System.out.println("Locale [en-US]: LOGIN_USER translation = " + test);
86
87         assertTrue(test.equals("Username:"));
88
89         // Test Polish translation
90
locale = new Locale JavaDoc("pl", "");
91         test = CustomLocalization.getString(null, locale, "LOGIN_TITLE");
92         System.out.println("Locale [pl]: LOGIN_TITLE translation = " + test);
93
94         assertTrue(test.equals("Logowanie"));
95     
96         // Test case when only english translation exists
97
locale = new Locale JavaDoc("my", "");
98         test = CustomLocalization.getString(null, locale, "_TEST_");
99         System.out.println("Locale [my]: _TEST_ = " + test);
100
101         assertTrue(test.equals("Do not translate"));
102
103     }
104
105 }
106
107
108
109
Popular Tags