ICU-6672 Fixed a missing keywords problem in ULocale#getDefault().

X-SVN-Rev: 25187
This commit is contained in:
Yoshito Umaoka 2009-01-05 22:33:01 +00:00
parent a996a898e0
commit f26b72bf1d
2 changed files with 17 additions and 4 deletions

View File

@ -1,6 +1,6 @@
/*
**********************************************************************
* Copyright (c) 2004-2008, International Business Machines
* Copyright (c) 2004-2009, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
* Author: Alan Liu
@ -231,10 +231,23 @@ public class ULocaleTest extends TestFmwk {
Locale.setDefault(backupDefault);
// Set default via ULocale
ULocale.setDefault(new ULocale("ja_JP@calendar=japanese"));
ULocale ujaJP_calJP = new ULocale("ja_JP@calendar=japanese");
ULocale.setDefault(ujaJP_calJP);
if (!Locale.getDefault().equals(jaJPJP)) {
errln("FAIL: ULocale#setDefault failed to set Java Locale ja_JP_JP /actual: " + Locale.getDefault());
}
// Ticket#6672 - missing keywords
defUloc = ULocale.getDefault();
if (!defUloc.equals(ujaJP_calJP)) {
errln("FAIL: ULocale#getDefault returned " + defUloc + " /expected: ja_JP@calendar=japanese");
}
// Set a incompatible base locale via Locale#setDefault
Locale.setDefault(Locale.US);
defUloc = ULocale.getDefault();
if (defUloc.equals(ujaJP_calJP)) {
errln("FAIL: ULocale#getDefault returned " + defUloc + " /expected: " + ULocale.forLocale(Locale.US));
}
Locale.setDefault(backupDefault);
// We also want to map ICU locale ja@calendar=japanese to Java ja_JP_JP

View File

@ -1,6 +1,6 @@
/*
******************************************************************************
* Copyright (C) 2003-2008, International Business Machines Corporation and *
* Copyright (C) 2003-2009, International Business Machines Corporation and *
* others. All Rights Reserved. *
******************************************************************************
*/
@ -918,7 +918,7 @@ public final class ULocale implements Serializable {
public static ULocale getDefault() {
synchronized (ULocale.class) {
Locale currentDefault = Locale.getDefault();
if (defaultLocale != currentDefault) {
if (!defaultLocale.equals(currentDefault)) {
defaultLocale = currentDefault;
defaultULocale = new ULocale(defaultLocale);
}