test/java/util/PluggableLocale/NumberFormatProviderTest.java

Print this page
rev 6057 : imported patch 8001205.8001562


  34 public class NumberFormatProviderTest extends ProviderTest {
  35 
  36     com.foo.NumberFormatProviderImpl nfp = new com.foo.NumberFormatProviderImpl();
  37     List<Locale> availloc = Arrays.asList(NumberFormat.getAvailableLocales());
  38     List<Locale> providerloc = Arrays.asList(nfp.getAvailableLocales());
  39     List<Locale> jreloc = Arrays.asList(LocaleProviderAdapter.forJRE().getAvailableLocales());
  40     List<Locale> jreimplloc = Arrays.asList(LocaleProviderAdapter.forJRE().getNumberFormatProvider().getAvailableLocales());
  41 
  42     public static void main(String[] s) {
  43         new NumberFormatProviderTest();
  44     }
  45 
  46     NumberFormatProviderTest() {
  47         availableLocalesTest();
  48         objectValidityTest();
  49         messageFormatTest();
  50     }
  51 
  52     void availableLocalesTest() {
  53         Set<Locale> localesFromAPI = new HashSet<Locale>(availloc);
  54         Set<Locale> localesExpected = new HashSet<Locale>(jreimplloc);
  55         localesExpected.remove(Locale.ROOT);
  56         localesExpected.addAll(providerloc);
  57         if (localesFromAPI.equals(localesExpected)) {
  58             System.out.println("availableLocalesTest passed.");
  59         } else {
  60             throw new RuntimeException("availableLocalesTest failed");
  61         }
  62     }
  63 
  64     void objectValidityTest() {
  65 
  66         for (Locale target: availloc) {
  67             // pure JRE implementation
  68             ResourceBundle rb = LocaleProviderAdapter.forJRE().getLocaleData().getNumberFormatData(target);
  69             boolean jreSupportsLocale = jreimplloc.contains(target);
  70 
  71             // JRE string arrays
  72             String[] jreNumberPatterns = null;
  73             if (jreSupportsLocale) {
  74                 try {
  75                     jreNumberPatterns = rb.getStringArray("NumberPatterns");




  34 public class NumberFormatProviderTest extends ProviderTest {
  35 
  36     com.foo.NumberFormatProviderImpl nfp = new com.foo.NumberFormatProviderImpl();
  37     List<Locale> availloc = Arrays.asList(NumberFormat.getAvailableLocales());
  38     List<Locale> providerloc = Arrays.asList(nfp.getAvailableLocales());
  39     List<Locale> jreloc = Arrays.asList(LocaleProviderAdapter.forJRE().getAvailableLocales());
  40     List<Locale> jreimplloc = Arrays.asList(LocaleProviderAdapter.forJRE().getNumberFormatProvider().getAvailableLocales());
  41 
  42     public static void main(String[] s) {
  43         new NumberFormatProviderTest();
  44     }
  45 
  46     NumberFormatProviderTest() {
  47         availableLocalesTest();
  48         objectValidityTest();
  49         messageFormatTest();
  50     }
  51 
  52     void availableLocalesTest() {
  53         Set<Locale> localesFromAPI = new HashSet<Locale>(availloc);
  54         Set<Locale> localesExpected = new HashSet<Locale>(jreloc);

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