Source Code Cross Referenced for SerializableTest.java in  » Internationalization-Localization » icu4j » com » ibm » icu » dev » test » serializable » 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.dev.test.serializable 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //##header
002:        /*
003:         *******************************************************************************
004:         * Copyright (C) 1996-2006, International Business Machines Corporation and    *
005:         * others. All Rights Reserved.                                                *
006:         *******************************************************************************
007:         *
008:         */
009:
010:        package com.ibm.icu.dev.test.serializable;
011:
012:        import java.util.Locale;
013:        import java.util.HashMap;
014:
015:        import com.ibm.icu.dev.test.TestFmwk;
016:        import com.ibm.icu.impl.JDKTimeZone;
017:        import com.ibm.icu.impl.LinkedHashMap;
018:        import com.ibm.icu.impl.LRUMap;
019:        import com.ibm.icu.impl.OlsonTimeZone;
020:        import com.ibm.icu.impl.TimeZoneAdapter;
021:        import com.ibm.icu.math.BigDecimal;
022:        import com.ibm.icu.math.MathContext;
023:        import com.ibm.icu.util.Currency;
024:        import com.ibm.icu.util.SimpleTimeZone;
025:        import com.ibm.icu.util.TimeZone;
026:        import com.ibm.icu.util.ULocale;
027:
028:        /**
029:         * @author emader
030:         *
031:         * TODO To change the template for this generated type comment go to
032:         * Window - Preferences - Java - Code Style - Code Templates
033:         */
034:        public class SerializableTest extends TestFmwk.TestGroup {
035:            public interface Handler {
036:                public Object[] getTestObjects();
037:
038:                public boolean hasSameBehavior(Object a, Object b);
039:            }
040:
041:            public static Handler getHandler(String className) {
042:                return (Handler) map.get(className);
043:            }
044:
045:            private static class TimeZoneHandler implements  Handler {
046:                String[] ZONES = { "GMT", "MET", "IST" };
047:
048:                public Object[] getTestObjects() {
049:                    TimeZone zones[] = new TimeZone[ZONES.length];
050:
051:                    for (int z = 0; z < ZONES.length; z += 1) {
052:                        zones[z] = TimeZone.getTimeZone(ZONES[z]);
053:                    }
054:
055:                    return zones;
056:                }
057:
058:                public boolean hasSameBehavior(Object a, Object b) {
059:                    TimeZone zone_a = (TimeZone) a;
060:                    TimeZone zone_b = (TimeZone) b;
061:
062:                    return zone_a.getDisplayName().equals(
063:                            zone_b.getDisplayName())
064:                            && zone_a.hasSameRules(zone_b);
065:                }
066:            }
067:
068:            private static Locale locales[] = { Locale.CANADA,
069:                    Locale.CANADA_FRENCH, Locale.CHINA, Locale.CHINESE,
070:                    Locale.ENGLISH, Locale.FRANCE, Locale.FRENCH,
071:                    Locale.GERMAN, Locale.GERMANY, Locale.ITALIAN,
072:                    Locale.ITALY, Locale.JAPAN, Locale.JAPANESE, Locale.KOREA,
073:                    Locale.KOREAN, Locale.PRC, Locale.SIMPLIFIED_CHINESE,
074:                    Locale.TAIWAN, Locale.TRADITIONAL_CHINESE, Locale.UK,
075:                    Locale.US };
076:
077:            private static Locale places[] = { Locale.CANADA,
078:                    Locale.CANADA_FRENCH, Locale.CHINA, Locale.FRANCE,
079:                    Locale.GERMANY, Locale.ITALY, Locale.JAPAN, Locale.KOREA,
080:                    Locale.PRC, Locale.TAIWAN, Locale.UK, Locale.US };
081:
082:            public static Locale[] getLocales() {
083:                return locales;
084:            }
085:
086:            public static boolean compareStrings(String a[], String b[]) {
087:                if (a.length != b.length) {
088:                    return false;
089:                }
090:
091:                for (int i = 0; i < a.length; i += 1) {
092:                    if (!a[i].equals(b[i])) {
093:                        return false;
094:                    }
095:                }
096:
097:                return true;
098:            }
099:
100:            public static boolean compareChars(char a[], char b[]) {
101:                if (a.length != b.length) {
102:                    return false;
103:                }
104:
105:                for (int i = 0; i < a.length; i += 1) {
106:                    if (a[i] != b[i]) {
107:                        return false;
108:                    }
109:                }
110:
111:                return true;
112:            }
113:
114:            private static class SimpleTimeZoneHandler extends TimeZoneHandler {
115:                public Object[] getTestObjects() {
116:                    SimpleTimeZone simpleTimeZones[] = new SimpleTimeZone[6];
117:
118:                    simpleTimeZones[0] = new SimpleTimeZone(32400000,
119:                            "MyTimeZone");
120:
121:                    simpleTimeZones[1] = new SimpleTimeZone(32400000,
122:                            "Asia/Tokyo");
123:
124:                    simpleTimeZones[2] = new SimpleTimeZone(32400000,
125:                            "Asia/Tokyo");
126:                    simpleTimeZones[2].setRawOffset(0);
127:
128:                    simpleTimeZones[3] = new SimpleTimeZone(32400000,
129:                            "Asia/Tokyo");
130:                    simpleTimeZones[3].setStartYear(100);
131:
132:                    simpleTimeZones[4] = new SimpleTimeZone(32400000,
133:                            "Asia/Tokyo");
134:                    simpleTimeZones[4].setStartYear(1000);
135:                    simpleTimeZones[4].setDSTSavings(1800000);
136:                    simpleTimeZones[4].setStartRule(3, 4, 180000);
137:                    simpleTimeZones[4].setEndRule(6, 3, 4, 360000);
138:
139:                    simpleTimeZones[5] = new SimpleTimeZone(32400000,
140:                            "Asia/Tokyo");
141:                    simpleTimeZones[5].setStartRule(2, 3, 4, 360000);
142:                    simpleTimeZones[5].setEndRule(6, 3, 4, 360000);
143:
144:                    return simpleTimeZones;
145:                }
146:            }
147:
148:            private static class ULocaleHandler implements  Handler {
149:                public Object[] getTestObjects() {
150:                    ULocale uLocales[] = new ULocale[locales.length];
151:
152:                    for (int i = 0; i < locales.length; i += 1) {
153:                        uLocales[i] = ULocale.forLocale(locales[i]);
154:                    }
155:
156:                    return uLocales;
157:                }
158:
159:                public boolean hasSameBehavior(Object a, Object b) {
160:                    ULocale uloc_a = (ULocale) a;
161:                    ULocale uloc_b = (ULocale) b;
162:
163:                    return uloc_a.getName().equals(uloc_b.getName());
164:                }
165:            }
166:
167:            private static class CurrencyHandler implements  Handler {
168:                public Object[] getTestObjects() {
169:                    Currency currencies[] = new Currency[places.length];
170:
171:                    for (int i = 0; i < places.length; i += 1) {
172:                        currencies[i] = Currency.getInstance(places[i]);
173:                    }
174:
175:                    return currencies;
176:                }
177:
178:                public boolean hasSameBehavior(Object a, Object b) {
179:                    Currency curr_a = (Currency) a;
180:                    Currency curr_b = (Currency) b;
181:
182:                    return curr_a.getCurrencyCode().equals(
183:                            curr_b.getCurrencyCode());
184:
185:                }
186:            }
187:
188:            private static class OlsonTimeZoneHandler implements  Handler {
189:                String zoneIDs[] = { "Pacific/Honolulu", "America/Anchorage",
190:                        "America/Los_Angeles", "America/Denver",
191:                        "America/Chicago", "America/New_York", "Africa/Cairo",
192:                        "Africa/Addis_Ababa", "Africa/Dar_es_Salaam",
193:                        "Africa/Freetown", "Africa/Johannesburg",
194:                        "Africa/Nairobi", "Asia/Bangkok", "Asia/Baghdad",
195:                        "Asia/Calcutta", "Asia/Hong_Kong", "Asia/Jakarta",
196:                        "Asia/Jerusalem", "Asia/Manila", "Asia/Tokyo",
197:                        "Europe/Amsterdam", "Europe/Athens", "Europe/Berlin",
198:                        "Europe/London", "Europe/Malta", "Europe/Moscow",
199:                        "Europe/Paris", "Europe/Rome" };
200:
201:                public Object[] getTestObjects() {
202:                    OlsonTimeZone timeZones[] = new OlsonTimeZone[zoneIDs.length];
203:
204:                    for (int i = 0; i < zoneIDs.length; i += 1) {
205:                        timeZones[i] = new OlsonTimeZone(zoneIDs[i]);
206:                    }
207:
208:                    return timeZones;
209:
210:                }
211:
212:                public boolean hasSameBehavior(Object a, Object b) {
213:                    OlsonTimeZone otz_a = (OlsonTimeZone) a;
214:                    OlsonTimeZone otz_b = (OlsonTimeZone) b;
215:                    long now = System.currentTimeMillis();
216:                    int a_offsets[] = { 0, 0 };
217:                    int b_offsets[] = { 0, 0 };
218:
219:                    otz_a.getOffset(now, false, a_offsets);
220:                    otz_b.getOffset(now, false, b_offsets);
221:
222:                    return a_offsets[0] == b_offsets[0]
223:                            && a_offsets[1] == b_offsets[1];
224:                }
225:            }
226:
227:            private static class JDKTimeZoneHandler implements  Handler {
228:                String zoneIDs[] = { "Pacific/Honolulu", "America/Anchorage",
229:                        "America/Los_Angeles", "America/Denver",
230:                        "America/Chicago", "America/New_York", "Africa/Cairo",
231:                        "Africa/Addis_Ababa", "Africa/Dar_es_Salaam",
232:                        "Africa/Freetown", "Africa/Johannesburg",
233:                        "Africa/Nairobi", "Asia/Bangkok", "Asia/Baghdad",
234:                        "Asia/Calcutta", "Asia/Hong_Kong", "Asia/Jakarta",
235:                        "Asia/Jerusalem", "Asia/Manila", "Asia/Tokyo",
236:                        "Europe/Amsterdam", "Europe/Athens", "Europe/Berlin",
237:                        "Europe/London", "Europe/Malta", "Europe/Moscow",
238:                        "Europe/Paris", "Europe/Rome" };
239:
240:                public Object[] getTestObjects() {
241:                    JDKTimeZone timeZones[] = new JDKTimeZone[zoneIDs.length];
242:
243:                    for (int i = 0; i < zoneIDs.length; i += 1) {
244:                        timeZones[i] = new JDKTimeZone(java.util.TimeZone
245:                                .getTimeZone(zoneIDs[i]));
246:                    }
247:
248:                    return timeZones;
249:
250:                }
251:
252:                public boolean hasSameBehavior(Object a, Object b) {
253:                    JDKTimeZone jtz_a = (JDKTimeZone) a;
254:                    JDKTimeZone jtz_b = (JDKTimeZone) b;
255:                    long now = System.currentTimeMillis();
256:                    int a_offsets[] = { 0, 0 };
257:                    int b_offsets[] = { 0, 0 };
258:
259:                    jtz_a.getOffset(now, false, a_offsets);
260:                    jtz_b.getOffset(now, false, b_offsets);
261:
262:                    return a_offsets[0] == b_offsets[0]
263:                            && a_offsets[1] == b_offsets[1];
264:                }
265:            }
266:
267:            private static class TimeZoneAdapterHandler implements  Handler {
268:                String zoneIDs[] = { "Pacific/Honolulu", "America/Anchorage",
269:                        "America/Los_Angeles", "America/Denver",
270:                        "America/Chicago", "America/New_York", "Africa/Cairo",
271:                        "Africa/Addis_Ababa", "Africa/Dar_es_Salaam",
272:                        "Africa/Freetown", "Africa/Johannesburg",
273:                        "Africa/Nairobi", "Asia/Bangkok", "Asia/Baghdad",
274:                        "Asia/Calcutta", "Asia/Hong_Kong", "Asia/Jakarta",
275:                        "Asia/Jerusalem", "Asia/Manila", "Asia/Tokyo",
276:                        "Europe/Amsterdam", "Europe/Athens", "Europe/Berlin",
277:                        "Europe/London", "Europe/Malta", "Europe/Moscow",
278:                        "Europe/Paris", "Europe/Rome" };
279:
280:                public Object[] getTestObjects() {
281:                    TimeZoneAdapter timeZones[] = new TimeZoneAdapter[zoneIDs.length];
282:
283:                    for (int i = 0; i < zoneIDs.length; i += 1) {
284:                        timeZones[i] = new TimeZoneAdapter(TimeZone
285:                                .getTimeZone(zoneIDs[i]));
286:                    }
287:
288:                    return timeZones;
289:
290:                }
291:
292:                public boolean hasSameBehavior(Object a, Object b) {
293:                    TimeZoneAdapter tza_a = (TimeZoneAdapter) a;
294:                    TimeZoneAdapter tza_b = (TimeZoneAdapter) b;
295:
296:                    return tza_a.hasSameRules(tza_b);
297:                }
298:            }
299:
300:            private static class BigDecimalHandler implements  Handler {
301:                String values[] = { "1234567890.", "123456789.0",
302:                        "12345678.90", "1234567.890", "123456.7890",
303:                        "12345.67890", "1234.567890", "123.4567890",
304:                        "12.34567890", "1.234567890", ".1234567890" };
305:
306:                public Object[] getTestObjects() {
307:                    BigDecimal bds[] = new BigDecimal[values.length];
308:
309:                    for (int i = 0; i < values.length; i += 1) {
310:                        bds[i] = new BigDecimal(values[i]);
311:                    }
312:
313:                    return bds;
314:                }
315:
316:                public boolean hasSameBehavior(Object a, Object b) {
317:                    BigDecimal bda = (BigDecimal) a;
318:                    BigDecimal bdb = (BigDecimal) b;
319:
320:                    return bda.toString().equals(bdb.toString());
321:                }
322:            }
323:
324:            private static class MathContextHandler implements  Handler {
325:                int forms[] = { MathContext.PLAIN, MathContext.ENGINEERING,
326:                        MathContext.SCIENTIFIC };
327:                int rounds[] = { MathContext.ROUND_CEILING,
328:                        MathContext.ROUND_DOWN, MathContext.ROUND_FLOOR,
329:                        MathContext.ROUND_HALF_DOWN,
330:                        MathContext.ROUND_HALF_EVEN, MathContext.ROUND_HALF_UP,
331:                        MathContext.ROUND_UNNECESSARY, MathContext.ROUND_UP };
332:
333:                public Object[] getTestObjects() {
334:                    int objectCount = forms.length * rounds.length;
335:                    MathContext contexts[] = new MathContext[objectCount];
336:                    int i = 0;
337:
338:                    for (int f = 0; f < forms.length; f += 1) {
339:                        for (int r = 0; r < rounds.length; r += 1) {
340:                            int digits = f * r;
341:                            boolean lostDigits = (r & 1) != 0;
342:
343:                            contexts[i++] = new MathContext(digits, forms[f],
344:                                    lostDigits, rounds[r]);
345:                        }
346:                    }
347:
348:                    return contexts;
349:                }
350:
351:                public boolean hasSameBehavior(Object a, Object b) {
352:                    MathContext mca = (MathContext) a;
353:                    MathContext mcb = (MathContext) b;
354:
355:                    return mca.toString().equals(mcb.toString());
356:                }
357:            }
358:
359:            private static class LRUMapHandler implements  Handler {
360:                public Object[] getTestObjects() {
361:                    LRUMap[] maps = new LRUMap[1];
362:                    maps[0] = new LRUMap();
363:                    maps[0].put("1", "a");
364:                    maps[0].put("2", "b");
365:                    return maps;
366:                }
367:
368:                public boolean hasSameBehavior(Object a, Object b) {
369:                    LRUMap mapA = (LRUMap) a;
370:                    LRUMap mapB = (LRUMap) b;
371:                    return mapA.equals(mapB);
372:                }
373:            }
374:
375:            private static class LinkedHashMapHandler implements  Handler {
376:                public Object[] getTestObjects() {
377:                    LinkedHashMap[] maps = new LinkedHashMap[2];
378:                    maps[0] = new LinkedHashMap();
379:                    maps[1] = new LinkedHashMap(16, 0.75F, true);
380:                    for (int i = 0; i < 2; i++) {
381:                        maps[i].put("1", "a");
382:                        maps[i].put("2", "b");
383:                    }
384:                    return maps;
385:                }
386:
387:                public boolean hasSameBehavior(Object a, Object b) {
388:                    LinkedHashMap mapA = (LinkedHashMap) a;
389:                    LinkedHashMap mapB = (LinkedHashMap) b;
390:                    return mapA.equals(mapB);
391:                }
392:            }
393:
394:            private static HashMap map = new HashMap();
395:
396:            static {
397:                map.put("com.ibm.icu.util.TimeZone", new TimeZoneHandler());
398:                map.put("com.ibm.icu.util.SimpleTimeZone",
399:                        new SimpleTimeZoneHandler());
400:                map.put("com.ibm.icu.util.ULocale", new ULocaleHandler());
401:                map.put("com.ibm.icu.util.Currency", new CurrencyHandler());
402:                map.put("com.ibm.icu.impl.JDKTimeZone",
403:                        new JDKTimeZoneHandler());
404:                map.put("com.ibm.icu.impl.LinkedHashMap",
405:                        new LinkedHashMapHandler());
406:                map.put("com.ibm.icu.impl.LRUMap", new LRUMapHandler());
407:                map.put("com.ibm.icu.impl.OlsonTimeZone",
408:                        new OlsonTimeZoneHandler());
409:                map.put("com.ibm.icu.impl.TimeZoneAdapter",
410:                        new TimeZoneAdapterHandler());
411:                map.put("com.ibm.icu.math.BigDecimal", new BigDecimalHandler());
412:                map.put("com.ibm.icu.math.MathContext",
413:                        new MathContextHandler());
414:
415:                map.put("com.ibm.icu.text.NumberFormat",
416:                        new FormatTests.NumberFormatHandler());
417:                map.put("com.ibm.icu.text.DecimalFormat",
418:                        new FormatTests.DecimalFormatHandler());
419:                map.put("com.ibm.icu.text.RuleBasedNumberFormat",
420:                        new FormatTests.RuleBasedNumberFormatHandler());
421:                map.put("com.ibm.icu.text.DecimalFormatSymbols",
422:                        new FormatTests.DecimalFormatSymbolsHandler());
423:                map.put("com.ibm.icu.text.MessageFormat",
424:                        new FormatTests.MessageFormatHandler());
425:                map.put("com.ibm.icu.text.DateFormat",
426:                        new FormatTests.DateFormatHandler());
427:                map.put("com.ibm.icu.text.DateFormatSymbols",
428:                        new FormatTests.DateFormatSymbolsHandler());
429:                map.put("com.ibm.icu.text.SimpleDateFormat",
430:                        new FormatTests.SimpleDateFormatHandler());
431:                map.put("com.ibm.icu.text.ChineseDateFormat",
432:                        new FormatTests.ChineseDateFormatHandler());
433:                map.put("com.ibm.icu.text.ChineseDateFormatSymbols",
434:                        new FormatTests.ChineseDateFormatSymbolsHandler());
435:
436:                map.put("com.ibm.icu.util.Calendar",
437:                        new CalendarTests.CalendarHandler());
438:                map.put("com.ibm.icu.util.BuddhistCalendar",
439:                        new CalendarTests.BuddhistCalendarHandler());
440:                map.put("com.ibm.icu.util.ChineseCalendar",
441:                        new CalendarTests.ChineseCalendarHandler());
442:                map.put("com.ibm.icu.util.CopticCalendar",
443:                        new CalendarTests.CopticCalendarHandler());
444:                map.put("com.ibm.icu.util.EthiopicCalendar",
445:                        new CalendarTests.EthiopicCalendarHandler());
446:                map.put("com.ibm.icu.util.GregorianCalendar",
447:                        new CalendarTests.GregorianCalendarHandler());
448:                map.put("com.ibm.icu.util.HebrewCalendar",
449:                        new CalendarTests.HebrewCalendarHandler());
450:                map.put("com.ibm.icu.util.IslamicCalendar",
451:                        new CalendarTests.IslamicCalendarHandler());
452:                map.put("com.ibm.icu.util.JapaneseCalendar",
453:                        new CalendarTests.JapaneseCalendarHandler());
454:
455:                map.put("com.ibm.icu.text.ArabicShapingException",
456:                        new ExceptionTests.ArabicShapingExceptionHandler());
457:                map.put("com.ibm.icu.text.StringPrepParseException",
458:                        new ExceptionTests.StringPrepParseExceptionHandler());
459:                map
460:                        .put(
461:                                "com.ibm.icu.util.UResourceTypeMismatchException",
462:                                new ExceptionTests.UResourceTypeMismatchExceptionHandler());
463:                map.put("com.ibm.icu.impl.InvalidFormatException",
464:                        new ExceptionTests.InvalidFormatExceptionHandler());
465:
466:                //#ifndef FOUNDATION
467:                map.put("com.ibm.icu.text.NumberFormat$Field",
468:                        new FormatTests.NumberFormatFieldHandler());
469:                //#endif
470:            }
471:
472:            public SerializableTest() {
473:                super (
474:                        new String[] {
475:                                "com.ibm.icu.dev.test.serializable.CoverageTest",
476:                                "com.ibm.icu.dev.test.serializable.CompatibilityTest" },
477:                        "All Serializable Tests");
478:            }
479:
480:            public static final String CLASS_TARGET_NAME = "Serializable";
481:
482:            public static void main(String[] args) {
483:                SerializableTest test = new SerializableTest();
484:
485:                test.run(args);
486:            }
487:        }
488:        //eof
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.