errln("FAIL: MissingResourceException must be thrown for RB - foo.bar.XXX");
}
}
public void TestTerritory() {
GlobalizationPreferences gp = new GlobalizationPreferences();
// Territory for unsupported language locale
logln("Set locale - ang");
gp.setLocale(new ULocale("ang"));
String territory = gp.getTerritory();
if (!territory.equals("US")) {
errln("FAIL: Territory is " + territory + " - Expected: US");
}
// Territory for language only locale "fr"
logln("Set locale - fr");
gp.setLocale(new ULocale("fr"));
territory = gp.getTerritory();
if (!territory.equals("FR")) {
errln("FAIL: Territory is " + territory + " - Expected: FR");
}
// Set explicity territory
logln("Set explicit territory - CA");
gp.setTerritory("CA");
territory = gp.getTerritory();
if (!territory.equals("CA")) {
errln("FAIL: Territory is " + territory + " - Expected: CA");
}
// Freeze
logln("Freeze this object");
gp.freeze();
boolean bFrozen = false;
try {
gp.setTerritory("FR");
} catch (UnsupportedOperationException uoe) {
logln("setTerritory is blocked");
bFrozen = true;
}
if (!bFrozen) {
errln("FAIL: setTerritory must be blocked after frozen");
}
territory = gp.getTerritory();
if (!territory.equals("CA")) {
errln("FAIL: Territory is not CA");
}
// Safe clone
GlobalizationPreferences gp1 = (GlobalizationPreferences)gp.cloneAsThawed();
territory = gp1.getTerritory();
if (!territory.equals("CA")) {
errln("FAIL: Territory is " + territory + " - Expected: CA");
}
gp1.reset();
ULocale[] locales = new ULocale[2];
locales[0] = new ULocale("ja");
locales[1] = new ULocale("zh_Hant_TW");
logln("Set locales - ja, zh_Hant_TW");
gp1.setLocales(locales);
territory = gp1.getTerritory();
if (!territory.equals("TW")) {
errln("FAIL: Territory is " + territory + " - Expected: TW");
}
}