for (int i = 0; i < INPUT_LOCALEIDS.length; i++) {
String[] localeStrings = INPUT_LOCALEIDS[i];
ArrayList locales = new ArrayList();
StringBuffer sb = new StringBuffer();
for (int j = 0; j < localeStrings.length; j++) {
locales.add(new ULocale(localeStrings[j]));
if (j != 0) {
sb.append(", ");
}
sb.append(localeStrings[j]);
}
logln("Input locales: " + sb.toString());
gp.reset();
gp.setLocales(locales);
List resultLocales = gp.getLocales();
if (resultLocales.size() != RESULTS_LOCALEIDS[i].length) {
errln("FAIL: Number of locales mismatch - GP:" + resultLocales.size()
+ " Expected:" + RESULTS_LOCALEIDS[i].length);
} else {
for (int j = 0; j < RESULTS_LOCALEIDS[i].length; j++) {
ULocale loc = gp.getLocale(j);
logln("Locale[" + j + "]: " + loc.toString());
if (!gp.getLocale(j).toString().equals(RESULTS_LOCALEIDS[i][j])) {
errln("FAIL: Locale index(" + j + ") does not match - GP:" + loc.toString()
+ " Expected:" + RESULTS_LOCALEIDS[i][j]);
}
}
}
}
// setLocales(ULocale[])
for (int i = 0; i < INPUT_LOCALEIDS.length; i++) {
String[] localeStrings = INPUT_LOCALEIDS[i];
ULocale[] localeArray = new ULocale[INPUT_LOCALEIDS[i].length];
StringBuffer sb = new StringBuffer();
for (int j = 0; j < localeStrings.length; j++) {
localeArray[j] = new ULocale(localeStrings[j]);
if (j != 0) {
sb.append(", ");
}
sb.append(localeStrings[j]);
}
logln("Input locales: " + sb.toString());
gp.reset();
gp.setLocales(localeArray);
List resultLocales = gp.getLocales();
if (resultLocales.size() != RESULTS_LOCALEIDS[i].length) {
errln("FAIL: Number of locales mismatch - GP:" + resultLocales.size()
+ " Expected:" + RESULTS_LOCALEIDS[i].length);
} else {
for (int j = 0; j < RESULTS_LOCALEIDS[i].length; j++) {
ULocale loc = gp.getLocale(j);
logln("Locale[" + j + "]: " + loc.toString());
if (!gp.getLocale(j).toString().equals(RESULTS_LOCALEIDS[i][j])) {
errln("FAIL: Locale index(" + j + ") does not match - GP:" + loc.toString()
+ " Expected:" + RESULTS_LOCALEIDS[i][j]);
}
}
}
}
// setLocales(String)
for (int i = 0; i < ACCEPT_LANGUAGES.length; i++) {
String acceptLanguage = ACCEPT_LANGUAGES[i];
logln("Accept language: " + acceptLanguage);
gp.reset();
gp.setLocales(acceptLanguage);
List resultLocales = gp.getLocales();
if (resultLocales.size() != RESULTS_LOCALEIDS[i].length) {
errln("FAIL: Number of locales mismatch - GP:" + resultLocales.size()
+ " Expected:" + RESULTS_LOCALEIDS[i].length);
} else {
for (int j = 0; j < RESULTS_LOCALEIDS[i].length; j++) {
ULocale loc = gp.getLocale(j);
logln("Locale[" + j + "]: " + loc.toString());
if (!gp.getLocale(j).toString().equals(RESULTS_LOCALEIDS[i][j])) {
errln("FAIL: Locale index(" + j + ") does not match - GP:" + loc.toString()
+ " Expected:" + RESULTS_LOCALEIDS[i][j]);
}
}
}
}
// accept-language without q-value
logln("Set accept-language - de,de-AT");
gp.setLocales("de,de-AT");
if (!gp.getLocale(0).toString().equals("de_AT")) {
errln("FAIL: getLocale(0) returns " + gp.getLocale(0).toString() + " Expected: de_AT");
}
// Invalid accept-language
logln("Set locale - ko_KR");
gp.setLocale(new ULocale("ko_KR"));
boolean bException = false;
try {
logln("Set invlaid accept-language - ko=100");
gp.setLocales("ko=100");
} catch (IllegalArgumentException iae) {