1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.jetspeed.services.customlocalization;
17
18
19 import junit.framework.Test;
20 import junit.framework.TestSuite;
21
22
23 import java.util.Locale;
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 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 args[])
53 {
54 junit.awtui.TestRunner.main(new String[] {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
71 return new TestSuite(TestLocalization.class);
72 }
73
74
75
76
77 public void testGoodTranslation() throws Exception
78 {
79 Locale locale = null;
80 String test = null;
81
82
83 locale = new Locale("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
90 locale = new Locale("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
97 locale = new Locale("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