test/java/util/PluggableLocale/DateFormatSymbolsProviderTest.java

Print this page
rev 6352 : imported patch 7162007


  45         availableLocalesTest();
  46         objectValidityTest();
  47         hashCodeTest();
  48     }
  49 
  50     void availableLocalesTest() {
  51         Set<Locale> localesFromAPI = new HashSet<>(availloc);
  52         Set<Locale> localesExpected = new HashSet<>(jreloc);
  53         localesExpected.addAll(providerloc);
  54         if (localesFromAPI.equals(localesExpected)) {
  55             System.out.println("availableLocalesTest passed.");
  56         } else {
  57             throw new RuntimeException("availableLocalesTest failed");
  58         }
  59     }
  60 
  61     void objectValidityTest() {
  62 
  63         for (Locale target: availloc) {
  64             // pure JRE implementation
  65             ResourceBundle rb = LocaleProviderAdapter.forJRE().getLocaleData().getDateFormatData(target);
  66             boolean jreSupportsLocale = jreimplloc.contains(target);
  67 
  68             // JRE string arrays
  69             String[][] jres = new String[6][];
  70             if (jreSupportsLocale) {
  71                 try {
  72                     jres[0] = (String[])rb.getObject("MonthNames");
  73                     jres[1] = (String[])rb.getObject("MonthAbbreviations");
  74                     jres[2] = (String[])rb.getObject("DayNames");
  75                     jres[3] = (String[])rb.getObject("DayAbbreviations");
  76                     jres[4] = (String[])rb.getObject("AmPmMarkers");
  77                     jres[5] = (String[])rb.getObject("Eras");
  78                 } catch (MissingResourceException mre) {}
  79             }
  80 
  81             // result object
  82             DateFormatSymbols dfs = DateFormatSymbols.getInstance(target);
  83             String[][] result = new String[6][];
  84             result[0] = dfs.getMonths();
  85             result[1] = dfs.getShortMonths();




  45         availableLocalesTest();
  46         objectValidityTest();
  47         hashCodeTest();
  48     }
  49 
  50     void availableLocalesTest() {
  51         Set<Locale> localesFromAPI = new HashSet<>(availloc);
  52         Set<Locale> localesExpected = new HashSet<>(jreloc);
  53         localesExpected.addAll(providerloc);
  54         if (localesFromAPI.equals(localesExpected)) {
  55             System.out.println("availableLocalesTest passed.");
  56         } else {
  57             throw new RuntimeException("availableLocalesTest failed");
  58         }
  59     }
  60 
  61     void objectValidityTest() {
  62 
  63         for (Locale target: availloc) {
  64             // pure JRE implementation
  65             ResourceBundle rb = ((ResourceBundleBasedAdapter)LocaleProviderAdapter.forJRE()).getLocaleData().getDateFormatData(target);
  66             boolean jreSupportsLocale = jreimplloc.contains(target);
  67 
  68             // JRE string arrays
  69             String[][] jres = new String[6][];
  70             if (jreSupportsLocale) {
  71                 try {
  72                     jres[0] = (String[])rb.getObject("MonthNames");
  73                     jres[1] = (String[])rb.getObject("MonthAbbreviations");
  74                     jres[2] = (String[])rb.getObject("DayNames");
  75                     jres[3] = (String[])rb.getObject("DayAbbreviations");
  76                     jres[4] = (String[])rb.getObject("AmPmMarkers");
  77                     jres[5] = (String[])rb.getObject("Eras");
  78                 } catch (MissingResourceException mre) {}
  79             }
  80 
  81             // result object
  82             DateFormatSymbols dfs = DateFormatSymbols.getInstance(target);
  83             String[][] result = new String[6][];
  84             result[0] = dfs.getMonths();
  85             result[1] = dfs.getShortMonths();