Source Code Cross Referenced for TimeZoneTest.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.Date;
011:        import java.util.Locale;
012:
013:        import com.ibm.icu.util.Calendar;
014:        import com.ibm.icu.util.TimeZone;
015:        import com.ibm.icu.util.ULocale;
016:
017:        public class TimeZoneTest extends ICUTestCase {
018:
019:            /*
020:             * Test method for 'com.ibm.icu.util.TimeZone.hashCode()'
021:             */
022:            public void testHashCode() {
023:                TimeZone tz1 = TimeZone.getTimeZone("PST");
024:                TimeZone tz2 = TimeZone.getTimeZone("PST");
025:                TimeZone tzn = TimeZone.getTimeZone("CST");
026:                testEHCS(tz1, tz2, tzn);
027:            }
028:
029:            /*
030:             * Test method for 'com.ibm.icu.util.TimeZone.TimeZone(TimeZone)'
031:             */
032:            public void testTimeZone() {
033:                // implicitly tested everywhere
034:            }
035:
036:            /*
037:             * Test method for 'com.ibm.icu.util.TimeZone.getOffset(int, int, int, int, int, int)'
038:             */
039:            public void testGetOffset() {
040:                TimeZone tz = TimeZone.getTimeZone("PST");
041:                int offset = tz.getOffset(1, 2004, 0, 01, 1, 0);
042:                assertEquals(-28800000, offset);
043:            }
044:
045:            /*
046:             * Test method for 'com.ibm.icu.util.TimeZone.setRawOffset(int)'
047:             */
048:            public void testSetRawOffset() {
049:                TimeZone tz = TimeZone.getTimeZone("PST");
050:                int value = tz.getRawOffset();
051:                int value1 = value + 100000;
052:                tz.setRawOffset(value1);
053:                int result = tz.getRawOffset();
054:                assertNotEqual(value, result);
055:                assertEquals(value1, result);
056:            }
057:
058:            /*
059:             * Test method for 'com.ibm.icu.util.TimeZone.getRawOffset()'
060:             */
061:            public void testGetRawOffset() {
062:                TimeZone tz = TimeZone.getTimeZone("PST");
063:                int offset = tz.getRawOffset();
064:                assertEquals(-28800000, offset);
065:            }
066:
067:            /*
068:             * Test method for 'com.ibm.icu.util.TimeZone.getID()'
069:             */
070:            public void testGetID() {
071:                TimeZone tz = TimeZone.getTimeZone("PST");
072:                assertEquals("PST", tz.getID());
073:            }
074:
075:            /*
076:             * Test method for 'com.ibm.icu.util.TimeZone.setID(String)'
077:             */
078:            public void testSetID() {
079:                TimeZone tz = TimeZone.getTimeZone("PST");
080:                String value1 = tz.getID();
081:                String value2 = value1 + "!";
082:                tz.setID(value2);
083:                String result = tz.getID();
084:                assertNotEqual(value1, result);
085:                assertEquals(value2, result);
086:            }
087:
088:            /*
089:             * Test method for 'com.ibm.icu.util.TimeZone.getDisplayName()'
090:             */
091:            public void testGetDisplayName() {
092:                TimeZone tz = TimeZone.getTimeZone("PST");
093:                assertEquals("Pacific Standard Time", tz.getDisplayName());
094:            }
095:
096:            /*
097:             * Test method for 'com.ibm.icu.util.TimeZone.getDisplayName(Locale)'
098:             */
099:            public void testGetDisplayNameLocale() {
100:                TimeZone tz = TimeZone.getTimeZone("PST");
101:                assertEquals("Pacific Standard Time", tz
102:                        .getDisplayName(Locale.US));
103:            }
104:
105:            /*
106:             * Test method for 'com.ibm.icu.util.TimeZone.getDisplayName(ULocale)'
107:             */
108:            public void testGetDisplayNameULocale() {
109:                TimeZone tz = TimeZone.getTimeZone("PST");
110:                assertEquals("Pacific Standard Time", tz
111:                        .getDisplayName(ULocale.US));
112:            }
113:
114:            /*
115:             * Test method for 'com.ibm.icu.util.TimeZone.getDisplayName(boolean, int)'
116:             */
117:            public void testGetDisplayNameBooleanInt() {
118:                TimeZone tz = TimeZone.getTimeZone("PST");
119:                assertEquals("PDT", tz.getDisplayName(true, TimeZone.SHORT));
120:                assertEquals("Pacific Daylight Time", tz.getDisplayName(true,
121:                        TimeZone.LONG));
122:            }
123:
124:            /*
125:             * Test method for 'com.ibm.icu.util.TimeZone.getDisplayName(boolean, int, Locale)'
126:             */
127:            public void testGetDisplayNameBooleanIntLocale() {
128:                TimeZone tz = TimeZone.getTimeZone("PST");
129:                assertEquals("PDT", tz.getDisplayName(true, TimeZone.SHORT,
130:                        Locale.US));
131:                assertEquals("Pacific Daylight Time", tz.getDisplayName(true,
132:                        TimeZone.LONG, Locale.US));
133:            }
134:
135:            /*
136:             * Test method for 'com.ibm.icu.util.TimeZone.getDisplayName(boolean, int, ULocale)'
137:             */
138:            public void testGetDisplayNameBooleanIntULocale() {
139:                TimeZone tz = TimeZone.getTimeZone("PST");
140:                assertEquals("PDT", tz.getDisplayName(true, TimeZone.SHORT,
141:                        ULocale.US));
142:                assertEquals("Pacific Daylight Time", tz.getDisplayName(true,
143:                        TimeZone.LONG, ULocale.US));
144:            }
145:
146:            /*
147:             * Test method for 'com.ibm.icu.util.TimeZone.getDSTSavings()'
148:             */
149:            public void testGetDSTSavings() {
150:                TimeZone tz = TimeZone.getTimeZone("PST");
151:                assertEquals(3600000, tz.getDSTSavings());
152:            }
153:
154:            /*
155:             * Test method for 'com.ibm.icu.util.TimeZone.useDaylightTime()'
156:             */
157:            public void testUseDaylightTime() {
158:                TimeZone tz = TimeZone.getTimeZone("PST");
159:                assertTrue(tz.useDaylightTime());
160:            }
161:
162:            /*
163:             * Test method for 'com.ibm.icu.util.TimeZone.inDaylightTime(Date)'
164:             */
165:            public void testInDaylightTime() {
166:                TimeZone tz = TimeZone.getTimeZone("PST");
167:                Calendar cal = Calendar.getInstance();
168:                cal.set(2005, 0, 17);
169:                Date date = cal.getTime();
170:                assertFalse(tz.inDaylightTime(date));
171:                cal.set(2005, 6, 17);
172:                date = cal.getTime();
173:                assertTrue(tz.inDaylightTime(date));
174:            }
175:
176:            /*
177:             * Test method for 'com.ibm.icu.util.TimeZone.getTimeZone(String)'
178:             */
179:            public void testGetTimeZone() {
180:                // implicitly tested everywhere
181:            }
182:
183:            /*
184:             * Test method for 'com.ibm.icu.util.TimeZone.getAvailableIDs(int)'
185:             */
186:            public void testGetAvailableIDsInt() {
187:                String[] ids = TimeZone.getAvailableIDs(-28800000);
188:                assertNotNull(ids);
189:            }
190:
191:            /*
192:             * Test method for 'com.ibm.icu.util.TimeZone.getAvailableIDs()'
193:             */
194:            public void testGetAvailableIDs() {
195:                String[] ids = TimeZone.getAvailableIDs();
196:                assertNotNull(ids);
197:            }
198:
199:            /*
200:             * Test method for 'com.ibm.icu.util.TimeZone.getDefault()'
201:             */
202:            public void testGetDefault() {
203:                TimeZone tz = TimeZone.getDefault();
204:                assertNotNull(tz);
205:            }
206:
207:            /*
208:             * Test method for 'com.ibm.icu.util.TimeZone.setDefault(TimeZone)'
209:             */
210:            public void testSetDefault() {
211:                TimeZone tz1 = TimeZone.getDefault();
212:                String newCode = "PDT".equals(tz1.getID()) ? "CST" : "PDT";
213:                TimeZone tz2 = TimeZone.getTimeZone(newCode);
214:                TimeZone.setDefault(tz2);
215:                TimeZone result = TimeZone.getDefault();
216:                assertNotEqual(tz1, result);
217:                assertEquals(tz2, result);
218:            }
219:
220:            /*
221:             * Test method for 'com.ibm.icu.util.TimeZone.hasSameRules(TimeZone)'
222:             */
223:            public void testHasSameRules() {
224:                TimeZone tz1 = TimeZone.getTimeZone("PST");
225:                TimeZone tz2 = TimeZone.getTimeZone("America/Los_Angeles");
226:                assertTrue(tz1.hasSameRules(tz2));
227:            }
228:
229:            /*
230:             * Test method for 'com.ibm.icu.util.TimeZone.clone()'
231:             */
232:            public void testClone() {
233:                // tested by testHashCode
234:            }
235:
236:            /*
237:             * Test method for 'com.ibm.icu.util.TimeZone.equals(Object)'
238:             */
239:            public void testEqualsObject() {
240:                // tested by testHashCode
241:            }
242:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.