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

Contents of /branches/2.3.x/src_junit/skrueger/i8n/I8NUtilTest.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1240 - (show annotations)
Fri Nov 5 13:02:30 2010 UTC (14 years, 3 months ago) by alfonx
File MIME type: text/plain
File size: 1956 byte(s)
Branch 2.3.x angelegt

1 package skrueger.i8n;
2
3 import static org.junit.Assert.assertEquals;
4 import static org.junit.Assert.assertFalse;
5 import static org.junit.Assert.assertNotNull;
6 import static org.junit.Assert.assertTrue;
7
8 import java.util.ArrayList;
9 import java.util.List;
10 import java.util.Locale;
11 import java.util.Set;
12
13 import org.junit.BeforeClass;
14 import org.junit.Test;
15
16 public class I8NUtilTest {
17
18 final static String oneLineCoded = "de{Baum}en{tree}";
19 final static List<String> langs4 = new ArrayList<String>();
20
21 @BeforeClass
22 public static void setup() {
23 langs4.add("de");
24 langs4.add("en");
25 langs4.add("xx");
26 langs4.add("yy");
27 }
28
29 @Test
30 public void testCreateFromOneLine() {
31 Translation t = I8NUtil.createFromOneLine(oneLineCoded);
32 assertEquals("Baum", t.toString("de"));
33 assertEquals("tree", t.toString("en"));
34 assertEquals(oneLineCoded, t.toOneLine());
35 }
36
37 @Test
38 public void testIsValidISOLangCode() {
39 assertTrue(I8NUtil.isValidISOLangCode("de"));
40 assertTrue(I8NUtil.isValidISOLangCode("ar"));
41 assertFalse(I8NUtil.isValidISOLangCode("äü"));
42 assertFalse(I8NUtil.isValidISOLangCode("ara"));
43 }
44
45 @Test
46 public void testMitUmlaute() {
47 assertEquals("öäü", I8NUtil.mitUmlaute("oeaeue"));
48 }
49
50 @Test
51 public void testQmTranslation() {
52 Translation t = I8NUtil.createFromOneLine(oneLineCoded);
53 assertEquals(0.5, I8NUtil.qmTranslation(langs4, t), .00000000001);
54 }
55
56 @Test
57 public void testGetLocalesForLang() {
58 List<Locale> locales = I8NUtil.getLocalesForLang("en");
59
60 assertTrue(locales.contains(new Locale("en", "za")));
61 assertTrue(locales.contains(new Locale("en", "sg")));
62 }
63
64 @Test
65 public void testGetLanguageCodes() {
66 Set<String> languageCodes = I8NUtil.getLanguageCodes();
67
68 assertTrue(languageCodes.contains("kj"));
69 }
70
71 @Test
72 public void testGetFirstLocaleForLang() {
73 Locale tjLocaleSelfmade = I8NUtil.getFirstLocaleForLang("kj");
74 assertNotNull(tjLocaleSelfmade);
75 System.out.println(tjLocaleSelfmade);
76 }
77 }

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