1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package net.curre.prefcount.util;
16
17 import java.util.logging.Logger;
18
19 import net.curre.prefcount.test.BaseTestCase;
20
21 import org.apache.commons.lang.StringUtils;
22
23
24
25
26
27
28
29
30 public class LocaleExtTest extends BaseTestCase {
31
32
33 private static Logger log = Logger.getLogger(LocaleExtTest.class.toString());
34
35
36
37
38
39
40 public void testConstructor() throws Exception {
41
42 log.info("Running testConstructor()...");
43
44 final String dispLang = "\u0420\u0443\u0441\u0441\u043A\u0438\u0439";
45 LocaleExt loc = new LocaleExt("ru", "RU", dispLang);
46 assertNotNull("Locale is null", loc.getLocale());
47 assertEquals("Wrong locale's country", "RU", loc.getLocale().getCountry());
48 assertEquals("Wrong locale's language", "ru", loc.getLocale().getLanguage());
49 assertEquals("Wrong display language", dispLang, loc.getDisplayLanguage());
50 assertNotNull("Enabled icon reference is null", loc.getEnabledIcon());
51 assertNotNull("Disabled icon reference is null", loc.getDisabledIcon());
52 }
53
54
55
56
57
58
59 public void testEquals() throws Exception {
60
61 log.info("Running testEquals()...");
62
63 LocaleExt loc0 = new LocaleExt("ru", "RU", "\u0420\u0443\u0441\u0441\u043A\u0438\u0439");
64 assertNotNull("RU locale is null", loc0.getLocale());
65
66 LocaleExt loc1 = new LocaleExt("us", "US", "English US");
67 assertNotNull("First US locale is null", loc1.getLocale());
68
69 LocaleExt loc2 = new LocaleExt("us", "US", "Another English US");
70 assertNotNull("Second US locale is null", loc2.getLocale());
71
72 assertFalse("RU and US locales should not be equal", loc0.equals(loc1));
73 assertTrue("Locale should be equal to itself", loc0.equals(loc0));
74 assertTrue("Different display language should not make locale different", loc1.equals(loc2));
75 Object o = "TESTY";
76 assertFalse("Locale should not be equal to a string", loc0.equals(o));
77 o = null;
78 assertFalse("Locale should not be equal to null", loc0.equals(o));
79 }
80
81
82
83
84
85
86 public void testHashCode() throws Exception {
87
88 log.info("Running testHashCode()...");
89
90 LocaleExt loc = new LocaleExt("us", "US", "English US");
91 assertNotNull("US locale is null", loc.getLocale());
92
93 assertEquals("ExtLocale's hash code should be the same as of it's locale's",
94 loc.getLocale().hashCode(), loc.hashCode());
95 }
96
97
98
99
100
101
102 public void testMiscellaneous() throws Exception {
103
104 log.info("Running testMiscellaneous()...");
105
106 LocaleExt loc = new LocaleExt("us", "US", "English US");
107 assertTrue("toString() is blank", StringUtils.isNotBlank(loc.toString()));
108 }
109
110
111
112 }