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