Search in sources :

Example 46 with UResourceBundle

use of android.icu.util.UResourceBundle in project j2objc by google.

the class ICUResourceBundleTest method TestICUGetKeysAtTopLevel.

/**
 * Test ICUResourceBundle.getKeys() for a whole bundle (top-level resource).
 * JDK JavaDoc for ResourceBundle.getKeys() says that it returns
 * "an Enumeration of the keys contained in this ResourceBundle and its parent bundles."
 */
@Test
public void TestICUGetKeysAtTopLevel() {
    String baseName = "android/icu/dev/data/testdata";
    UResourceBundle te_IN = UResourceBundle.getBundleInstance(baseName, "te_IN", testLoader);
    UResourceBundle te = UResourceBundle.getBundleInstance(baseName, "te", testLoader);
    Set<String> te_set = setFromEnumeration(te.getKeys());
    Set<String> te_IN_set = setFromEnumeration(te_IN.getKeys());
    assertTrue("te.getKeys().contains(string_only_in_Root)", te_set.contains("string_only_in_Root"));
    assertTrue("te.getKeys().contains(string_only_in_te)", te_set.contains("string_only_in_te"));
    assertFalse("te.getKeys().contains(string_only_in_te_IN)", te_set.contains("string_only_in_te_IN"));
    assertTrue("te_IN.getKeys().contains(string_only_in_Root)", te_IN_set.contains("string_only_in_Root"));
    assertTrue("te_IN.getKeys().contains(string_only_in_te)", te_IN_set.contains("string_only_in_te"));
    assertTrue("te_IN.getKeys().contains(string_only_in_te_IN)", te_IN_set.contains("string_only_in_te_IN"));
// TODO: Check for keys of alias resource items
}
Also used : ICUResourceBundle(android.icu.impl.ICUResourceBundle) UResourceBundle(android.icu.util.UResourceBundle) Test(org.junit.Test)

Aggregations

UResourceBundle (android.icu.util.UResourceBundle)46 ICUResourceBundle (android.icu.impl.ICUResourceBundle)26 MissingResourceException (java.util.MissingResourceException)24 Test (org.junit.Test)17 ULocale (android.icu.util.ULocale)8 UResourceBundleIterator (android.icu.util.UResourceBundleIterator)6 UResourceTypeMismatchException (android.icu.util.UResourceTypeMismatchException)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 LinkedHashMap (java.util.LinkedHashMap)3 LinkedHashSet (java.util.LinkedHashSet)3 SimpleTimeZone (android.icu.util.SimpleTimeZone)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 EnumSet (java.util.EnumSet)2 Locale (java.util.Locale)2 Map (java.util.Map)2 Set (java.util.Set)2 TreeMap (java.util.TreeMap)2 JavaTimeZone (android.icu.impl.JavaTimeZone)1