test/java/util/PluggableLocale/DecimalFormatSymbolsProviderTest.java

Print this page
rev 6057 : imported patch 8001205.8001562


  31 
  32 public class DecimalFormatSymbolsProviderTest extends ProviderTest {
  33 
  34     com.foo.DecimalFormatSymbolsProviderImpl dfsp = new com.foo.DecimalFormatSymbolsProviderImpl();
  35     List<Locale> availloc = Arrays.asList(DecimalFormatSymbols.getAvailableLocales());
  36     List<Locale> providerloc = Arrays.asList(dfsp.getAvailableLocales());
  37     List<Locale> jreloc = Arrays.asList(LocaleProviderAdapter.forJRE().getAvailableLocales());
  38     List<Locale> jreimplloc = Arrays.asList(LocaleProviderAdapter.forJRE().getDecimalFormatSymbolsProvider().getAvailableLocales());
  39 
  40     public static void main(String[] s) {
  41         new DecimalFormatSymbolsProviderTest();
  42     }
  43 
  44     DecimalFormatSymbolsProviderTest() {
  45         availableLocalesTest();
  46         objectValidityTest();
  47     }
  48 
  49     void availableLocalesTest() {
  50         Set<Locale> localesFromAPI = new HashSet<Locale>(availloc);
  51         Set<Locale> localesExpected = new HashSet<Locale>(jreimplloc);
  52         localesExpected.remove(Locale.ROOT);
  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().getNumberFormatData(target);
  66             boolean jreSupportsLocale = jreimplloc.contains(target);
  67 
  68             // JRE string arrays
  69             String[] jres = new String[2];
  70             if (jreSupportsLocale) {
  71                 try {
  72                     String[] tmp = rb.getStringArray("NumberElements");




  31 
  32 public class DecimalFormatSymbolsProviderTest extends ProviderTest {
  33 
  34     com.foo.DecimalFormatSymbolsProviderImpl dfsp = new com.foo.DecimalFormatSymbolsProviderImpl();
  35     List<Locale> availloc = Arrays.asList(DecimalFormatSymbols.getAvailableLocales());
  36     List<Locale> providerloc = Arrays.asList(dfsp.getAvailableLocales());
  37     List<Locale> jreloc = Arrays.asList(LocaleProviderAdapter.forJRE().getAvailableLocales());
  38     List<Locale> jreimplloc = Arrays.asList(LocaleProviderAdapter.forJRE().getDecimalFormatSymbolsProvider().getAvailableLocales());
  39 
  40     public static void main(String[] s) {
  41         new DecimalFormatSymbolsProviderTest();
  42     }
  43 
  44     DecimalFormatSymbolsProviderTest() {
  45         availableLocalesTest();
  46         objectValidityTest();
  47     }
  48 
  49     void availableLocalesTest() {
  50         Set<Locale> localesFromAPI = new HashSet<Locale>(availloc);
  51         Set<Locale> localesExpected = new HashSet<Locale>(jreloc);

  52         localesExpected.addAll(providerloc);
  53         if (localesFromAPI.equals(localesExpected)) {
  54             System.out.println("availableLocalesTest passed.");
  55         } else {
  56             throw new RuntimeException("availableLocalesTest failed");
  57         }
  58     }
  59 
  60     void objectValidityTest() {
  61 
  62         for (Locale target: availloc) {
  63             // pure JRE implementation
  64             ResourceBundle rb = LocaleProviderAdapter.forJRE().getLocaleData().getNumberFormatData(target);
  65             boolean jreSupportsLocale = jreimplloc.contains(target);
  66 
  67             // JRE string arrays
  68             String[] jres = new String[2];
  69             if (jreSupportsLocale) {
  70                 try {
  71                     String[] tmp = rb.getStringArray("NumberElements");