Source Code Cross Referenced for ULocaleTest.java in  » Internationalization-Localization » icu4j » com » ibm » icu » tests » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Internationalization Localization » icu4j » com.ibm.icu.tests 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *******************************************************************************
003:         * Copyright (C) 2006, International Business Machines Corporation and         *
004:         * others. All Rights Reserved.                                                *
005:         *******************************************************************************
006:         */
007:
008:        package com.ibm.icu.tests;
009:
010:        import java.util.Iterator;
011:        import java.util.Locale;
012:
013:        import com.ibm.icu.util.ULocale;
014:
015:        public class ULocaleTest extends ICUTestCase {
016:            private String sampleName;
017:            private String longULocaleName;
018:            private String longULocaleBasename;
019:            private String nonNormalizedName;
020:            private ULocale longULocale;
021:            private Locale sampleLocale;
022:
023:            /**
024:             * @Override
025:             */
026:            protected void setUp() throws Exception {
027:                super .setUp();
028:
029:                sampleName = "ll_CC_VVVV";
030:                longULocaleName = "ll_Ssss_CC_VVVV@collation=phonebook;key=value";
031:                longULocaleBasename = longULocaleName.substring(0,
032:                        longULocaleName.indexOf('@'));
033:                nonNormalizedName = "LL_ssss_cc_VVVV@ Key = value ; Collation = phonebook ; ";
034:                longULocale = new ULocale(longULocaleName);
035:                sampleLocale = new ULocale(sampleName).toLocale();
036:            }
037:
038:            /*
039:             * Test method for 'com.ibm.icu.x.util.ULocale.hashCode()'
040:             */
041:            public void testHashCode() {
042:                ULocale obj = ULocale.GERMANY;
043:                ULocale eq = new ULocale("de_DE");
044:                ULocale neq = new ULocale("de_DE_FRENCH");
045:
046:                ICUTestCase.testEHCS(obj, eq, neq);
047:            }
048:
049:            /*
050:             * Test method for 'com.ibm.icu.x.util.ULocale.forLocale(Locale)'
051:             */
052:            public void testForLocale() {
053:                assertEquals(ULocale.GERMANY, ULocale.forLocale(Locale.GERMANY));
054:            }
055:
056:            /*
057:             * Test method for 'com.ibm.icu.x.util.ULocale.ULocale(String)'
058:             */
059:            public void testULocaleString() {
060:                assertEquals(ULocale.GERMAN, new ULocale("de"));
061:            }
062:
063:            /*
064:             * Test method for 'com.ibm.icu.x.util.ULocale.ULocale(String, String)'
065:             */
066:            public void testULocaleStringString() {
067:                assertEquals(ULocale.GERMANY, new ULocale("de", "DE"));
068:            }
069:
070:            /*
071:             * Test method for 'com.ibm.icu.x.util.ULocale.ULocale(String, String, String)'
072:             */
073:            public void testULocaleStringStringString() {
074:                assertEquals(sampleLocale, new ULocale("ll", "cc", "VVVV")
075:                        .toLocale());
076:            }
077:
078:            /*
079:             * Test method for 'com.ibm.icu.x.util.ULocale.createCanonical(String)'
080:             */
081:            public void testCreateCanonical() {
082:                ULocale result = ULocale.createCanonical("de__PHONEBOOK");
083:                assertEquals(new ULocale("de@collation=phonebook"), result);
084:            }
085:
086:            /*
087:             * Test method for 'com.ibm.icu.x.util.ULocale.toLocale()'
088:             */
089:            public void testToLocale() {
090:                assertEquals(sampleLocale, new ULocale("ll", "cc", "VVVV")
091:                        .toLocale());
092:            }
093:
094:            /*
095:             * Test method for 'com.ibm.icu.x.util.ULocale.getDefault()'
096:             */
097:            public void testGetDefault() {
098:                assertEquals(Locale.getDefault(), ULocale.getDefault()
099:                        .toLocale());
100:            }
101:
102:            /*
103:             * Test method for 'com.ibm.icu.x.util.ULocale.setDefault(ULocale)'
104:             */
105:            public void testSetDefault() {
106:                Locale oldLocale = Locale.getDefault();
107:                ULocale oldULocale = ULocale.getDefault();
108:                try {
109:                    ULocale.setDefault(longULocale);
110:                    ICUTestCase.assertNotEqual(Locale.getDefault(), oldLocale);
111:                    ICUTestCase
112:                            .assertNotEqual(ULocale.getDefault(), oldULocale);
113:                    assertEquals(longULocale, ULocale.getDefault());
114:                    assertEquals(sampleLocale, Locale.getDefault());
115:                } finally {
116:                    ULocale.setDefault(oldULocale);
117:                    Locale.setDefault(oldLocale); // in case of some error
118:                }
119:            }
120:
121:            /*
122:             * Test method for 'com.ibm.icu.x.util.ULocale.clone()'
123:             */
124:            public void testClone() {
125:                // see testHashcode
126:            }
127:
128:            /*
129:             * Test method for 'com.ibm.icu.x.util.ULocale.equals(Object)'
130:             */
131:            public void testEqualsObject() {
132:                // see testHashcode
133:            }
134:
135:            /*
136:             * Test method for 'com.ibm.icu.x.util.ULocale.getAvailableLocales()'
137:             */
138:            public void testGetAvailableLocales() {
139:                ULocale[] ulocales = ULocale.getAvailableLocales();
140:                if (ICUTestCase.testingWrapper) {
141:                    Locale[] locales = Locale.getAvailableLocales();
142:                    for (int i = 0; i < ulocales.length; ++i) {
143:                        assertEquals(ulocales[i].toLocale(), locales[i]);
144:                    }
145:                }
146:                // else nothing to test except that the function returned.
147:            }
148:
149:            /*
150:             * Test method for 'com.ibm.icu.x.util.ULocale.getISOCountries()'
151:             */
152:            public void testGetISOCountries() {
153:                String[] ucountries = ULocale.getISOCountries();
154:                assertNotNull(ucountries);
155:                if (ICUTestCase.testingWrapper) {
156:                    // keep our own data for now
157:                    // our data doesn't match java's so this test would fail
158:                    // TODO: enable if we decide to use java's data
159:                    // String[] countries = Locale.getISOCountries();
160:                    // TestBoilerplate.assertArraysEqual(ucountries, countries);
161:                }
162:                // else nothing to test except that the function returned.
163:            }
164:
165:            /*
166:             * Test method for 'com.ibm.icu.x.util.ULocale.getISOLanguages()'
167:             */
168:            public void testGetISOLanguages() {
169:                String[] ulanguages = ULocale.getISOLanguages();
170:                assertNotNull(ulanguages);
171:                if (ICUTestCase.testingWrapper) {
172:                    // keep our own data for now
173:                    // our data doesn't match java's so this test would fail
174:                    // TODO: enable if we decide to use java's data
175:                    // String[] languages = Locale.getISOLanguages();
176:                    // TestBoilerplate.assertArraysEqual(ulanguages, languages);
177:                }
178:                // else nothing to test except that the function returned.
179:            }
180:
181:            /*
182:             * Test method for 'com.ibm.icu.x.util.ULocale.getLanguage()'
183:             */
184:            public void testGetLanguage() {
185:                assertEquals("ll", longULocale.getLanguage());
186:                assertEquals("ll", longULocale.toLocale().getLanguage());
187:            }
188:
189:            /*
190:             * Test method for 'com.ibm.icu.x.util.ULocale.getLanguage(String)'
191:             */
192:            public void testGetLanguageString() {
193:                assertEquals("ll", ULocale.getLanguage(longULocale.getName()));
194:            }
195:
196:            /*
197:             * Test method for 'com.ibm.icu.x.util.ULocale.getScript()'
198:             */
199:            public void testGetScript() {
200:                assertEquals("Ssss", longULocale.getScript());
201:            }
202:
203:            /*
204:             * Test method for 'com.ibm.icu.x.util.ULocale.getScript(String)'
205:             */
206:            public void testGetScriptString() {
207:                assertEquals("Ssss", ULocale.getScript(longULocale.getName()));
208:            }
209:
210:            /*
211:             * Test method for 'com.ibm.icu.x.util.ULocale.getCountry()'
212:             */
213:            public void testGetCountry() {
214:                assertEquals("CC", longULocale.getCountry());
215:                assertEquals("CC", longULocale.toLocale().getCountry());
216:            }
217:
218:            /*
219:             * Test method for 'com.ibm.icu.x.util.ULocale.getCountry(String)'
220:             */
221:            public void testGetCountryString() {
222:                assertEquals("CC", ULocale.getCountry(longULocale.getName()));
223:            }
224:
225:            /*
226:             * Test method for 'com.ibm.icu.x.util.ULocale.getVariant()'
227:             */
228:            public void testGetVariant() {
229:                assertEquals("VVVV", longULocale.getVariant());
230:                assertEquals("VVVV", longULocale.toLocale().getVariant());
231:            }
232:
233:            /*
234:             * Test method for 'com.ibm.icu.x.util.ULocale.getVariant(String)'
235:             */
236:            public void testGetVariantString() {
237:                assertEquals("VVVV", ULocale.getVariant(longULocale.getName()));
238:            }
239:
240:            /*
241:             * Test method for 'com.ibm.icu.x.util.ULocale.getFallback(String)'
242:             */
243:            public void testGetFallbackString() {
244:                assertEquals(ULocale.GERMAN, ULocale
245:                        .getFallback(ULocale.GERMANY.getName()));
246:            }
247:
248:            /*
249:             * Test method for 'com.ibm.icu.x.util.ULocale.getFallback()'
250:             */
251:            public void testGetFallback() {
252:                assertEquals(ULocale.GERMAN, ULocale.GERMANY.getFallback());
253:            }
254:
255:            /*
256:             * Test method for 'com.ibm.icu.x.util.ULocale.getBaseName()'
257:             */
258:            public void testGetBaseName() {
259:                assertEquals(longULocaleBasename, longULocale.getBaseName());
260:            }
261:
262:            /*
263:             * Test method for 'com.ibm.icu.x.util.ULocale.getBaseName(String)'
264:             */
265:            public void testGetBaseNameString() {
266:                assertEquals(longULocaleBasename, longULocale.getBaseName());
267:            }
268:
269:            /*
270:             * Test method for 'com.ibm.icu.x.util.ULocale.getName()'
271:             */
272:            public void testGetName() {
273:                assertEquals(longULocaleName, longULocale.getName());
274:            }
275:
276:            /*
277:             * Test method for 'com.ibm.icu.x.util.ULocale.getName(String)'
278:             */
279:            public void testGetNameString() {
280:                assertEquals(longULocaleName, ULocale
281:                        .getName(nonNormalizedName));
282:            }
283:
284:            /*
285:             * Test method for 'com.ibm.icu.x.util.ULocale.toString()'
286:             */
287:            public void testToString() {
288:                assertEquals(longULocaleName, longULocale.toString());
289:            }
290:
291:            /*
292:             * Test method for 'com.ibm.icu.x.util.ULocale.getKeywords()'
293:             */
294:            public void testGetKeywords() {
295:                Iterator iter = longULocale.getKeywords();
296:                assertEquals(iter.next(), "collation");
297:                assertEquals(iter.next(), "key");
298:                assertFalse(iter.hasNext());
299:            }
300:
301:            /*
302:             * Test method for 'com.ibm.icu.x.util.ULocale.getKeywords(String)'
303:             */
304:            public void testGetKeywordsString() {
305:                Iterator iter = ULocale.getKeywords(nonNormalizedName);
306:                assertEquals(iter.next(), "collation");
307:                assertEquals(iter.next(), "key");
308:                assertFalse(iter.hasNext());
309:            }
310:
311:            /*
312:             * Test method for 'com.ibm.icu.x.util.ULocale.getKeywordValue(String)'
313:             */
314:            public void testGetKeywordValueString() {
315:                assertEquals("value", longULocale.getKeywordValue("key"));
316:                assertEquals("phonebook", longULocale
317:                        .getKeywordValue("collation"));
318:                assertNull(longULocale.getKeywordValue("zzyzx"));
319:            }
320:
321:            /*
322:             * Test method for 'com.ibm.icu.x.util.ULocale.getKeywordValue(String, String)'
323:             */
324:            public void testGetKeywordValueStringString() {
325:                assertEquals("value", ULocale.getKeywordValue(longULocaleName,
326:                        "key"));
327:                assertEquals("phonebook", ULocale.getKeywordValue(
328:                        longULocaleName, "collation"));
329:                assertNull(ULocale.getKeywordValue(longULocaleName, "zzyzx"));
330:
331:            }
332:
333:            /*
334:             * Test method for 'com.ibm.icu.x.util.ULocale.canonicalize(String)'
335:             */
336:            public void testCanonicalize() {
337:                assertEquals("de@collation=phonebook", ULocale
338:                        .canonicalize("de__PHONEBOOK"));
339:            }
340:
341:            /*
342:             * Test method for 'com.ibm.icu.x.util.ULocale.setKeywordValue(String, String)'
343:             */
344:            public void testSetKeywordValueStringString() {
345:                ULocale munged = longULocale.setKeywordValue("key", "C#");
346:                assertEquals("C#", munged.getKeywordValue("key"));
347:                munged = munged.setKeywordValue("zzyzx", "grue");
348:                assertEquals("grue", munged.getKeywordValue("zzyzx"));
349:            }
350:
351:            /*
352:             * Test method for 'com.ibm.icu.x.util.ULocale.setKeywordValue(String, String, String)'
353:             */
354:            public void testSetKeywordValueStringStringString() {
355:                String munged = ULocale.setKeywordValue(longULocaleName, "key",
356:                        "C#");
357:                assertEquals("C#", ULocale.getKeywordValue(munged, "key"));
358:                munged = ULocale.setKeywordValue(munged, "zzyzx", "grue");
359:                assertEquals("grue", ULocale.getKeywordValue(munged, "zzyzx"));
360:            }
361:
362:            /*
363:             * Test method for 'com.ibm.icu.x.util.ULocale.getISO3Language()'
364:             */
365:            public void testGetISO3Language() {
366:                String il = ULocale.GERMANY.getISO3Language();
367:                String jl = Locale.GERMANY.getISO3Language();
368:                assertEquals(il, jl);
369:            }
370:
371:            /*
372:             * Test method for 'com.ibm.icu.x.util.ULocale.getISO3Language(String)'
373:             */
374:            public void testGetISO3LanguageString() {
375:                String il = ULocale.getISO3Language(ULocale.GERMANY.getName());
376:                String jl = Locale.GERMANY.getISO3Language();
377:                assertEquals(il, jl);
378:            }
379:
380:            /*
381:             * Test method for 'com.ibm.icu.x.util.ULocale.getISO3Country()'
382:             */
383:            public void testGetISO3Country() {
384:                String ic = ULocale.GERMANY.getISO3Country();
385:                String jc = Locale.GERMANY.getISO3Country();
386:                assertEquals(ic, jc);
387:            }
388:
389:            /*
390:             * Test method for 'com.ibm.icu.x.util.ULocale.getISO3Country(String)'
391:             */
392:            public void testGetISO3CountryString() {
393:                String ic = ULocale.getISO3Country(ULocale.GERMANY.getName());
394:                String jc = Locale.GERMANY.getISO3Country();
395:                assertEquals(ic, jc);
396:            }
397:
398:            /*
399:             * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayLanguage()'
400:             */
401:            public void testGetDisplayLanguage() {
402:                String idl = ULocale.GERMANY.getDisplayLanguage();
403:                String jdl = Locale.GERMANY.getDisplayLanguage();
404:                assertEquals(idl, jdl);
405:            }
406:
407:            /*
408:             * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayLanguage(ULocale)'
409:             */
410:            public void testGetDisplayLanguageULocale() {
411:                String idl = ULocale.GERMANY
412:                        .getDisplayLanguage(ULocale.GERMANY);
413:                String jdl = Locale.GERMANY.getDisplayLanguage(Locale.GERMANY);
414:                assertEquals(idl, jdl);
415:            }
416:
417:            /*
418:             * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayLanguage(String, String)'
419:             */
420:            public void testGetDisplayLanguageStringString() {
421:                String idl = ULocale.getDisplayLanguage(ULocale.GERMANY
422:                        .getName(), "de_DE");
423:                String jdl = Locale.GERMANY.getDisplayLanguage(Locale.GERMANY);
424:                assertEquals(idl, jdl);
425:            }
426:
427:            /*
428:             * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayLanguage(String, ULocale)'
429:             */
430:            public void testGetDisplayLanguageStringULocale() {
431:                String idl = ULocale.getDisplayLanguage(ULocale.GERMANY
432:                        .getName(), ULocale.GERMANY);
433:                String jdl = Locale.GERMANY.getDisplayLanguage(Locale.GERMANY);
434:                assertEquals(idl, jdl);
435:            }
436:
437:            /*
438:             * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayScript()'
439:             */
440:            public void testGetDisplayScript() {
441:                String is = ULocale.TRADITIONAL_CHINESE.getDisplayScript();
442:                if (ICUTestCase.testingWrapper) {
443:                    assertEquals("Hant", is);
444:                } else {
445:                    assertEquals("Traditional Chinese", is);
446:                }
447:            }
448:
449:            /*
450:             * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayScript(ULocale)'
451:             */
452:            public void testGetDisplayScriptULocale() {
453:                String is = ULocale.TRADITIONAL_CHINESE
454:                        .getDisplayScript(ULocale.GERMANY);
455:                if (ICUTestCase.testingWrapper) {
456:                    assertEquals("Hant", is);
457:                } else {
458:                    // TODO: look up expected value
459:                    assertEquals("Hant", is);
460:                }
461:            }
462:
463:            /*
464:             * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayScript(String, String)'
465:             */
466:            public void testGetDisplayScriptStringString() {
467:                String is = ULocale.getDisplayScript("zh_Hant", "de_DE");
468:                if (ICUTestCase.testingWrapper) {
469:                    assertEquals("Hant", is);
470:                } else {
471:                    // TODO: look up expected value
472:                    assertEquals("Hant", is);
473:                }
474:            }
475:
476:            /*
477:             * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayScript(String, ULocale)'
478:             */
479:            public void testGetDisplayScriptStringULocale() {
480:                String is = ULocale
481:                        .getDisplayScript("zh_Hant", ULocale.GERMANY);
482:                if (ICUTestCase.testingWrapper) {
483:                    assertEquals("Hant", is);
484:                } else {
485:                    // TODO: look up expected value
486:                    assertEquals("Hant", is);
487:                }
488:            }
489:
490:            /*
491:             * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayCountry()'
492:             */
493:            public void testGetDisplayCountry() {
494:                String idc = ULocale.GERMANY.getDisplayCountry();
495:                String jdc = Locale.GERMANY.getDisplayCountry();
496:                assertEquals(idc, jdc);
497:            }
498:
499:            /*
500:             * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayCountry(ULocale)'
501:             */
502:            public void testGetDisplayCountryULocale() {
503:                String idc = ULocale.GERMANY.getDisplayCountry(ULocale.GERMANY);
504:                String jdc = Locale.GERMANY.getDisplayCountry(Locale.GERMANY);
505:                assertEquals(idc, jdc);
506:            }
507:
508:            /*
509:             * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayCountry(String, String)'
510:             */
511:            public void testGetDisplayCountryStringString() {
512:                String idc = ULocale.getDisplayCountry("de_DE", "de_DE");
513:                String jdc = Locale.GERMANY.getDisplayCountry(Locale.GERMANY);
514:                assertEquals(idc, jdc);
515:            }
516:
517:            /*
518:             * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayCountry(String, ULocale)'
519:             */
520:            public void testGetDisplayCountryStringULocale() {
521:                String idc = ULocale
522:                        .getDisplayCountry("de_DE", ULocale.GERMANY);
523:                String jdc = Locale.GERMANY.getDisplayCountry(Locale.GERMANY);
524:                assertEquals(idc, jdc);
525:            }
526:
527:            /*
528:             * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayVariant()'
529:             */
530:            public void testGetDisplayVariant() {
531:                String idv = new ULocale("de_DE_PHONEBOOK").getDisplayVariant();
532:                String jdv = new Locale("de", "DE", "PHONEBOOK")
533:                        .getDisplayVariant();
534:                assertEquals(jdv, idv);
535:            }
536:
537:            /*
538:             * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayVariant(ULocale)'
539:             */
540:            public void testGetDisplayVariantULocale() {
541:                String idv = new ULocale("de_DE_PHONEBOOK")
542:                        .getDisplayVariant(ULocale.GERMANY);
543:                String jdv = new Locale("de", "DE", "PHONEBOOK")
544:                        .getDisplayVariant(Locale.GERMANY);
545:                assertEquals(jdv, idv);
546:            }
547:
548:            /*
549:             * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayVariant(String, String)'
550:             */
551:            public void testGetDisplayVariantStringString() {
552:                String idv = ULocale.getDisplayVariant("de_DE_PHONEBOOK",
553:                        "de_DE");
554:                String jdv = new Locale("de", "DE", "PHONEBOOK")
555:                        .getDisplayVariant(Locale.GERMANY);
556:                assertEquals(jdv, idv);
557:            }
558:
559:            /*
560:             * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayVariant(String, ULocale)'
561:             */
562:            public void testGetDisplayVariantStringULocale() {
563:                String idv = ULocale.getDisplayVariant("de_DE_PHONEBOOK",
564:                        ULocale.GERMANY);
565:                String jdv = new Locale("de", "DE", "PHONEBOOK")
566:                        .getDisplayVariant(Locale.GERMANY);
567:                assertEquals(jdv, idv);
568:            }
569:
570:            /*
571:             * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayKeyword(String)'
572:             */
573:            public void testGetDisplayKeywordString() {
574:                String idk = ULocale.getDisplayKeyword("collation");
575:                assertEquals("collation", idk);
576:            }
577:
578:            /*
579:             * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayKeyword(String, String)'
580:             */
581:            public void testGetDisplayKeywordStringString() {
582:                String idk = ULocale.getDisplayKeyword("collation", "de_DE");
583:                if (ICUTestCase.testingWrapper) {
584:                    assertEquals("collation", idk);
585:                } else {
586:                    // TODO: find real value
587:                    assertEquals("collation", idk);
588:                }
589:            }
590:
591:            /*
592:             * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayKeyword(String, ULocale)'
593:             */
594:            public void testGetDisplayKeywordStringULocale() {
595:                String idk = ULocale.getDisplayKeyword("collation",
596:                        ULocale.GERMANY);
597:                if (ICUTestCase.testingWrapper) {
598:                    assertEquals("collation", idk);
599:                } else {
600:                    // TODO: find real value
601:                    assertEquals("collation", idk);
602:                }
603:            }
604:
605:            /*
606:             * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayKeywordValue(String)'
607:             */
608:            public void testGetDisplayKeywordValueString() {
609:                ULocale ul = new ULocale("de_DE@collation=phonebook");
610:                String idk = ul.getDisplayKeywordValue("collation");
611:                if (ICUTestCase.testingWrapper) {
612:                    assertEquals("phonebook", idk);
613:                } else {
614:                    // TODO: find real value
615:                    assertEquals("phonebook", idk);
616:                }
617:            }
618:
619:            /*
620:             * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayKeywordValue(String, ULocale)'
621:             */
622:            public void testGetDisplayKeywordValueStringULocale() {
623:                ULocale ul = new ULocale("de_DE@collation=phonebook");
624:                String idk = ul.getDisplayKeywordValue("collation",
625:                        ULocale.GERMANY);
626:                if (ICUTestCase.testingWrapper) {
627:                    assertEquals("phonebook", idk);
628:                } else {
629:                    // TODO: find real value
630:                    assertEquals("phonebook", idk);
631:                }
632:            }
633:
634:            /*
635:             * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayKeywordValue(String, String, String)'
636:             */
637:            public void testGetDisplayKeywordValueStringStringString() {
638:                String idk = ULocale.getDisplayKeywordValue(
639:                        "de_DE@collation=phonebook", "collation", "de_DE");
640:                if (ICUTestCase.testingWrapper) {
641:                    assertEquals("phonebook", idk);
642:                } else {
643:                    // TODO: find real value
644:                    assertEquals("phonebook", idk);
645:                }
646:            }
647:
648:            /*
649:             * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayKeywordValue(String, String, ULocale)'
650:             */
651:            public void testGetDisplayKeywordValueStringStringULocale() {
652:                String idk = ULocale.getDisplayKeywordValue(
653:                        "de_DE@collation=phonebook", "collation",
654:                        ULocale.GERMANY);
655:                if (ICUTestCase.testingWrapper) {
656:                    assertEquals("phonebook", idk);
657:                } else {
658:                    // TODO: find real value
659:                    assertEquals("phonebook", idk);
660:                }
661:            }
662:
663:            /*
664:             * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayName()'
665:             */
666:            public void testGetDisplayName() {
667:                String idn = ULocale.GERMANY.getDisplayName();
668:                String jdn = Locale.GERMANY.getDisplayName();
669:                assertEquals(idn, jdn);
670:            }
671:
672:            /*
673:             * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayName(ULocale)'
674:             */
675:            public void testGetDisplayNameULocale() {
676:                String idn = ULocale.GERMANY.getDisplayName(ULocale.GERMANY);
677:                String jdn = Locale.GERMANY.getDisplayName(Locale.GERMANY);
678:                assertEquals(idn, jdn);
679:            }
680:
681:            /*
682:             * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayName(String, String)'
683:             */
684:            public void testGetDisplayNameStringString() {
685:                String idn = ULocale.getDisplayName("de_DE", "de_DE");
686:                String jdn = Locale.GERMANY.getDisplayName(Locale.GERMANY);
687:                assertEquals(idn, jdn);
688:            }
689:
690:            /*
691:             * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayName(String, ULocale)'
692:             */
693:            public void testGetDisplayNameStringULocale() {
694:                String idn = ULocale.getDisplayName("de_DE", ULocale.GERMANY);
695:                String jdn = Locale.GERMANY.getDisplayName(Locale.GERMANY);
696:                assertEquals(idn, jdn);
697:            }
698:
699:            /*
700:             * Test method for 'com.ibm.icu.x.util.ULocale.acceptLanguage(String, ULocale[], boolean[])'
701:             */
702:            public void testAcceptLanguageStringULocaleArrayBooleanArray() {
703:                boolean[] fallback = new boolean[1];
704:                ULocale[] locales = { new ULocale("en_CA"),
705:                        new ULocale("es_US"), };
706:                ULocale result = ULocale.acceptLanguage(
707:                        "en-US, en-GB, en-CA, es-US", locales, fallback);
708:                assertEquals(new ULocale("en_CA"), result);
709:                assertFalse(fallback[0]);
710:                result = ULocale.acceptLanguage(
711:                        "en-US, en-GB, es-US-NEWMEXICO", locales, fallback);
712:                assertEquals(new ULocale("es_US"), result);
713:                assertTrue(fallback[0]);
714:            }
715:
716:            /*
717:             * Test method for 'com.ibm.icu.x.util.ULocale.acceptLanguage(ULocale[], ULocale[], boolean[])'
718:             */
719:            public void testAcceptLanguageULocaleArrayULocaleArrayBooleanArray() {
720:                boolean[] fallback = new boolean[1];
721:                ULocale[] locales = { new ULocale("en_CA"),
722:                        new ULocale("es_US"), };
723:                ULocale[] accept_locales = { new ULocale("en_US"),
724:                        new ULocale("en_GB"), new ULocale("en_CA"),
725:                        new ULocale("es_US"), };
726:                ULocale[] accept_locales2 = { new ULocale("en_US"),
727:                        new ULocale("en_GB"), new ULocale("es_US_NEWMEXICO"), };
728:                ULocale result = ULocale.acceptLanguage(accept_locales,
729:                        locales, fallback);
730:                assertEquals(new ULocale("en_CA"), result);
731:                assertFalse(fallback[0]);
732:                result = ULocale.acceptLanguage(accept_locales2, locales,
733:                        fallback);
734:                assertEquals(new ULocale("es_US"), result);
735:                assertTrue(fallback[0]);
736:            }
737:
738:            /*
739:             * Test method for 'com.ibm.icu.x.util.ULocale.acceptLanguage(String, boolean[])'
740:             */
741:            public void testAcceptLanguageStringBooleanArray() {
742:                boolean[] fallback = new boolean[1];
743:                ULocale result = ULocale.acceptLanguage("en-CA, en-GB, es-US",
744:                        fallback);
745:                assertEquals(new ULocale("en_CA"), result);
746:                assertFalse(fallback[0]);
747:                result = ULocale.acceptLanguage("es-US-NEWMEXICO", fallback);
748:                assertNotNull(result); // actual result depends on jdk
749:                assertTrue(fallback[0]);
750:            }
751:
752:            /*
753:             * Test method for 'com.ibm.icu.x.util.ULocale.acceptLanguage(ULocale[], boolean[])'
754:             */
755:            public void testAcceptLanguageULocaleArrayBooleanArray() {
756:                boolean[] fallback = new boolean[1];
757:                ULocale[] accept_locales = { new ULocale("en_CA"),
758:                        new ULocale("en_GB"), new ULocale("es_US"), };
759:                ULocale[] accept_locales2 = { new ULocale("es_US_NEWMEXICO"), };
760:                ULocale result = ULocale.acceptLanguage(accept_locales,
761:                        fallback);
762:                assertEquals(new ULocale("en_CA"), result);
763:                assertFalse(fallback[0]);
764:                result = ULocale.acceptLanguage(accept_locales2, fallback);
765:                assertNotNull(result); // actual result depends on jdk
766:                assertTrue(fallback[0]);
767:            }
768:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.