ICU-6368 Workaround for the IBM Java 6 Locale SPI support problems in the test cases.

X-SVN-Rev: 24252
This commit is contained in:
Yoshito Umaoka 2008-06-20 15:22:15 +00:00
parent 5da06ab009
commit 5f799aea8c
10 changed files with 92 additions and 0 deletions

View file

@ -26,6 +26,10 @@ public class BreakIteratorTest extends TestFmwk {
*/
public void TestGetInstance() {
for (Locale loc : BreakIterator.getAvailableLocales()) {
if (TestUtil.isProblematicIBMLocale(loc)) {
logln("Skipped " + loc);
continue;
}
checkGetInstance(CHARACTER_BRK, loc);
checkGetInstance(WORD_BRK, loc);
checkGetInstance(LINE_BRK, loc);

View file

@ -22,6 +22,11 @@ public class CollatorTest extends TestFmwk {
*/
public void TestGetInstance() {
for (Locale loc : Collator.getAvailableLocales()) {
if (TestUtil.isProblematicIBMLocale(loc)) {
logln("Skipped " + loc);
continue;
}
Collator coll = Collator.getInstance(loc);
boolean isIcuImpl = (coll instanceof com.ibm.icu.impl.jdkadapter.CollatorICU);

View file

@ -39,6 +39,11 @@ public class CurrencyNameTest extends TestFmwk {
continue;
}
for (Locale loc : Locale.getAvailableLocales()) {
if (TestUtil.isProblematicIBMLocale(loc)) {
logln("Skipped " + loc);
continue;
}
String curSymbol = currency.getSymbol(loc);
String curSymbolIcu = currencyIcu.getSymbol(loc);

View file

@ -21,6 +21,11 @@ public class DateFormatSymbolsTest extends TestFmwk {
*/
public void TestGetInstance() {
for (Locale loc : DateFormatSymbols.getAvailableLocales()) {
if (TestUtil.isProblematicIBMLocale(loc)) {
logln("Skipped " + loc);
continue;
}
DateFormatSymbols dfs = DateFormatSymbols.getInstance(loc);
boolean isIcuImpl = (dfs instanceof com.ibm.icu.impl.jdkadapter.DateFormatSymbolsICU);

View file

@ -24,6 +24,10 @@ public class DateFormatTest extends TestFmwk {
*/
public void TestGetInstance() {
for (Locale loc : DateFormat.getAvailableLocales()) {
if (TestUtil.isProblematicIBMLocale(loc)) {
logln("Skipped " + loc);
continue;
}
checkGetInstance(DateFormat.FULL, DateFormat.LONG, loc);
checkGetInstance(DateFormat.MEDIUM, -1, loc);
checkGetInstance(1, DateFormat.SHORT, loc);

View file

@ -22,6 +22,11 @@ public class DecimalFormatSymbolsTest extends TestFmwk {
*/
public void TestGetInstance() {
for (Locale loc : DecimalFormatSymbols.getAvailableLocales()) {
if (TestUtil.isProblematicIBMLocale(loc)) {
logln("Skipped " + loc);
continue;
}
DecimalFormatSymbols decfs = DecimalFormatSymbols.getInstance(loc);
boolean isIcuImpl = (decfs instanceof com.ibm.icu.impl.jdkadapter.DecimalFormatSymbolsICU);

View file

@ -20,6 +20,11 @@ public class LocaleNameTest extends TestFmwk {
Locale[] locales = Locale.getAvailableLocales();
StringBuffer icuid = new StringBuffer();
for (Locale inLocale : locales) {
if (TestUtil.isProblematicIBMLocale(inLocale)) {
logln("Skipped " + inLocale);
continue;
}
ULocale inULocale = ULocale.forLocale(inLocale);
Locale inLocaleICU = TestUtil.toICUExtendedLocale(inLocale);
for (Locale forLocale : locales) {
@ -73,6 +78,11 @@ public class LocaleNameTest extends TestFmwk {
public void TestCountryNames() {
Locale[] locales = Locale.getAvailableLocales();
for (Locale inLocale : locales) {
if (TestUtil.isProblematicIBMLocale(inLocale)) {
logln("Skipped " + inLocale);
continue;
}
ULocale inULocale = ULocale.forLocale(inLocale);
Locale inLocaleICU = TestUtil.toICUExtendedLocale(inLocale);
for (Locale forLocale : locales) {
@ -114,6 +124,11 @@ public class LocaleNameTest extends TestFmwk {
Locale[] locales = Locale.getAvailableLocales();
StringBuffer icuid = new StringBuffer();
for (Locale inLocale : locales) {
if (TestUtil.isProblematicIBMLocale(inLocale)) {
logln("Skipped " + inLocale);
continue;
}
ULocale inULocale = ULocale.forLocale(inLocale);
Locale inLocaleICU = TestUtil.toICUExtendedLocale(inLocale);
for (Locale forLocale : locales) {

View file

@ -30,6 +30,10 @@ public class NumberFormatTest extends TestFmwk {
*/
public void TestGetInstance() {
for (Locale loc : NumberFormat.getAvailableLocales()) {
if (TestUtil.isProblematicIBMLocale(loc)) {
logln("Skipped " + loc);
continue;
}
checkGetInstance(DEFAULT_TYPE, loc);
checkGetInstance(NUMBER_TYPE, loc);
checkGetInstance(INTEGER_TYPE, loc);

View file

@ -39,4 +39,45 @@ public class TestUtil {
}
return o1.equals(o2);
}
/*
* Ticket#6368
*
* The ICU4J locale spi test cases reports many errors on IBM Java 6. There are two kinds
* of problems observed and both of them look like implementation problems in IBM Java 6.
*
* - When a locale has variant field (for example, sr_RS_Cyrl, de_DE_PREEURO), adding ICU
* suffix in the variant field (for example, sr_RS_Cyrl_ICU, de_DE_PREEURO_ICU) has no effects.
* For these locales, IBM JRE 6 ignores installed Locale providers.
*
* - For "sh" sublocales with "ICU" variant (for example, sh__ICU, sh_CS_ICU), IBM JRE 6 also
* ignores installed ICU locale providers. Probably, "sh" is internally mapped to "sr_RS_Cyrl"
* internally before locale look up.
*
* For now, we exclude these problematic locales from locale spi test cases on IBM Java 6.
*/
private static final boolean IBMJRE;
static {
String javaVendor = System.getProperty("java.vendor");
if (javaVendor != null && javaVendor.indexOf("IBM") >= 0) {
IBMJRE = true;
} else {
IBMJRE = false;
}
}
public static boolean isProblematicIBMLocale(Locale loc) {
if (!IBMJRE) {
return false;
}
if (loc.getLanguage().equals("sh")) {
return true;
}
String variant = loc.getVariant();
if (variant.startsWith("EURO") || variant.startsWith("PREEURO")
|| variant.startsWith("Cyrl") || variant.startsWith("Latn")) {
return true;
}
return false;
}
}

View file

@ -21,6 +21,10 @@ public class TimeZoneNameTest extends TestFmwk {
public void TestTimeZoneNames() {
String[] tzids = TimeZone.getAvailableIDs();
for (Locale loc : Locale.getAvailableLocales()) {
if (TestUtil.isProblematicIBMLocale(loc)) {
logln("Skipped " + loc);
continue;
}
for (String tzid : tzids) {
TimeZone tz = TimeZone.getTimeZone(tzid);
com.ibm.icu.util.TimeZone tzIcu = com.ibm.icu.util.TimeZone.getTimeZone(tzid);