1
|
|
package abbot.i18n;
|
2
|
|
|
3
|
|
import java.util.Locale;
|
4
|
|
|
5
|
|
import junit.extensions.abbot.TestHelper;
|
6
|
|
|
7
|
|
|
8
|
|
public class StringsTest extends junit.framework.TestCase {
|
9
|
|
|
10
|
1
|
public void testMissingResource() throws Throwable {
|
11
|
1
|
Locale oldLocale = Locale.getDefault();
|
12
|
1
|
try {
|
13
|
1
|
Locale.setDefault(Locale.FRENCH);
|
14
|
1
|
String key = "NoSuchResource";
|
15
|
1
|
String value = Strings.get(key);
|
16
|
1
|
assertEquals("Missing resource will be a flagged key",
|
17
|
|
"#" + key + "#", value);
|
18
|
|
|
19
|
1
|
key = "abbot.DefaultPropertiesLoaded";
|
20
|
1
|
value = Strings.get(key);
|
21
|
1
|
assertEquals("Missing i18n resource should get default value",
|
22
|
|
"yes", value);
|
23
|
|
}
|
24
|
|
finally {
|
25
|
1
|
Locale.setDefault(oldLocale);
|
26
|
|
}
|
27
|
|
}
|
28
|
|
|
29
|
1
|
public void testOptionalResource() throws Throwable {
|
30
|
|
|
31
|
1
|
String key = "Menu.acc";
|
32
|
1
|
String value = Strings.get(key, true);
|
33
|
1
|
assertNull("Non-existent, optional value should be null", value);
|
34
|
|
}
|
35
|
|
|
36
|
2
|
public StringsTest(String name) {
|
37
|
2
|
super(name);
|
38
|
|
}
|
39
|
|
|
40
|
0
|
public static void main(String[] args) {
|
41
|
0
|
TestHelper.runTests(args, StringsTest.class);
|
42
|
|
}
|
43
|
|
}
|
44
|
|
|