From 3c5cd056bd8421b6721394481b292e921b2c6ac8 Mon Sep 17 00:00:00 2001 From: Ram Viswanadha Date: Tue, 16 Nov 2004 19:24:45 +0000 Subject: [PATCH] ICU-4102 synch tests with ICU4C X-SVN-Rev: 16873 --- .../dev/test/util/ICUResourceBundleTest.java | 21 +++++++++++++++++++ .../com/ibm/icu/impl/ICUResourceBundle.java | 11 +++++++++- .../src/com/ibm/icu/util/UResourceBundle.java | 4 +++- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/icu4j/src/com/ibm/icu/dev/test/util/ICUResourceBundleTest.java b/icu4j/src/com/ibm/icu/dev/test/util/ICUResourceBundleTest.java index 9472a9f67a..73f2ab6a36 100644 --- a/icu4j/src/com/ibm/icu/dev/test/util/ICUResourceBundleTest.java +++ b/icu4j/src/com/ibm/icu/dev/test/util/ICUResourceBundleTest.java @@ -21,6 +21,7 @@ import com.ibm.icu.text.UTF16; import com.ibm.icu.util.Holiday; import com.ibm.icu.util.ULocale; import com.ibm.icu.util.UResourceBundle; +import com.ibm.icu.util.UResourceTypeMismatchException; public final class ICUResourceBundleTest extends TestFmwk { @@ -761,5 +762,25 @@ public final class ICUResourceBundleTest extends TestFmwk { errln("Caught an unexpected expected"); } } + public void TestJB4102(){ + try { + ICUResourceBundle root =(ICUResourceBundle) ICUResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, "root"); + ICUResourceBundle t = null; + try{ + t = root.getWithFallback("calendar/islamic-civil/DateTimePatterns"); + errln("Second resource does not exist. How did it get here?\n"); + }catch(MissingResourceException ex){ + logln("Got the expected exception"); + } + try{ + t = root.getWithFallback("calendar/islamic-civil/eras/abbreviated/0/mikimaus/pera"); + errln("Second resource does not exist. How did it get here?\n"); + }catch(UResourceTypeMismatchException ex){ + logln("Got the expected exception"); + } + } catch (MissingResourceException e) { + warnln("Could not load the locale data"); + } + } } diff --git a/icu4j/src/com/ibm/icu/impl/ICUResourceBundle.java b/icu4j/src/com/ibm/icu/impl/ICUResourceBundle.java index 13afb98c03..a3ac8b91b2 100644 --- a/icu4j/src/com/ibm/icu/impl/ICUResourceBundle.java +++ b/icu4j/src/com/ibm/icu/impl/ICUResourceBundle.java @@ -1007,5 +1007,14 @@ public abstract class ICUResourceBundle extends UResourceBundle{ } return sub; } - + public boolean equals(Object other){ + if(other instanceof ICUResourceBundle){ + ICUResourceBundle o = (ICUResourceBundle)other; + if(getBaseName().equals(o.getBaseName())&& + getULocale().equals(o.getULocale())){ + return true; + } + } + return false; + } } diff --git a/icu4j/src/com/ibm/icu/util/UResourceBundle.java b/icu4j/src/com/ibm/icu/util/UResourceBundle.java index f369ee155f..34aa417dd7 100644 --- a/icu4j/src/com/ibm/icu/util/UResourceBundle.java +++ b/icu4j/src/com/ibm/icu/util/UResourceBundle.java @@ -464,7 +464,9 @@ public abstract class UResourceBundle extends ResourceBundle{ }else{ parent = ICUResourceBundle.createBundle(baseName, rootLocale, root); } - b.setParent(parent); + if(!b.equals(parent)){ + b.setParent(parent); + } } } return b;