test/java/util/PluggableLocale/CurrencyNameProviderTest.java

Print this page
rev 5931 : imported patch 8000245.8000273.8000615

*** 48,63 **** void test1() { com.bar.CurrencyNameProviderImpl cnp = new com.bar.CurrencyNameProviderImpl(); Locale[] availloc = Locale.getAvailableLocales(); Locale[] testloc = availloc.clone(); List<Locale> providerloc = Arrays.asList(cnp.getAvailableLocales()); for (Locale target: availloc) { // pure JRE implementation OpenListResourceBundle rb = (OpenListResourceBundle)LocaleProviderAdapter.forJRE().getLocaleData().getCurrencyNames(target); ! boolean jreHasBundle = rb.getLocale().equals(target); for (Locale test: testloc) { // get a Currency instance Currency c = null; try { --- 48,64 ---- void test1() { com.bar.CurrencyNameProviderImpl cnp = new com.bar.CurrencyNameProviderImpl(); Locale[] availloc = Locale.getAvailableLocales(); Locale[] testloc = availloc.clone(); + List<Locale> jreimplloc = Arrays.asList(LocaleProviderAdapter.forJRE().getCurrencyNameProvider().getAvailableLocales()); List<Locale> providerloc = Arrays.asList(cnp.getAvailableLocales()); for (Locale target: availloc) { // pure JRE implementation OpenListResourceBundle rb = (OpenListResourceBundle)LocaleProviderAdapter.forJRE().getLocaleData().getCurrencyNames(target); ! boolean jreSupportsTarget = jreimplloc.contains(target); for (Locale test: testloc) { // get a Currency instance Currency c = null; try {
*** 80,110 **** if (providerloc.contains(target)) { providerscurrency = cnp.getSymbol(c.getCurrencyCode(), target); providersname = cnp.getDisplayName(c.getCurrencyCode(), target); } ! // JRE's name (if any) String jrescurrency = null; String jresname = null; String key = c.getCurrencyCode(); String nameKey = key.toLowerCase(Locale.ROOT); ! if (jreHasBundle) { try { jrescurrency = rb.getString(key); ! } catch (MissingResourceException mre) { ! // JRE does not have any resource, "jrescurrency" should remain null ! } try { jresname = rb.getString(nameKey); ! } catch (MissingResourceException mre) { ! // JRE does not have any resource, "jresname" should remain null } - } ! checkValidity(target, jrescurrency, providerscurrency, currencyresult, jrescurrency!=null); checkValidity(target, jresname, providersname, nameresult, ! jreHasBundle && rb.handleGetKeys().contains(nameKey)); } } } --- 81,108 ---- if (providerloc.contains(target)) { providerscurrency = cnp.getSymbol(c.getCurrencyCode(), target); providersname = cnp.getDisplayName(c.getCurrencyCode(), target); } ! // JRE's name String jrescurrency = null; String jresname = null; String key = c.getCurrencyCode(); String nameKey = key.toLowerCase(Locale.ROOT); ! if (jreSupportsTarget) { try { jrescurrency = rb.getString(key); ! } catch (MissingResourceException mre) {} try { jresname = rb.getString(nameKey); ! } catch (MissingResourceException mre) {} } ! checkValidity(target, jrescurrency, providerscurrency, currencyresult, ! jreSupportsTarget && jrescurrency != null); checkValidity(target, jresname, providersname, nameresult, ! jreSupportsTarget && jresname != null); } } }