This project has retired. For details please refer to its
Attic page.
TestLocalization xref
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 at7 * 8 * http://www.apache.org/licenses/LICENSE-2.09 * 10 * Unless required by applicable law or agreed to in writing, software11 * 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 and14 * limitations under the License.15 */16packageorg.apache.jetspeed.services.customlocalization;
1718// Junit imports19import junit.framework.Test;
20import junit.framework.TestSuite;
2122// Java APIs23import java.util.Locale;
2425import org.apache.jetspeed.services.customlocalization.CustomLocalization;
26import org.apache.jetspeed.test.HeadlessBaseTest;
2728/***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 */3435publicclassTestLocalizationextendsHeadlessBaseTest36 {
37/***38 * Defines the testcase name for JUnit.39 * 40 * @param name the testcase's name.41 */42publicTestLocalization(String name)
43 {
44super(name);
45 }
4647/***48 * Start the tests.49 *50 * @param args the arguments. Not used51 */52publicstaticvoid main(String args[])
53 {
54 junit.awtui.TestRunner.main(new String[] {TestLocalization.class.getName()});
55 }
5657/***58 */59publicvoid setup()
60 {
61 System.out.println("Setup: Testing Localization");
62 }
6364/***65 * 66 * @return 67 */68publicstatic Test suite()
69 {
70// All methods starting with "test" will be executed in the test suite.71returnnew TestSuite(TestLocalization.class);
72 }
737475///////////////////////////////////////////////////////////////////////////7677publicvoid testGoodTranslation() throws Exception
78 {
79 Locale locale = null;
80 String test = null;
8182// Test English translation83 locale = new Locale("en", "US");
84 test = CustomLocalization.getString(null, locale, "LOGIN_USERNAME");
85 System.out.println("Locale [en-US]: LOGIN_USER translation = " + test);
8687 assertTrue(test.equals("Username:"));
8889// Test Polish translation90 locale = new Locale("pl", "");
91 test = CustomLocalization.getString(null, locale, "LOGIN_TITLE");
92 System.out.println("Locale [pl]: LOGIN_TITLE translation = " + test);
9394 assertTrue(test.equals("Logowanie"));
9596// Test case when only english translation exists97 locale = new Locale("my", "");
98 test = CustomLocalization.getString(null, locale, "_TEST_");
99 System.out.println("Locale [my]: _TEST_ = " + test);
100101 assertTrue(test.equals("Do not translate"));
102103 }
104105 }
106107108