Source Code Cross Referenced for TestDateTimeUtils.java in  » Database-DBMS » axion » org » axiondb » util » 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 » Database DBMS » axion » org.axiondb.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: TestDateTimeUtils.java,v 1.7 2005/06/18 01:03:44 ahimanikya Exp $
003:         * =======================================================================
004:         * Copyright (c) 2004 Axion Development Team.  All rights reserved.
005:         *  
006:         * Redistribution and use in source and binary forms, with or without 
007:         * modification, are permitted provided that the following conditions 
008:         * are met:
009:         * 
010:         * 1. Redistributions of source code must retain the above 
011:         *    copyright notice, this list of conditions and the following 
012:         *    disclaimer. 
013:         *   
014:         * 2. Redistributions in binary form must reproduce the above copyright 
015:         *    notice, this list of conditions and the following disclaimer in 
016:         *    the documentation and/or other materials provided with the 
017:         *    distribution. 
018:         *   
019:         * 3. The names "Tigris", "Axion", nor the names of its contributors may 
020:         *    not be used to endorse or promote products derived from this 
021:         *    software without specific prior written permission. 
022:         *  
023:         * 4. Products derived from this software may not be called "Axion", nor 
024:         *    may "Tigris" or "Axion" appear in their names without specific prior
025:         *    written permission.
026:         *   
027:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
028:         * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
029:         * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
030:         * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
031:         * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
032:         * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
033:         * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
034:         * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
035:         * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
036:         * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
037:         * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
038:         * =======================================================================
039:         */
040:        package org.axiondb.util;
041:
042:        import org.axiondb.AxionException;
043:
044:        import junit.framework.Test;
045:        import junit.framework.TestCase;
046:        import junit.framework.TestSuite;
047:
048:        /**
049:         * Unit tests for DateTimeUtils function.
050:         * 
051:         * @version $Revision: 1.7 $ $Date: 2005/06/18 01:03:44 $
052:         * @author Jonathan Giron
053:         */
054:        public class TestDateTimeUtils extends TestCase {
055:            public TestDateTimeUtils(String testName) {
056:                super (testName);
057:            }
058:
059:            public static Test suite() {
060:                return new TestSuite(TestDateTimeUtils.class);
061:            }
062:
063:            public void testProcessFormatStringWithValidInputs()
064:                    throws Exception {
065:                assertEquals("hh", DateTimeUtils.processFormatString("HH"));
066:                assertEquals("hh", DateTimeUtils.processFormatString("HH12"));
067:                assertEquals("hh", DateTimeUtils.processFormatString("hh12"));
068:                assertEquals("HH", DateTimeUtils.processFormatString("HH24"));
069:                assertEquals("HH", DateTimeUtils.processFormatString("hh24"));
070:                assertEquals("mmMM", DateTimeUtils.processFormatString("mimm"));
071:                assertEquals("mmMM", DateTimeUtils.processFormatString("MIMM"));
072:                assertEquals("mmMM", DateTimeUtils.processFormatString("MImm"));
073:                assertEquals("mmMM", DateTimeUtils.processFormatString("miMM"));
074:                assertEquals("yyyy", DateTimeUtils.processFormatString("YYYY"));
075:                assertEquals("hhMMMM", DateTimeUtils
076:                        .processFormatString("hhMONTH"));
077:                assertEquals("DDDyy", DateTimeUtils
078:                        .processFormatString("DDDYY"));
079:            }
080:
081:            public void testLabelToCode() throws Exception {
082:                assertEquals(DateTimeUtils.DAY, DateTimeUtils
083:                        .labelToCode("day"));
084:                assertEquals(DateTimeUtils.DAY, DateTimeUtils
085:                        .labelToCode("Day"));
086:                assertEquals(DateTimeUtils.DAY, DateTimeUtils
087:                        .labelToCode("DAY"));
088:
089:                assertEquals(DateTimeUtils.MONTH, DateTimeUtils
090:                        .labelToCode("month"));
091:                assertEquals(DateTimeUtils.MONTH, DateTimeUtils
092:                        .labelToCode("Month"));
093:                assertEquals(DateTimeUtils.MONTH, DateTimeUtils
094:                        .labelToCode("MONTH"));
095:
096:                assertEquals(DateTimeUtils.YEAR, DateTimeUtils
097:                        .labelToCode("year"));
098:                assertEquals(DateTimeUtils.YEAR, DateTimeUtils
099:                        .labelToCode("Year"));
100:                assertEquals(DateTimeUtils.YEAR, DateTimeUtils
101:                        .labelToCode("YEAR"));
102:
103:                assertEquals(DateTimeUtils.MINUTE, DateTimeUtils
104:                        .labelToCode("minute"));
105:                assertEquals(DateTimeUtils.MINUTE, DateTimeUtils
106:                        .labelToCode("Minute"));
107:                assertEquals(DateTimeUtils.MINUTE, DateTimeUtils
108:                        .labelToCode("MINUTE"));
109:
110:                assertEquals(DateTimeUtils.SECOND, DateTimeUtils
111:                        .labelToCode("second"));
112:                assertEquals(DateTimeUtils.SECOND, DateTimeUtils
113:                        .labelToCode("Second"));
114:                assertEquals(DateTimeUtils.SECOND, DateTimeUtils
115:                        .labelToCode("SECOND"));
116:
117:                assertEquals(DateTimeUtils.WEEK, DateTimeUtils
118:                        .labelToCode("week"));
119:                assertEquals(DateTimeUtils.WEEK, DateTimeUtils
120:                        .labelToCode("Week"));
121:                assertEquals(DateTimeUtils.WEEK, DateTimeUtils
122:                        .labelToCode("WEEK"));
123:
124:                assertEquals(DateTimeUtils.QUARTER, DateTimeUtils
125:                        .labelToCode("quarter"));
126:                assertEquals(DateTimeUtils.QUARTER, DateTimeUtils
127:                        .labelToCode("Quarter"));
128:                assertEquals(DateTimeUtils.QUARTER, DateTimeUtils
129:                        .labelToCode("QUARTER"));
130:
131:                assertEquals(DateTimeUtils.MILLISECOND, DateTimeUtils
132:                        .labelToCode("millisecond"));
133:                assertEquals(DateTimeUtils.MILLISECOND, DateTimeUtils
134:                        .labelToCode("Millisecond"));
135:                assertEquals(DateTimeUtils.MILLISECOND, DateTimeUtils
136:                        .labelToCode("MILLISECOND"));
137:
138:                final String msg = "Expected AxionException (22006) - invalid interval format";
139:                try {
140:                    DateTimeUtils.labelToCode("blah");
141:                    fail(msg);
142:                } catch (AxionException expected) {
143:                    assertEquals(msg, "22006", expected.getSQLState());
144:                }
145:
146:                try {
147:                    DateTimeUtils.labelToCode(null);
148:                    fail(msg);
149:                } catch (AxionException expected) {
150:                    assertEquals(msg, "22006", expected.getSQLState());
151:                }
152:            }
153:
154:            public void testGetPartMnemonicFor() throws Exception {
155:                String[][] partMnemonicPair = new String[][] {
156:                        new String[] { "WEEKDAY", "dow" },
157:                        new String[] { "WEEKDAY3", "dy" },
158:                        new String[] { "WEEKDAYFULL", "day" },
159:                        new String[] { "DAY", "dd" },
160:                        new String[] { "MONTH", "mm" },
161:                        new String[] { "MONTH3", "mon" },
162:                        new String[] { "MONTHFULL", "month" },
163:                        new String[] { "YEAR", "yyyy" },
164:                        new String[] { "YEAR2", "yy" },
165:                        new String[] { "HOUR", "h" },
166:                        new String[] { "HOUR12", "hh12" },
167:                        new String[] { "HOUR24", "hh24" },
168:                        new String[] { "MINUTE", "mi" },
169:                        new String[] { "SECOND", "ss" },
170:                        new String[] { "WEEK", "w" },
171:                        new String[] { "QUARTER", "q" },
172:                        new String[] { "MILLISECOND", "ff" },
173:                        new String[] { "AMPM", "am" } };
174:
175:                for (int i = 0; i < partMnemonicPair.length; i++) {
176:                    assertEquals(partMnemonicPair[i][1], DateTimeUtils
177:                            .getPartMnemonicFor(partMnemonicPair[i][0]));
178:                }
179:
180:                final String msg = "Expected AxionException (22006) - invalid interval format";
181:                try {
182:                    DateTimeUtils.getPartMnemonicFor(null);
183:                    fail(msg);
184:                } catch (AxionException expected) {
185:                    assertEquals(msg, "22006", expected.getSQLState());
186:                }
187:
188:                try {
189:                    DateTimeUtils.getPartMnemonicFor("unknown");
190:                    fail(msg);
191:                } catch (AxionException expected) {
192:                    assertEquals(msg, "22006", expected.getSQLState());
193:                }
194:            }
195:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.