test/java/util/PluggableLocale/BreakIteratorProviderTest.java

Print this page
rev 6057 : imported patch 8001205.8001562


  37     List<Locale> providerloc = Arrays.asList(bip.getAvailableLocales());
  38     List<Locale> jreloc = Arrays.asList(LocaleProviderAdapter.forJRE().getAvailableLocales());
  39     List<Locale> jreimplloc = Arrays.asList(LocaleProviderAdapter.forJRE().getBreakIteratorProvider().getAvailableLocales());
  40 
  41     private static final int CHARACTER_INDEX = 0;
  42     private static final int WORD_INDEX = 1;
  43     private static final int LINE_INDEX = 2;
  44     private static final int SENTENCE_INDEX = 3;
  45 
  46     public static void main(String[] s) {
  47         new BreakIteratorProviderTest();
  48     }
  49 
  50     BreakIteratorProviderTest() {
  51         availableLocalesTest();
  52         objectValidityTest();
  53     }
  54 
  55     void availableLocalesTest() {
  56         Set<Locale> localesFromAPI = new HashSet<Locale>(availloc);
  57         Set<Locale> localesExpected = new HashSet<Locale>(jreimplloc);
  58         localesExpected.remove(Locale.ROOT);
  59         localesExpected.addAll(providerloc);
  60         if (localesFromAPI.equals(localesExpected)) {
  61             System.out.println("availableLocalesTest passed.");
  62         } else {
  63             throw new RuntimeException("availableLocalesTest failed");
  64         }
  65     }
  66 
  67     void objectValidityTest() {
  68 
  69         for (Locale target: availloc) {
  70             // pure JRE implementation
  71             ResourceBundle rb = LocaleProviderAdapter.forJRE().getLocaleData().getBundle(
  72                         "sun.text.resources.BreakIteratorInfo", target);
  73             String[] classNames = rb.getStringArray("BreakIteratorClasses");
  74             boolean jreSupportsLocale = jreimplloc.contains(target);
  75 
  76             // result object
  77             String[] result = new String[4];
  78             result[0] = BreakIterator.getCharacterInstance(target).getClass().getName();




  37     List<Locale> providerloc = Arrays.asList(bip.getAvailableLocales());
  38     List<Locale> jreloc = Arrays.asList(LocaleProviderAdapter.forJRE().getAvailableLocales());
  39     List<Locale> jreimplloc = Arrays.asList(LocaleProviderAdapter.forJRE().getBreakIteratorProvider().getAvailableLocales());
  40 
  41     private static final int CHARACTER_INDEX = 0;
  42     private static final int WORD_INDEX = 1;
  43     private static final int LINE_INDEX = 2;
  44     private static final int SENTENCE_INDEX = 3;
  45 
  46     public static void main(String[] s) {
  47         new BreakIteratorProviderTest();
  48     }
  49 
  50     BreakIteratorProviderTest() {
  51         availableLocalesTest();
  52         objectValidityTest();
  53     }
  54 
  55     void availableLocalesTest() {
  56         Set<Locale> localesFromAPI = new HashSet<Locale>(availloc);
  57         Set<Locale> localesExpected = new HashSet<Locale>(jreloc);

  58         localesExpected.addAll(providerloc);
  59         if (localesFromAPI.equals(localesExpected)) {
  60             System.out.println("availableLocalesTest passed.");
  61         } else {
  62             throw new RuntimeException("availableLocalesTest failed");
  63         }
  64     }
  65 
  66     void objectValidityTest() {
  67 
  68         for (Locale target: availloc) {
  69             // pure JRE implementation
  70             ResourceBundle rb = LocaleProviderAdapter.forJRE().getLocaleData().getBundle(
  71                         "sun.text.resources.BreakIteratorInfo", target);
  72             String[] classNames = rb.getStringArray("BreakIteratorClasses");
  73             boolean jreSupportsLocale = jreimplloc.contains(target);
  74 
  75             // result object
  76             String[] result = new String[4];
  77             result[0] = BreakIterator.getCharacterInstance(target).getClass().getName();