/[schmitzm]/branches/2.4.x/src_junit/skrueger/i8n/I8NUtilTest.java
ViewVC logotype

Annotation of /branches/2.4.x/src_junit/skrueger/i8n/I8NUtilTest.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1332 - (hide annotations)
Tue Dec 7 00:36:48 2010 UTC (14 years, 3 months ago) by alfonx
Original Path: trunk/src_junit/skrueger/i8n/I8NUtilTest.java
File MIME type: text/plain
File size: 2013 byte(s)
Used a regex to extends all .*Test classes with TestingClass to initialize logger properly
1 alfonx 1097 package skrueger.i8n;
2    
3     import static org.junit.Assert.assertEquals;
4     import static org.junit.Assert.assertFalse;
5 alfonx 1150 import static org.junit.Assert.assertNotNull;
6 alfonx 1097 import static org.junit.Assert.assertTrue;
7    
8     import java.util.ArrayList;
9     import java.util.List;
10 alfonx 1100 import java.util.Locale;
11 alfonx 1150 import java.util.Set;
12 alfonx 1097
13     import org.junit.BeforeClass;
14     import org.junit.Test;
15    
16 alfonx 1332 import schmitzm.junit.TestingClass;
17     public class I8NUtilTest extends TestingClass {
18 alfonx 1097
19     final static String oneLineCoded = "de{Baum}en{tree}";
20     final static List<String> langs4 = new ArrayList<String>();
21    
22     @BeforeClass
23     public static void setup() {
24     langs4.add("de");
25     langs4.add("en");
26     langs4.add("xx");
27     langs4.add("yy");
28     }
29    
30     @Test
31     public void testCreateFromOneLine() {
32     Translation t = I8NUtil.createFromOneLine(oneLineCoded);
33     assertEquals("Baum", t.toString("de"));
34     assertEquals("tree", t.toString("en"));
35     assertEquals(oneLineCoded, t.toOneLine());
36     }
37    
38     @Test
39     public void testIsValidISOLangCode() {
40     assertTrue(I8NUtil.isValidISOLangCode("de"));
41     assertTrue(I8NUtil.isValidISOLangCode("ar"));
42     assertFalse(I8NUtil.isValidISOLangCode("äü"));
43     assertFalse(I8NUtil.isValidISOLangCode("ara"));
44     }
45    
46     @Test
47     public void testMitUmlaute() {
48     assertEquals("öäü", I8NUtil.mitUmlaute("oeaeue"));
49     }
50    
51     @Test
52     public void testQmTranslation() {
53     Translation t = I8NUtil.createFromOneLine(oneLineCoded);
54     assertEquals(0.5, I8NUtil.qmTranslation(langs4, t), .00000000001);
55     }
56    
57 alfonx 1100 @Test
58     public void testGetLocalesForLang() {
59     List<Locale> locales = I8NUtil.getLocalesForLang("en");
60    
61     assertTrue(locales.contains(new Locale("en", "za")));
62     assertTrue(locales.contains(new Locale("en", "sg")));
63     }
64    
65 alfonx 1150 @Test
66     public void testGetLanguageCodes() {
67     Set<String> languageCodes = I8NUtil.getLanguageCodes();
68    
69     assertTrue(languageCodes.contains("kj"));
70     }
71    
72     @Test
73     public void testGetFirstLocaleForLang() {
74     Locale tjLocaleSelfmade = I8NUtil.getFirstLocaleForLang("kj");
75     assertNotNull(tjLocaleSelfmade);
76     System.out.println(tjLocaleSelfmade);
77     }
78 alfonx 1097 }

Properties

Name Value
svn:eol-style native
svn:keywords Id URL
svn:mime-type text/plain

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26