1/* GENERATED SOURCE. DO NOT MODIFY. */ 2/** 3 ******************************************************************************* 4 * Copyright (C) 2001-2015, International Business Machines Corporation and 5 * others. All Rights Reserved. 6 ******************************************************************************* 7 */ 8package android.icu.dev.test.util; 9 10import java.io.BufferedReader; 11import java.io.InputStreamReader; 12import java.net.JarURLConnection; 13import java.net.URL; 14import java.net.URLConnection; 15import java.nio.ByteBuffer; 16import java.util.Enumeration; 17import java.util.Locale; 18import java.util.MissingResourceException; 19import java.util.NoSuchElementException; 20import java.util.Set; 21import java.util.TreeSet; 22import java.util.jar.JarEntry; 23 24import android.icu.dev.test.TestFmwk; 25import android.icu.impl.ICUResourceBundle; 26import android.icu.impl.Utility; 27import android.icu.text.BreakIterator; 28import android.icu.text.UTF16; 29import android.icu.util.Calendar; 30import android.icu.util.Holiday; 31import android.icu.util.ULocale; 32import android.icu.util.UResourceBundle; 33import android.icu.util.UResourceBundleIterator; 34import android.icu.util.UResourceTypeMismatchException; 35import org.junit.runner.RunWith; 36import android.icu.junit.IcuTestFmwkRunner; 37 38@RunWith(IcuTestFmwkRunner.class) 39public final class ICUResourceBundleTest extends TestFmwk { 40 private static final ClassLoader testLoader = ICUResourceBundleTest.class.getClassLoader(); 41 42 public static void main(String args[]) throws Exception { 43 ICUResourceBundleTest test = new ICUResourceBundleTest(); 44 test.run(args); 45 } 46 public void TestGetResources(){ 47 try{ 48 // It does not work well in eclipse plug-in test because of class loader configuration?? 49 // For now, specify resource path explicitly in this test case 50 //Enumeration en = testLoader.getResources("META-INF"); 51 Enumeration en = testLoader.getResources("android.icu.dev.data"); 52 for(;en.hasMoreElements();) { 53 URL url = (URL)en.nextElement(); 54 if (url == null) { 55 warnln("could not load resource data"); 56 return; 57 } 58 URLConnection c = url.openConnection(); 59 60 if (c instanceof JarURLConnection) { 61 JarURLConnection jc = (JarURLConnection)c; 62 JarEntry je = jc.getJarEntry(); 63 logln("jar entry: " + je.toString()); 64 } else { 65 BufferedReader br = new BufferedReader( 66 new InputStreamReader(c.getInputStream())); 67 logln("input stream:"); 68 try { 69 String line = null; 70 int n = 0; 71 while ((line = br.readLine()) != null) { 72 logln(" " + ++n + ": " + line); 73 } 74 } finally { 75 br.close(); 76 } 77 } 78 } 79 }catch(SecurityException ex) { 80 warnln("could not load resource data: " + ex); 81 ex.printStackTrace(); 82 }catch(NullPointerException ex) { 83 // thrown by ibm 1.4.2 windows jvm security manager 84 warnln("could not load resource data: " + ex); 85 }catch(Exception ex){ 86 ex.printStackTrace(); 87 errln("Unexpected exception: "+ ex); 88 } 89 } 90 public void TestResourceBundleWrapper(){ 91 UResourceBundle bundle = UResourceBundle.getBundleInstance("android.icu.impl.data.HolidayBundle", "da_DK"); 92 Object o = bundle.getObject("holidays"); 93 if(o instanceof Holiday[] ){ 94 logln("wrapper mechanism works for Weekend data"); 95 }else{ 96 errln("Did not get the expected output for Weekend data"); 97 } 98 99 bundle = UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, "bogus"); 100 if(bundle instanceof UResourceBundle && bundle.getULocale().getName().equals("en_US")){ 101 logln("wrapper mechanism works for bogus locale"); 102 }else{ 103 errln("wrapper mechanism failed for bogus locale."); 104 } 105 106 try{ 107 bundle = UResourceBundle.getBundleInstance("bogus", "bogus"); 108 if(bundle!=null){ 109 errln("Did not get the expected exception"); 110 } 111 }catch(MissingResourceException ex){ 112 logln("got the expected exception"); 113 } 114 115 116 } 117 public void TestJB3879(){ 118 // this tests tests loading of root bundle when a resource bundle 119 // for the default locale is requested 120 try { 121 UResourceBundle bundle = (UResourceBundle) UResourceBundle.getBundleInstance("android/icu/dev/data/testdata", ULocale.getDefault(), testLoader); 122 if(bundle==null){ 123 errln("could not create the resource bundle"); 124 } 125 } 126 catch (MissingResourceException ex) { 127 warnln("could not load test data: " + ex.getMessage()); 128 } 129 } 130 public void TestOpen(){ 131 UResourceBundle bundle = (UResourceBundle) UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, "en_US_POSIX"); 132 133 if(bundle==null){ 134 errln("could not create the resource bundle"); 135 } 136 137 UResourceBundle obj = bundle.get("NumberElements").get("latn").get("patterns"); 138 139 int size = obj.getSize(); 140 int type = obj.getType(); 141 if(type == UResourceBundle.TABLE){ 142 UResourceBundle sub; 143 for(int i=0; i<size; i++) { 144 sub = obj.get(i); 145 String temp =sub.getString(); 146 if(temp.length()==0){ 147 errln("Failed to get the items from number patterns table in bundle: "+ 148 bundle.getULocale().getBaseName()); 149 } 150 //System.out.println("\""+prettify(temp)+"\""); 151 } 152 } 153 154 obj = bundle.get("NumberElements").get("latn").get("symbols"); 155 156 size = obj.getSize(); 157 type = obj.getType(); 158 if(type == UResourceBundle.TABLE){ 159 UResourceBundle sub; 160 for(int i=0; i<size; i++){ 161 sub = obj.get(i); 162 String temp =sub.getString(); 163 if(temp.length()==0){ 164 errln("Failed to get the items from number symbols table in bundle: "+ 165 bundle.getULocale().getBaseName()); 166 } 167 // System.out.println("\""+prettify(temp)+"\""); 168 } 169 } 170 171 if(bundle==null){ 172 errln("could not create the resource bundle"); 173 } 174 175 bundle = (UResourceBundle) UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, "zzz_ZZ_very_very_very_long_bogus_bundle"); 176 if(!bundle.getULocale().equals(ULocale.getDefault())){ 177 errln("UResourceBundle did not load the default bundle when bundle was not found. Default: " + ULocale.getDefault() + 178 ", Bundle locale: " + bundle.getULocale()); 179 } 180 } 181 182 public void TestBasicTypes(){ 183 UResourceBundle bundle = null; 184 try { 185 bundle = (UResourceBundle)UResourceBundle.getBundleInstance("android/icu/dev/data/testdata", "testtypes", testLoader); 186 } 187 catch (MissingResourceException e) { 188 warnln("could not load test data: " + e.getMessage()); 189 return; 190 } 191 { 192 String expected = "abc\u0000def"; 193 UResourceBundle sub = bundle.get("zerotest"); 194 if(!expected.equals(sub.getString())){ 195 errln("Did not get the expected string for key zerotest in bundle testtypes"); 196 } 197 sub = bundle.get("emptyexplicitstring"); 198 expected =""; 199 if(!expected.equals(sub.getString())){ 200 errln("Did not get the expected string for key emptyexplicitstring in bundle testtypes"); 201 } 202 sub = bundle.get("emptystring"); 203 expected =""; 204 if(!expected.equals(sub.getString())){ 205 errln("Did not get the expected string for key emptystring in bundle testtypes"); 206 } 207 } 208 { 209 int expected = 123; 210 UResourceBundle sub = bundle.get("onehundredtwentythree"); 211 if(expected!=sub.getInt()){ 212 errln("Did not get the expected int value for key onehundredtwentythree in bundle testtypes"); 213 } 214 sub = bundle.get("emptyint"); 215 expected=0; 216 if(expected!=sub.getInt()){ 217 errln("Did not get the expected int value for key emptyint in bundle testtypes"); 218 } 219 } 220 { 221 int expected = 1; 222 UResourceBundle sub = bundle.get("one"); 223 if(expected!=sub.getInt()){ 224 errln("Did not get the expected int value for key one in bundle testtypes"); 225 } 226 } 227 { 228 int expected = -1; 229 UResourceBundle sub = bundle.get("minusone"); 230 int got = sub.getInt(); 231 if(expected!=got){ 232 errln("Did not get the expected int value for key minusone in bundle testtypes"); 233 } 234 expected = 0xFFFFFFF; 235 got = sub.getUInt(); 236 if(expected!=got){ 237 errln("Did not get the expected int value for key minusone in bundle testtypes"); 238 } 239 } 240 { 241 int expected = 1; 242 UResourceBundle sub = bundle.get("plusone"); 243 if(expected!=sub.getInt()){ 244 errln("Did not get the expected int value for key minusone in bundle testtypes"); 245 } 246 247 } 248 { 249 int[] expected = new int[]{ 1, 2, 3, -3, 4, 5, 6, 7 } ; 250 UResourceBundle sub = bundle.get("integerarray"); 251 if(!Utility.arrayEquals(expected,sub.getIntVector())){ 252 errln("Did not get the expected int vector value for key integerarray in bundle testtypes"); 253 } 254 sub = bundle.get("emptyintv"); 255 expected = new int[0]; 256 if(!Utility.arrayEquals(expected,sub.getIntVector())){ 257 errln("Did not get the expected int vector value for key emptyintv in bundle testtypes"); 258 } 259 260 } 261 { 262 UResourceBundle sub = bundle.get("binarytest"); 263 ByteBuffer got = sub.getBinary(); 264 if(got.remaining()!=15){ 265 errln("Did not get the expected length for the binary ByteBuffer"); 266 } 267 for(int i=0; i< got.remaining(); i++){ 268 byte b = got.get(); 269 if(b!=i){ 270 errln("Did not get the expected value for binary buffer at index: "+i); 271 } 272 } 273 sub = bundle.get("emptybin"); 274 got = sub.getBinary(); 275 if(got.remaining()!=0){ 276 errln("Did not get the expected length for the emptybin ByteBuffer"); 277 } 278 279 } 280 { 281 UResourceBundle sub = bundle.get("emptyarray"); 282 String key = sub.getKey(); 283 if(!key.equals("emptyarray")){ 284 errln("Did not get the expected key for emptytable item"); 285 } 286 if(sub.getSize()!=0){ 287 errln("Did not get the expected length for emptytable item"); 288 } 289 } 290 { 291 UResourceBundle sub = bundle.get("menu"); 292 String key = sub.getKey(); 293 if(!key.equals("menu")){ 294 errln("Did not get the expected key for menu item"); 295 } 296 UResourceBundle sub1 = sub.get("file"); 297 key = sub1.getKey(); 298 if(!key.equals("file")){ 299 errln("Did not get the expected key for file item"); 300 } 301 UResourceBundle sub2 = sub1.get("open"); 302 key = sub2.getKey(); 303 if(!key.equals("open")){ 304 errln("Did not get the expected key for file item"); 305 } 306 String value = sub2.getString(); 307 if(!value.equals("Open")){ 308 errln("Did not get the expected value for key for oen item"); 309 } 310 311 sub = bundle.get("emptytable"); 312 key = sub.getKey(); 313 if(!key.equals("emptytable")){ 314 errln("Did not get the expected key for emptytable item"); 315 } 316 if(sub.getSize()!=0){ 317 errln("Did not get the expected length for emptytable item"); 318 } 319 sub = bundle.get("menu").get("file"); 320 int size = sub.getSize(); 321 String expected; 322 for(int i=0; i<size; i++){ 323 sub1 = sub.get(i); 324 325 switch(i){ 326 case 0: 327 expected = "exit"; 328 break; 329 case 1: 330 expected = "open"; 331 break; 332 case 2: 333 expected = "save"; 334 break; 335 default: 336 expected =""; 337 } 338 String got = sub1.getKey(); 339 if(!expected.equals(got)){ 340 errln("Did not get the expected key at index"+i+". Expected: "+expected+" Got: "+got); 341 }else{ 342 logln("Got the expected key at index: "+i); 343 } 344 } 345 } 346 347 } 348 private static final class TestCase{ 349 String key; 350 int value; 351 TestCase(String key, int value){ 352 this.key = key; 353 this.value = value; 354 } 355 } 356 public void TestTable32(){ 357 TestCase[] arr = new TestCase[]{ 358 new TestCase ( "ooooooooooooooooo", 0 ), 359 new TestCase ( "oooooooooooooooo1", 1 ), 360 new TestCase ( "ooooooooooooooo1o", 2 ), 361 new TestCase ( "oo11ooo1ooo11111o", 25150 ), 362 new TestCase ( "oo11ooo1ooo111111", 25151 ), 363 new TestCase ( "o1111111111111111", 65535 ), 364 new TestCase ( "1oooooooooooooooo", 65536 ), 365 new TestCase ( "1ooooooo11o11ooo1", 65969 ), 366 new TestCase ( "1ooooooo11o11oo1o", 65970 ), 367 new TestCase ( "1ooooooo111oo1111", 65999 ) 368 }; 369 UResourceBundle bundle = null; 370 try { 371 bundle = UResourceBundle.getBundleInstance("android/icu/dev/data/testdata","testtable32", testLoader); 372 } 373 catch (MissingResourceException ex) { 374 warnln("could not load resource data: " + ex.getMessage()); 375 return; 376 } 377 378 if(bundle.getType()!= UResourceBundle.TABLE){ 379 errln("Could not get the correct type for bundle testtable32"); 380 } 381 382 int size =bundle.getSize(); 383 if(size!=66000){ 384 errln("Could not get the correct size for bundle testtable32"); 385 } 386 387 int number = -1; 388 389 // get the items by index 390 for(int i =0; i<size; i++){ 391 UResourceBundle item = bundle.get(i); 392 String key = item.getKey(); 393 int parsedNumber = parseTable32Key(key); 394 switch(item.getType()){ 395 case UResourceBundle.STRING: 396 String value = item.getString(); 397 number = UTF16.charAt(value,0); 398 break; 399 case UResourceBundle.INT: 400 number = item.getInt(); 401 break; 402 default: 403 errln("Got unexpected resource type in testtable32"); 404 } 405 if(number!=parsedNumber){ 406 errln("Did not get expected value in testtypes32 for key"+ 407 key+". Expected: "+parsedNumber+" Got:"+number); 408 } 409 410 } 411 412 // search for some items by key 413 for(int i=0;i<arr.length; i++){ 414 UResourceBundle item = bundle.get(arr[i].key); 415 switch(item.getType()){ 416 case UResourceBundle.STRING: 417 String value = item.getString(); 418 number = UTF16.charAt(value,0); 419 break; 420 case UResourceBundle.INT: 421 number = item.getInt(); 422 break; 423 default: 424 errln("Got unexpected resource type in testtable32"); 425 } 426 427 if(number != arr[i].value){ 428 errln("Did not get expected value in testtypes32 for key" + 429 arr[i].key +". Expected: " + arr[i].value + " Got:" + number); 430 } 431 } 432 } 433 private static int parseTable32Key(String key) { 434 int number; 435 char c; 436 437 number=0; 438 for(int i=0; i<key.length(); i++){ 439 c = key.charAt(i); 440 number<<=1; 441 if(c=='1') { 442 number|=1; 443 } 444 } 445 return number; 446 } 447 448 public void TestAliases(){ 449 String simpleAlias = "Open"; 450 451 UResourceBundle rb = (UResourceBundle)UResourceBundle.getBundleInstance("android/icu/dev/data/testdata","testaliases", testLoader); 452 if (rb == null) { 453 warnln("could not load testaliases data"); 454 return; 455 } 456 UResourceBundle sub = rb.get("simplealias"); 457 String s1 = sub.getString("simplealias"); 458 if(s1.equals(simpleAlias)){ 459 logln("Alias mechanism works for simplealias"); 460 }else{ 461 errln("Did not get the expected output for simplealias"); 462 } 463 { 464 try{ 465 rb = (UResourceBundle)UResourceBundle.getBundleInstance("android/icu/dev/data/testdata","testaliases",testLoader); 466 sub = rb.get("nonexisting"); 467 errln("Did not get the expected exception for nonexisting"); 468 }catch(MissingResourceException ex){ 469 logln("Alias mechanism works for nonexisting alias"); 470 } 471 } 472 { 473 rb = (UResourceBundle)UResourceBundle.getBundleInstance("android/icu/dev/data/testdata","testaliases",testLoader); 474 sub = rb.get("referencingalias"); 475 s1 = sub.getString(); 476 if(s1.equals("H:mm:ss")){ 477 logln("Alias mechanism works for referencingalias"); 478 }else{ 479 errln("Did not get the expected output for referencingalias"); 480 } 481 } 482 { 483 UResourceBundle rb1 = (UResourceBundle)UResourceBundle.getBundleInstance("android/icu/dev/data/testdata","testaliases",testLoader); 484 if(rb1!=rb){ 485 errln("Caching of the resource bundle failed"); 486 }else{ 487 logln("Caching of resource bundle passed"); 488 } 489 sub = rb1.get("testGetStringByKeyAliasing" ); 490 491 s1 = sub.get("KeyAlias0PST").getString(); 492 if(s1.equals("America/Los_Angeles")){ 493 logln("Alias mechanism works for KeyAlias0PST"); 494 }else{ 495 errln("Did not get the expected output for KeyAlias0PST"); 496 } 497 498 s1 = sub.getString("KeyAlias1PacificStandardTime"); 499 if(s1.equals("Pacific Standard Time")){ 500 logln("Alias mechanism works for KeyAlias1PacificStandardTime"); 501 }else{ 502 errln("Did not get the expected output for KeyAlias1PacificStandardTime"); 503 } 504 s1 = sub.getString("KeyAlias2PDT"); 505 if(s1.equals("PDT")){ 506 logln("Alias mechanism works for KeyAlias2PDT"); 507 }else{ 508 errln("Did not get the expected output for KeyAlias2PDT"); 509 } 510 511 s1 = sub.getString("KeyAlias3LosAngeles"); 512 if(s1.equals("Los Angeles")){ 513 logln("Alias mechanism works for KeyAlias3LosAngeles. Got: "+s1); 514 }else{ 515 errln("Did not get the expected output for KeyAlias3LosAngeles. Got: "+s1); 516 } 517 } 518 { 519 sub = rb.get("testGetStringByIndexAliasing" ); 520 s1 = sub.getString(0); 521 if(s1.equals("America/Los_Angeles")){ 522 logln("Alias mechanism works for testGetStringByIndexAliasing/0. Got: "+s1); 523 }else{ 524 errln("Did not get the expected output for testGetStringByIndexAliasing/0. Got: "+s1); 525 } 526 s1 = sub.getString(1); 527 if(s1.equals("Pacific Standard Time")){ 528 logln("Alias mechanism works for testGetStringByIndexAliasing/1"); 529 }else{ 530 errln("Did not get the expected output for testGetStringByIndexAliasing/1"); 531 } 532 s1 = sub.getString(2); 533 if(s1.equals("PDT")){ 534 logln("Alias mechanism works for testGetStringByIndexAliasing/2"); 535 }else{ 536 errln("Did not get the expected output for testGetStringByIndexAliasing/2"); 537 } 538 539 s1 = sub.getString(3); 540 if(s1.equals("Los Angeles")){ 541 logln("Alias mechanism works for testGetStringByIndexAliasing/3. Got: "+s1); 542 }else{ 543 errln("Did not get the expected output for testGetStringByIndexAliasing/3. Got: "+s1); 544 } 545 } 546 547// Note: Following test cases are no longer working because collation data is now in the collation module 548// { 549// sub = rb.get("testAliasToTree" ); 550// 551// ByteBuffer buf = sub.get("standard").get("%%CollationBin").getBinary(); 552// if(buf==null){ 553// errln("Did not get the expected output for %%CollationBin"); 554// } 555// } 556// 557// rb = (UResourceBundle) UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_COLLATION_BASE_NAME,"zh_TW"); 558// UResourceBundle b = (UResourceBundle) rb.getObject("collations"); 559// if(b != null){ 560// if(b.get(0).getKey().equals( "default")){ 561// logln("Alias mechanism works"); 562// }else{ 563// errln("Alias mechanism failed for zh_TW collations"); 564// } 565// }else{ 566// errln("Did not get the expected object for collations"); 567// } 568 569 // Test case for #7996 570 { 571 UResourceBundle bundle = UResourceBundle.getBundleInstance("android/icu/dev/data/testdata", "te", testLoader); 572 UResourceBundle table = bundle.get("tableT7996"); 573 try { 574 String s = table.getString("a7996"); 575 logln("Alias in nested table referring one in sh worked - " + s); 576 } catch (MissingResourceException e) { 577 errln("Alias in nested table referring one in sh failed"); 578 } 579 580 try { 581 String s = ((ICUResourceBundle)table).getStringWithFallback("b7996"); 582 logln("Alias with /LOCALE/ in nested table in root referring back to another key in the current locale bundle worked - " + s); 583 } catch (MissingResourceException e) { 584 errln("Alias with /LOCALE/ in nested table in root referring back to another key in the current locale bundle failed"); 585 } 586 } 587 588 } 589 public void TestAlias(){ 590 logln("Testing %%ALIAS"); 591 UResourceBundle rb = (UResourceBundle) UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME,"iw_IL"); 592 UResourceBundle b = rb.get("NumberElements"); 593 if(b != null){ 594 if(b.getSize()>0){ 595 logln("%%ALIAS mechanism works"); 596 }else{ 597 errln("%%ALIAS mechanism failed for iw_IL NumberElements"); 598 } 599 }else{ 600 errln("%%ALIAS mechanism failed for iw_IL"); 601 } 602 } 603 public void TestXPathAlias(){ 604 UResourceBundle rb = (UResourceBundle) UResourceBundle.getBundleInstance("android/icu/dev/data/testdata","te_IN",testLoader); 605 UResourceBundle b = rb.get("aliasClient"); 606 String result = b.getString(); 607 String expResult= "correct"; 608 609 if(!result.equals(expResult)){ 610 errln("Did not get the expected result for XPath style alias"); 611 } 612 try{ 613 UResourceBundle c = rb.get("rootAliasClient"); 614 result = c.getString(); 615 expResult = "correct"; 616 if(!result.equals(expResult)){ 617 errln("Did not get the expected result for XPath style alias for rootAliasClient"); 618 } 619 }catch( MissingResourceException ex){ 620 errln("Could not get rootAliasClient"); 621 } 622 } 623 public void TestCircularAliases(){ 624 try{ 625 UResourceBundle rb = (UResourceBundle)UResourceBundle.getBundleInstance("android/icu/dev/data/testdata","testaliases",testLoader); 626 UResourceBundle sub = rb.get("aaa"); 627 String s1 = sub.getString(); 628 if(s1!=null){ 629 errln("Did not get the expected exception"); 630 } 631 }catch(IllegalArgumentException ex){ 632 logln("got expected exception for circular references"); 633 } 634 catch (MissingResourceException ex) { 635 warnln("could not load resource data: " + ex.getMessage()); 636 } 637 } 638 639 public void TestPreventFallback() { 640 String noFallbackResource = "string_in_te_no_te_IN_fallback"; 641 ICUResourceBundle rb = (ICUResourceBundle) UResourceBundle.getBundleInstance("android/icu/dev/data/testdata","te_IN_NE",testLoader); 642 try { 643 rb.getStringWithFallback(noFallbackResource); 644 fail("Expected MissingResourceException."); 645 } catch (MissingResourceException e) { 646 // Expected 647 } 648 rb.getStringWithFallback("string_only_in_te"); 649 rb = (ICUResourceBundle) UResourceBundle.getBundleInstance("android/icu/dev/data/testdata","te",testLoader); 650 rb.getStringWithFallback(noFallbackResource); 651 } 652 653 public void TestGetWithFallback(){ 654 /* 655 UResourceBundle bundle =(UResourceBundle) UResourceBundle.getBundleInstance("com/ibm/icu/dev/data/testdata","te_IN"); 656 String key = bundle.getStringWithFallback("Keys/collation"); 657 if(!key.equals("COLLATION")){ 658 errln("Did not get the expected result from getStringWithFallback method."); 659 } 660 String type = bundle.getStringWithFallback("Types/collation/direct"); 661 if(!type.equals("DIRECT")){ 662 errln("Did not get the expected result form getStringWithFallback method."); 663 } 664 */ 665 ICUResourceBundle bundle = null; 666 667 bundle = (ICUResourceBundle) UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME,"fr_FR"); 668 ICUResourceBundle b1 = bundle.getWithFallback("calendar"); 669 String defaultCal = b1.getStringWithFallback("default"); 670 if(!defaultCal.equals("gregorian")){ 671 errln("Did not get the expected default calendar string: Expected: gregorian, Got: "+defaultCal); 672 } 673 ICUResourceBundle b2 = b1.getWithFallback(defaultCal); 674 ICUResourceBundle b3 = b2.getWithFallback("monthNames"); 675 ICUResourceBundle b4 = b3.getWithFallback("format"); 676 ICUResourceBundle b5 = b4.getWithFallback("narrow"); 677 if(b5.getSize()!=12){ 678 errln("Did not get the expected size for the monthNames"); 679 } 680 } 681 682 private static final String CALENDAR_RESNAME = "calendar"; 683 private static final String CALENDAR_KEYWORD = "calendar"; 684 685 public void TestLocaleDisplayNames() { 686 ULocale[] locales = ULocale.getAvailableLocales(); 687 for (int i = 0; i < locales.length; ++i) { 688 if (!hasLocalizedCountryFor(ULocale.ENGLISH, locales[i]) && (locales[i].getLanguage().compareTo("ti") != 0)){ // TODO: restore test for ti_* when cldrbug 3058 is fixed 689 errln("Could not get English localized country for " + locales[i]); 690 } 691 if(!hasLocalizedLanguageFor(ULocale.ENGLISH, locales[i])){ 692 errln("Could not get English localized language for " + locales[i]); 693 } 694 if(!hasLocalizedCountryFor(locales[i], locales[i]) && 695 !(locales[i].getLanguage().equals("ti") || // TODO: restore test for ti_* when cldrbug 3058 is fixed 696 ((locales[i].getBaseName().equals("lrc_IQ") || locales[i].getBaseName().equals("lrc_IR") || locales[i].getBaseName().equals("nus_SS")) && logKnownIssue("cldrbug:8903", "No localized region name for lrc_IQ, lrc_IR, nus_SS")))) { 697 errln("Could not get native localized country for " + locales[i]); 698 hasLocalizedCountryFor(locales[i], locales[i]); 699 } 700 if(!hasLocalizedLanguageFor(locales[i], locales[i]) && (locales[i].getLanguage().compareTo("nmg") != 0)){ 701 errln("Could not get native localized language for " + locales[i]); 702 } 703 704 logln(locales[i] + "\t" + locales[i].getDisplayName(ULocale.ENGLISH) + "\t" + locales[i].getDisplayName(locales[i])); 705 } 706 } 707 708 private static boolean hasLocalizedLanguageFor(ULocale locale, ULocale otherLocale) { 709 String lang = otherLocale.getLanguage(); 710 String localizedVersion = otherLocale.getDisplayLanguage(locale); 711 return !lang.equals(localizedVersion); 712 } 713 714 private static boolean hasLocalizedCountryFor(ULocale locale, ULocale otherLocale) { 715 String country = otherLocale.getCountry(); 716 if (country.equals("")) return true; 717 String localizedVersion = otherLocale.getDisplayCountry(locale); 718 return !country.equals(localizedVersion); 719 } 720 721 public void TestFunctionalEquivalent(){ 722 // Android patch: Force default Gregorian calendar. 723 String[] calCases = { 724 // avail locale equiv 725 "t", "en_US_POSIX", "en@calendar=gregorian", 726 "f", "ja_JP_TOKYO", "ja@calendar=gregorian", 727 "f", "ja_JP_TOKYO@calendar=japanese", "ja@calendar=japanese", 728 "t", "sr@calendar=gregorian", "sr@calendar=gregorian", 729 "t", "en", "en@calendar=gregorian", 730 "t", "th_TH", "th@calendar=gregorian", 731 "t", "th_TH@calendar=gregorian", "th@calendar=gregorian", 732 "f", "th_TH_Bangkok", "th@calendar=gregorian", 733 }; 734 // Android patch end. 735 736 logln("Testing functional equivalents for calendar..."); 737 getFunctionalEquivalentTestCases(ICUResourceBundle.ICU_BASE_NAME, 738 Calendar.class.getClassLoader(), 739 CALENDAR_RESNAME, CALENDAR_KEYWORD, false, calCases); 740 741 logln("Testing error conditions:"); 742 try { 743 ClassLoader cl = BreakIterator.class.getClassLoader(); 744 ICUResourceBundle.getFunctionalEquivalent(ICUResourceBundle.ICU_BRKITR_BASE_NAME, cl, "calendar", 745 "calendar", new ULocale("ar_EG@calendar=islamic"), new boolean[1], true); 746 errln("Err: expected MissingResourceException"); 747 } catch ( MissingResourceException t ) { 748 logln("expected MissingResourceException caught (PASS): " + t.toString()); 749 } 750 } 751 752 private void getFunctionalEquivalentTestCases(String path, ClassLoader cl, String resName, String keyword, 753 boolean truncate, String[] testCases) { 754 //String F_STR = "f"; 755 String T_STR = "t"; 756 boolean isAvail[] = new boolean[1]; 757 758 logln("Testing functional equivalents..."); 759 for(int i = 0; i < testCases.length ;i+=3) { 760 boolean expectAvail = T_STR.equals(testCases[i+0]); 761 ULocale inLocale = new ULocale(testCases[i+1]); 762 ULocale expectLocale = new ULocale(testCases[i+2]); 763 764 logln(new Integer(i/3).toString() + ": " + new Boolean(expectAvail).toString() + "\t\t" + 765 inLocale.toString() + "\t\t" + expectLocale.toString()); 766 767 ULocale equivLocale = ICUResourceBundle.getFunctionalEquivalent(path, cl, resName, keyword, inLocale, isAvail, truncate); 768 boolean gotAvail = isAvail[0]; 769 770 if((gotAvail != expectAvail) || !equivLocale.equals(expectLocale)) { 771 errln(new Integer(i/3).toString() + ": Error, expected Equiv=" + new Boolean(expectAvail).toString() + "\t\t" + 772 inLocale.toString() + "\t\t--> " + expectLocale.toString() + ", but got " + new Boolean(gotAvail).toString() + " " + 773 equivLocale.toString()); 774 } 775 } 776 } 777 778 public void TestNorwegian(){ 779 try{ 780 UResourceBundle rb = UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_REGION_BASE_NAME, "no_NO_NY"); 781 UResourceBundle sub = rb.get("Countries"); 782 String s1 = sub.getString("NO"); 783 if(s1.equals("Noreg")){ 784 logln("got expected output "); 785 }else{ 786 errln("did not get the expected result"); 787 } 788 }catch(IllegalArgumentException ex){ 789 errln("Caught an unexpected expected"); 790 } 791 } 792 public void TestJB4102(){ 793 try { 794 ICUResourceBundle root =(ICUResourceBundle) UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, "root"); 795 ICUResourceBundle t = null; 796// AmPmMarkers now exist in root/islamic calendar, so this test is rendered useless. 797// try{ 798// t = root.getWithFallback("calendar/islamic-civil/AmPmMarkers"); 799// errln("Second resource does not exist. How did it get here?\n"); 800// }catch(MissingResourceException ex){ 801// logln("Got the expected exception"); 802// } 803 try{ 804 t = root.getWithFallback("calendar/islamic-civil/eras/abbreviated/0/mikimaus/pera"); 805 errln("Second resource does not exist. How did it get here?\n"); 806 }catch(MissingResourceException ex){ 807 logln("Got the expected exception"); 808 } 809 if(t!=null){ 810 errln("t is not null!"); 811 } 812 } catch (MissingResourceException e) { 813 warnln("Could not load the locale data: " + e.getMessage()); 814 } 815 } 816 817 public void TestCLDRStyleAliases() { 818 String result = null; 819 String expected = null; 820 String[]expects = new String[] { "", "a41", "a12", "a03", "ar4" }; 821 822 logln("Testing CLDR style aliases......\n"); 823 824 UResourceBundle rb = UResourceBundle.getBundleInstance("android/icu/dev/data/testdata", "te_IN_REVISED", testLoader); 825 ICUResourceBundle alias = (ICUResourceBundle)rb.get("a"); 826 827 for(int i = 1; i < 5 ; i++) { 828 String resource="a"+i; 829 UResourceBundle a = (alias).getWithFallback(resource); 830 result = a.getString(); 831 if(result.equals(expected)) { 832 errln("CLDR style aliases failed resource with name "+resource+"resource, exp "+expects[i] +" , got " + result); 833 } 834 } 835 836 } 837 private String getLSString(int status){ 838 switch(status){ 839 case ICUResourceBundle.FROM_FALLBACK: 840 return "FROM_FALLBACK"; 841 case ICUResourceBundle.FROM_DEFAULT: 842 return "FROM_DEFAULT"; 843 case ICUResourceBundle.FROM_ROOT: 844 return "FROM_ROOT"; 845 case ICUResourceBundle.FROM_LOCALE: 846 return "FROM_LOCALE"; 847 default: 848 return "UNKNOWN"; 849 } 850 } 851 852 private void assertEqualLoadingStatus(String msg, int target, int result) { 853 if (result != target) { 854 errln(msg + " expected: "+ getLSString(target) 855 + " got: " + getLSString(result)); 856 } 857 } 858 859 @SuppressWarnings("unused") 860 private void assertDefaultLoadingStatus(String msg, int result) { 861 assertEqualLoadingStatus(msg, ICUResourceBundle.FROM_DEFAULT, result); 862 } 863 864 private void assertFallbackLoadingStatus(String msg, int result) { 865 assertEqualLoadingStatus(msg, ICUResourceBundle.FROM_FALLBACK, result); 866 } 867 868 private void assertRootLoadingStatus(String msg, int result) { 869 assertEqualLoadingStatus(msg, ICUResourceBundle.FROM_ROOT, result); 870 } 871 872 private void assertLocaleLoadingStatus(String msg, int result) { 873 assertEqualLoadingStatus(msg, ICUResourceBundle.FROM_LOCALE, result); 874 } 875 876 public void TestLoadingStatus(){ 877 ICUResourceBundle bundle = (ICUResourceBundle) UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, "yi_IL"); 878 assertFallbackLoadingStatus("base/yi_IL", bundle.getLoadingStatus()); 879 880 bundle = (ICUResourceBundle) UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, "eo_DE"); 881 assertFallbackLoadingStatus("base/eo_DE", bundle.getLoadingStatus()); 882 883 logln("Test to verify loading status of get(String)"); 884 bundle = (ICUResourceBundle) UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_LANG_BASE_NAME, "zh_Hant_TW"); 885 ICUResourceBundle countries = (ICUResourceBundle) bundle.get("Languages"); 886 assertFallbackLoadingStatus("lang/Languages/zh_Hant_TW", countries.getLoadingStatus()); 887 888 /* 889 UResourceBundle auxExemplar = bundle.get("AuxExemplarCharacters"); 890 status = auxExemplar.getLoadingStatus(); 891 if(status != UResourceBundle.FROM_ROOT){ 892 errln("Did not get the expected value for loading status. Expected "+ getLSString(UResourceBundle.FROM_ROOT) 893 + " Got: " + getLSString(status)); 894 } 895 */ 896 897 logln("Test to verify root loading status of get()"); 898 bundle = (ICUResourceBundle)UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, "te_IN"); 899 ICUResourceBundle ms = (ICUResourceBundle) bundle.get("layout"); 900 assertRootLoadingStatus("base/layout/te_IN", ms.getLoadingStatus()); 901 902 logln("Test to verify loading status of getwithFallback"); 903 bundle = (ICUResourceBundle) UResourceBundle.getBundleInstance("android/icu/dev/data/testdata", "sh_YU", testLoader); 904 ICUResourceBundle temp = (ICUResourceBundle) bundle.getWithFallback("a/a2"); 905 assertLocaleLoadingStatus("testdata/a/a2/sh_YU", temp.getLoadingStatus()); 906 907 temp = bundle.getWithFallback("a/a1"); 908 assertFallbackLoadingStatus("testdata/a/a1/sh_YU", temp.getLoadingStatus()); 909 910 temp = bundle.getWithFallback("a/a4"); 911 assertRootLoadingStatus("testdata/a/a4/sh_YU", temp.getLoadingStatus()); 912 } 913 914 public void TestCoverage(){ 915 UResourceBundle bundle; 916 bundle = UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME); 917 if (bundle == null){ 918 errln("UResourceBundle.getBundleInstance(String baseName) failed"); 919 } 920 bundle = null; 921 bundle = UResourceBundle.getBundleInstance(ULocale.getDefault()); 922 if (bundle == null){ 923 errln("UResourceBundle.getBundleInstance(ULocale) failed"); 924 return; 925 } 926 if (new UResourceTypeMismatchException("coverage") == null){ 927 errln("Create UResourceTypeMismatchException error"); 928 } 929 class Stub extends UResourceBundle{ 930 public ULocale getULocale() {return ULocale.ROOT;} 931 protected String getLocaleID() {return null;} 932 protected String getBaseName() {return null;} 933 protected UResourceBundle getParent() {return null;} 934 protected void setLoadingStatus(int newStatus) {} 935 public Enumeration getKeys() {return null;} 936 protected Object handleGetObject(String aKey) {return null;} 937 } 938 Stub stub = new Stub(); 939 940 if (!stub.getLocale().equals(ULocale.ROOT.toLocale())){ 941 errln("UResourceBundle.getLoclae(Locale) should delegate to (ULocale)"); 942 } 943 } 944 public void TestJavaULocaleBundleLoading(){ 945 String baseName="android.icu.dev.data.resources.TestDataElements"; 946 String locName = "en_Latn_US"; 947 UResourceBundle bundle = UResourceBundle.getBundleInstance(baseName, locName, testLoader); 948 String fromRoot = bundle.getString("from_root"); 949 if(!fromRoot.equals("This data comes from root")){ 950 errln("Did not get the expected string for from_root"); 951 } 952 String fromEn = bundle.getString("from_en"); 953 if(!fromEn.equals("This data comes from en")){ 954 errln("Did not get the expected string for from_en"); 955 } 956 String fromEnLatn = bundle.getString("from_en_Latn"); 957 if(!fromEnLatn.equals("This data comes from en_Latn")){ 958 errln("Did not get the expected string for from_en_Latn"); 959 } 960 String fromEnLatnUs = bundle.getString("from_en_Latn_US"); 961 if(!fromEnLatnUs.equals("This data comes from en_Latn_US")){ 962 errln("Did not get the expected string for from_en_Latn_US"); 963 } 964 UResourceBundle bundle1 = UResourceBundle.getBundleInstance(baseName, new ULocale(locName), testLoader); 965 if(!bundle1.equals(bundle)){ 966 errln("Did not get the expected bundle for "+baseName +"."+locName); 967 } 968 if(bundle1!=bundle){ 969 errln("Did not load the bundle from cache"); 970 } 971 972 UResourceBundle bundle2 = UResourceBundle.getBundleInstance(baseName, "en_IN", testLoader); 973 if(!bundle2.getLocale().toString().equals("en")){ 974 errln("Did not get the expected fallback locale. Expected: en Got: "+bundle2.getLocale().toString()); 975 } 976 UResourceBundle bundle3 = UResourceBundle.getBundleInstance(baseName, "te_IN", testLoader); 977 if(!bundle3.getLocale().toString().equals("te")){ 978 errln("Did not get the expected fallback locale. Expected: te Got: "+bundle2.getLocale().toString()); 979 } 980 // non-existent bundle .. should return default 981 UResourceBundle defaultBundle = UResourceBundle.getBundleInstance(baseName, "hi_IN", testLoader); 982 ULocale defaultLocale = ULocale.getDefault(); 983 if(!defaultBundle.getULocale().equals(defaultLocale)){ 984 errln("Did not get the default bundle for non-existent bundle"); 985 } 986 // non-existent bundle, non-existent default locale 987 // so return the root bundle. 988 ULocale.setDefault(ULocale.CANADA_FRENCH); 989 UResourceBundle root = UResourceBundle.getBundleInstance(baseName, "hi_IN", testLoader); 990 if(!root.getULocale().toString().equals("")){ 991 errln("Did not get the root bundle for non-existent default bundle for non-existent bundle"); 992 } 993 //reset the default 994 ULocale.setDefault(defaultLocale); 995 Enumeration keys = bundle.getKeys(); 996 int i=0; 997 while(keys.hasMoreElements()){ 998 logln("key: "+ keys.nextElement()); 999 i++; 1000 } 1001 if(i!=4){ 1002 errln("Did not get the expected number of keys: got " + i + ", expected 4"); 1003 } 1004 UResourceBundle bundle4 = UResourceBundle.getBundleInstance(baseName, "fr_Latn_FR", testLoader); 1005 if(bundle4==null){ 1006 errln("Could not load bundle fr_Latn_FR"); 1007 } 1008 } 1009 public void TestAliasFallback(){ 1010 try{ 1011 ULocale loc = new ULocale("en_US"); 1012 ICUResourceBundle b = (ICUResourceBundle)UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, loc); 1013 ICUResourceBundle b1 = (ICUResourceBundle)b.getWithFallback("calendar/hebrew/monthNames/format/abbreviated"); 1014 if(b1!=null){ 1015 logln("loaded data for abbreviated month names: "+ b1.getKey()); 1016 } 1017 }catch(MissingResourceException ex){ 1018 warnln("Failed to load data for abbreviated month names"); 1019 } 1020 } 1021 private Set<String> setFromEnumeration(Enumeration<String> e) { 1022 TreeSet<String> set = new TreeSet<String>(); 1023 while (e.hasMoreElements()) { 1024 set.add(e.nextElement()); 1025 } 1026 return set; 1027 } 1028 /** 1029 * Test ICUResourceBundle.getKeys() for a whole bundle (top-level resource). 1030 * JDK JavaDoc for ResourceBundle.getKeys() says that it returns 1031 * "an Enumeration of the keys contained in this ResourceBundle and its parent bundles." 1032 */ 1033 public void TestICUGetKeysAtTopLevel() { 1034 String baseName="android/icu/dev/data/testdata"; 1035 UResourceBundle te_IN = UResourceBundle.getBundleInstance(baseName, "te_IN", testLoader); 1036 UResourceBundle te = UResourceBundle.getBundleInstance(baseName, "te", testLoader); 1037 Set<String> te_set = setFromEnumeration(te.getKeys()); 1038 Set<String> te_IN_set = setFromEnumeration(te_IN.getKeys()); 1039 assertTrue("te.getKeys().contains(string_only_in_Root)", te_set.contains("string_only_in_Root")); 1040 assertTrue("te.getKeys().contains(string_only_in_te)", te_set.contains("string_only_in_te")); 1041 assertFalse("te.getKeys().contains(string_only_in_te_IN)", te_set.contains("string_only_in_te_IN")); 1042 assertTrue("te_IN.getKeys().contains(string_only_in_Root)", te_IN_set.contains("string_only_in_Root")); 1043 assertTrue("te_IN.getKeys().contains(string_only_in_te)", te_IN_set.contains("string_only_in_te")); 1044 assertTrue("te_IN.getKeys().contains(string_only_in_te_IN)", te_IN_set.contains("string_only_in_te_IN")); 1045 // TODO: Check for keys of alias resource items 1046 } 1047 /** 1048 * Test ICUResourceBundle.getKeys() for a resource item (not a whole bundle/top-level resource). 1049 * This does not take parent bundles into account. 1050 */ 1051 public void TestICUGetKeysForResourceItem() { 1052 String baseName="android/icu/dev/data/testdata"; 1053 UResourceBundle te = UResourceBundle.getBundleInstance(baseName, "te", testLoader); 1054 UResourceBundle tagged_array_in_Root_te = te.get("tagged_array_in_Root_te"); 1055 Set<String> keys = setFromEnumeration(tagged_array_in_Root_te.getKeys()); 1056 assertTrue("tagged_array_in_Root_te.getKeys().contains(tag0)", keys.contains("tag0")); 1057 assertTrue("tagged_array_in_Root_te.getKeys().contains(tag1)", keys.contains("tag1")); 1058 assertFalse("tagged_array_in_Root_te.getKeys().contains(tag7)", keys.contains("tag7")); 1059 assertFalse("tagged_array_in_Root_te.getKeys().contains(tag12)", keys.contains("tag12")); 1060 UResourceBundle array_in_Root_te = te.get("array_in_Root_te"); 1061 assertFalse("array_in_Root_te.getKeys().hasMoreElements()", array_in_Root_te.getKeys().hasMoreElements()); 1062 UResourceBundle string_in_Root_te = te.get("string_in_Root_te"); 1063 assertFalse("string_in_Root_te.getKeys().hasMoreElements()", string_in_Root_te.getKeys().hasMoreElements()); 1064 } 1065 1066 /* 1067 * UResouceBundle should be able to load a resource bundle even if 1068 * a similarly named class (only case differences) exists in the 1069 * same package. See Ticket#6844 1070 */ 1071 public void TestT6844() { 1072 try { 1073 UResourceBundle rb1 1074 = UResourceBundle.getBundleInstance("android.icu.dev.data.resources.TestMessages", ULocale.getDefault(), testLoader); 1075 assertEquals("bundleContainer in TestMessages", "TestMessages.class", rb1.getString("bundleContainer")); 1076 1077 UResourceBundle rb2 1078 = UResourceBundle.getBundleInstance("android.icu.dev.data.resources.testmessages", ULocale.getDefault(), testLoader); 1079 assertEquals("bundleContainer in testmessages", "testmessages.properties", rb2.getString("bundleContainer")); 1080 } catch (Throwable t) { 1081 errln(t.getMessage()); 1082 } 1083 } 1084 1085 public void TestUResourceBundleCoverage() { 1086 Locale locale = null; 1087 ULocale ulocale = null; 1088 String baseName = null; 1089 UResourceBundle rb1, rb2, rb3, rb4, rb5, rb6, rb7; 1090 1091 rb1 = UResourceBundle.getBundleInstance(ulocale); 1092 rb2 = UResourceBundle.getBundleInstance(baseName); 1093 rb3 = UResourceBundle.getBundleInstance(baseName, ulocale); 1094 rb4 = UResourceBundle.getBundleInstance(baseName, locale); 1095 1096 rb5 = UResourceBundle.getBundleInstance(baseName, ulocale, testLoader); 1097 rb6 = UResourceBundle.getBundleInstance(baseName, locale, testLoader); 1098 try { 1099 rb7 = UResourceBundle.getBundleInstance("bogus", Locale.getDefault(), testLoader); 1100 errln("Should have thrown exception with bogus baseName."); 1101 } catch (java.util.MissingResourceException ex) { 1102 } 1103 if (rb1 == null || rb2 == null || rb3 == null || rb4 == null || rb5 == null || rb6 == null) { 1104 errln("Error getting resource bundle."); 1105 } 1106 1107 rb7 = UResourceBundle.getBundleInstance("android.icu.dev.data.resources.TestDataElements", Locale.getDefault(), testLoader); 1108 1109 UResourceBundle.resetBundleCache(); 1110 1111 try { 1112 rb1.getBinary(); 1113 errln("getBinary() call should have thrown UResourceTypeMismatchException."); 1114 } catch (UResourceTypeMismatchException ex) { 1115 } 1116 try { 1117 rb1.getStringArray(); 1118 errln("getStringArray() call should have thrown UResourceTypeMismatchException."); 1119 } catch (UResourceTypeMismatchException ex) { 1120 } 1121 try { 1122 byte [] ba = { 0x00 }; 1123 rb1.getBinary(ba); 1124 errln("getBinary(byte[]) call should have thrown UResourceTypeMismatchException."); 1125 } catch (UResourceTypeMismatchException ex) { 1126 } 1127 try { 1128 rb1.getInt(); 1129 errln("getInt() call should have thrown UResourceTypeMismatchException."); 1130 } catch (UResourceTypeMismatchException ex) { 1131 } 1132 try { 1133 rb1.getIntVector(); 1134 errln("getIntVector() call should have thrown UResourceTypeMismatchException."); 1135 } catch (UResourceTypeMismatchException ex) { 1136 } 1137 try { 1138 rb1.getUInt(); 1139 errln("getUInt() call should have thrown UResourceTypeMismatchException."); 1140 } catch (UResourceTypeMismatchException ex) { 1141 } 1142 if (rb1.getVersion() != null) { 1143 errln("getVersion() call should have returned null."); 1144 } 1145 if (rb7.getType() != UResourceBundle.NONE) { 1146 errln("getType() call should have returned NONE."); 1147 } 1148 if (rb7.getKey() != null) { 1149 errln("getKey() call should have returned null."); 1150 } 1151 if (((ICUResourceBundle)rb1).findTopLevel(0) == null) { 1152 errln("Error calling findTopLevel()."); 1153 } 1154 if (ICUResourceBundle.getFullLocaleNameSet() == null) { 1155 errln("Error calling getFullLocaleNameSet()."); 1156 } 1157 UResourceBundleIterator itr = rb1.getIterator(); 1158 while (itr.hasNext()) { 1159 itr.next(); 1160 } 1161 try { 1162 itr.next(); 1163 errln("NoSuchElementException exception should have been thrown."); 1164 } catch (NoSuchElementException ex) { 1165 } 1166 try { 1167 itr.nextString(); 1168 errln("NoSuchElementException exception should have been thrown."); 1169 } catch (NoSuchElementException ex) { 1170 } 1171 } 1172} 1173