test/java/util/PluggableLocale/GenericTest.java

Print this page
rev 6057 : imported patch 8001205.8001562


  56      * Make sure that all the locales are available from the existing providers
  57      */
  58     void availableLocalesTest() {
  59         // Check that Locale.getAvailableLocales() returns the union of the JRE supported
  60         // locales and providers' locales
  61         HashSet<Locale> result =
  62             new HashSet<>(Arrays.asList(Locale.getAvailableLocales()));
  63         HashSet<Locale> expected =
  64             new HashSet<>(Arrays.asList(LocaleProviderAdapter.forJRE().getAvailableLocales()));
  65         expected.addAll(Arrays.asList(breakIP.getAvailableLocales()));
  66         expected.addAll(Arrays.asList(collatorP.getAvailableLocales()));
  67         expected.addAll(Arrays.asList(dateFP.getAvailableLocales()));
  68         expected.addAll(Arrays.asList(dateFSP.getAvailableLocales()));
  69         expected.addAll(Arrays.asList(decimalFSP.getAvailableLocales()));
  70         expected.addAll(Arrays.asList(numberFP.getAvailableLocales()));
  71         expected.addAll(Arrays.asList(currencyNP.getAvailableLocales()));
  72         expected.addAll(Arrays.asList(currencyNP2.getAvailableLocales()));
  73         expected.addAll(Arrays.asList(localeNP.getAvailableLocales()));
  74         expected.addAll(Arrays.asList(tzNP.getAvailableLocales()));
  75         expected.addAll(Arrays.asList(calDataP.getAvailableLocales()));
  76         expected.remove(Locale.ROOT);
  77         if (!result.equals(expected)) {
  78             throw new RuntimeException("Locale.getAvailableLocales() does not return the union of locales: diff="
  79                                        + getDiff(result, expected));
  80         }
  81     }
  82 
  83     /**
  84      * test with "xx_YY_ZZ", which is an example locale not contained
  85      * in Locale.getAvailableLocales().  Fallback tests for supported locales
  86      * are done in each xxxProviderTest test cases.
  87      */
  88     void localeFallbackTest() {
  89         Locale xx = new Locale("xx");
  90         Locale dispLocale = new Locale ("xx", "YY", "ZZ");
  91 
  92         String xxname = xx.getDisplayLanguage(xx);
  93         String expected = localeNP.getDisplayLanguage(xx.getLanguage(), dispLocale);
  94         if (!xxname.equals(expected)) {
  95             throw new RuntimeException("Locale fallback did not perform correctly. got: "+xxname+" expected: "+expected);
  96         }


  56      * Make sure that all the locales are available from the existing providers
  57      */
  58     void availableLocalesTest() {
  59         // Check that Locale.getAvailableLocales() returns the union of the JRE supported
  60         // locales and providers' locales
  61         HashSet<Locale> result =
  62             new HashSet<>(Arrays.asList(Locale.getAvailableLocales()));
  63         HashSet<Locale> expected =
  64             new HashSet<>(Arrays.asList(LocaleProviderAdapter.forJRE().getAvailableLocales()));
  65         expected.addAll(Arrays.asList(breakIP.getAvailableLocales()));
  66         expected.addAll(Arrays.asList(collatorP.getAvailableLocales()));
  67         expected.addAll(Arrays.asList(dateFP.getAvailableLocales()));
  68         expected.addAll(Arrays.asList(dateFSP.getAvailableLocales()));
  69         expected.addAll(Arrays.asList(decimalFSP.getAvailableLocales()));
  70         expected.addAll(Arrays.asList(numberFP.getAvailableLocales()));
  71         expected.addAll(Arrays.asList(currencyNP.getAvailableLocales()));
  72         expected.addAll(Arrays.asList(currencyNP2.getAvailableLocales()));
  73         expected.addAll(Arrays.asList(localeNP.getAvailableLocales()));
  74         expected.addAll(Arrays.asList(tzNP.getAvailableLocales()));
  75         expected.addAll(Arrays.asList(calDataP.getAvailableLocales()));

  76         if (!result.equals(expected)) {
  77             throw new RuntimeException("Locale.getAvailableLocales() does not return the union of locales: diff="
  78                                        + getDiff(result, expected));
  79         }
  80     }
  81 
  82     /**
  83      * test with "xx_YY_ZZ", which is an example locale not contained
  84      * in Locale.getAvailableLocales().  Fallback tests for supported locales
  85      * are done in each xxxProviderTest test cases.
  86      */
  87     void localeFallbackTest() {
  88         Locale xx = new Locale("xx");
  89         Locale dispLocale = new Locale ("xx", "YY", "ZZ");
  90 
  91         String xxname = xx.getDisplayLanguage(xx);
  92         String expected = localeNP.getDisplayLanguage(xx.getLanguage(), dispLocale);
  93         if (!xxname.equals(expected)) {
  94             throw new RuntimeException("Locale fallback did not perform correctly. got: "+xxname+" expected: "+expected);
  95         }