ICU-9150 Workaround for locale SPI tests on Java 7 environment.

X-SVN-Rev: 31537
This commit is contained in:
Yoshito Umaoka 2012-02-29 06:35:16 +00:00
parent d381e10433
commit 58a11c2260
4 changed files with 42 additions and 10 deletions

View file

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 2008-2010, International Business Machines Corporation and *
* Copyright (C) 2008-2012, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -60,9 +60,15 @@ public class CurrencyNameTest extends TestFmwk {
continue;
}
// Note: Short term workaround for Java locale with script.
// Java Locale with non-empty script cannot have variant "ICU"
// because it's not well-formed as BCP 47. Because we cannot
// build such Locale, we skip the check below for now.
boolean ignoreErrorForNow = TestUtil.hasScript(loc);
if (TestUtil.isICUExtendedLocale(loc)) {
if (!curSymbol.equals(curSymbolIcu)) {
if (!curSymbol.equals(curSymbolIcu)) {
if (!curSymbol.equals(curSymbolIcu) && !ignoreErrorForNow) {
errln("FAIL: Currency symbol for " + currencyCode + " by ICU is " + curSymbolIcu
+ ", but got " + curSymbol + " in locale " + loc);
}
@ -75,7 +81,7 @@ public class CurrencyNameTest extends TestFmwk {
// Try explicit ICU locale (xx_yy_ICU)
Locale locIcu = TestUtil.toICUExtendedLocale(loc);
curSymbol = currency.getSymbol(locIcu);
if (!curSymbol.equals(curSymbolIcu)) {
if (!curSymbol.equals(curSymbolIcu) && !ignoreErrorForNow) {
errln("FAIL: Currency symbol for " + currencyCode + " by ICU is " + curSymbolIcu
+ ", but got " + curSymbol + " in locale " + locIcu);
}

View file

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 2008, International Business Machines Corporation and *
* Copyright (C) 2008-2012, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -53,9 +53,16 @@ public class LocaleNameTest extends TestFmwk {
}
String name = forLocale.getDisplayLanguage(inLocale);
// Note: Short term workaround for Java locale with script.
// Java Locale with non-empty script cannot have variant "ICU"
// because it's not well-formed as BCP 47. Because we cannot
// build such Locale, we skip the check below for now.
boolean ignoreErrorForNow = TestUtil.hasScript(inLocale);
if (TestUtil.isICUExtendedLocale(inLocale)) {
// The name should be taken from ICU
if (!name.equals(icuname)) {
if (!name.equals(icuname) && !ignoreErrorForNow) {
errln("FAIL: Language name by ICU is " + icuname + ", but got " + name
+ " for locale " + forLocale + " in locale " + inLocale);
}
@ -66,7 +73,7 @@ public class LocaleNameTest extends TestFmwk {
}
// Try explicit ICU locale (xx_yy_ICU)
name = forLocale.getDisplayLanguage(inLocaleICU);
if (!name.equals(icuname)) {
if (!name.equals(icuname) && !ignoreErrorForNow) {
errln("FAIL: Language name by ICU is " + icuname + ", but got " + name
+ " for locale " + forLocale + " in locale " + inLocaleICU);
}

View file

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 2008-2009, International Business Machines Corporation and *
* Copyright (C) 2008-2012, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -8,6 +8,8 @@ package com.ibm.icu.dev.test.localespi;
import java.util.Locale;
import com.ibm.icu.util.ULocale;
public class TestUtil {
private static final String ICU_VARIANT = "ICU";
@ -99,4 +101,14 @@ public class TestUtil {
}
return false;
}
/**
* Check if the given Locale has script field (Java 7+)
* @param locale the locale
* @return true if the given Locale has non-empty script
*/
public static boolean hasScript(Locale locale) {
ULocale uloc = ULocale.forLocale(locale);
return uloc.getScript().length() > 0;
}
}

View file

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 2008-2010, International Business Machines Corporation and *
* Copyright (C) 2008-2012, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -91,10 +91,17 @@ public class TimeZoneNameTest extends TestFmwk {
String styleStr = (style == TimeZone.SHORT) ? "SHORT" : "LONG";
String name = tz.getDisplayName(daylight, style, loc);
// Note: Short term workaround for Java locale with script.
// Java Locale with non-empty script cannot have variant "ICU"
// because it's not well-formed as BCP 47. Because we cannot
// build such Locale, we skip the check below for now.
boolean ignoreErrorForNow = TestUtil.hasScript(loc);
if (TestUtil.isICUExtendedLocale(loc)) {
// The name should be taken from ICU
if (!name.equals(icuname)) {
if (warnOnly) {
if (warnOnly || ignoreErrorForNow) {
logln("WARNING: TimeZone name by ICU is " + icuname + ", but got " + name
+ " for time zone " + tz.getID() + " in locale " + loc
+ " (daylight=" + daylight + ", style=" + styleStr + ")");
@ -115,7 +122,7 @@ public class TimeZoneNameTest extends TestFmwk {
Locale icuLoc = TestUtil.toICUExtendedLocale(loc);
name = tz.getDisplayName(daylight, style, icuLoc);
if (!name.equals(icuname)) {
if (warnOnly) {
if (warnOnly || ignoreErrorForNow) {
logln("WARNING: TimeZone name by ICU is " + icuname + ", but got " + name
+ " for time zone " + tz.getID() + " in locale " + icuLoc
+ " (daylight=" + daylight + ", style=" + styleStr + ")");