Source Code Cross Referenced for TestIngresDialect.java in  » Database-JDBC-Connection-Pool » HA-JDBC » net » sf » hajdbc » dialect » 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 JDBC Connection Pool » HA JDBC » net.sf.hajdbc.dialect 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * HA-JDBC: High-Availability JDBC
003:         * Copyright (c) 2004-2007 Paul Ferraro
004:         * 
005:         * This library is free software; you can redistribute it and/or modify it 
006:         * under the terms of the GNU Lesser General Public License as published by the 
007:         * Free Software Foundation; either version 2.1 of the License, or (at your 
008:         * option) any later version.
009:         * 
010:         * This library is distributed in the hope that it will be useful, but WITHOUT
011:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
012:         * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 
013:         * for more details.
014:         * 
015:         * You should have received a copy of the GNU Lesser General Public License
016:         * along with this library; if not, write to the Free Software Foundation, 
017:         * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018:         * 
019:         * Contact: ferraro@users.sourceforge.net
020:         */
021:        package net.sf.hajdbc.dialect;
022:
023:        import java.sql.DatabaseMetaData;
024:        import java.sql.SQLException;
025:        import java.util.Collection;
026:        import java.util.Iterator;
027:
028:        import net.sf.hajdbc.Dialect;
029:        import net.sf.hajdbc.QualifiedName;
030:
031:        import org.easymock.EasyMock;
032:        import org.testng.annotations.DataProvider;
033:        import org.testng.annotations.Test;
034:
035:        /**
036:         * @author Paul Ferraro
037:         */
038:        @SuppressWarnings("nls")
039:        public class TestIngresDialect extends TestStandardDialect {
040:            @Override
041:            protected Dialect createDialect() {
042:                return new IngresDialect();
043:            }
044:
045:            @Override
046:            @Test(dataProvider="insert-table-sql")
047:            public String parseInsertTable(String sql) throws SQLException {
048:                this .replay();
049:
050:                String table = this .dialect.parseInsertTable(sql);
051:
052:                this .verify();
053:
054:                assert table == null : table;
055:
056:                return table;
057:            }
058:
059:            @Override
060:            @Test(dataProvider="meta-data")
061:            public Collection<QualifiedName> getSequences(
062:                    DatabaseMetaData metaData) throws SQLException {
063:                EasyMock.expect(metaData.getConnection()).andReturn(
064:                        this .connection);
065:                EasyMock.expect(this .connection.createStatement()).andReturn(
066:                        this .statement);
067:                EasyMock
068:                        .expect(
069:                                this .statement
070:                                        .executeQuery("SELECT seq_name FROM iisequence"))
071:                        .andReturn(this .resultSet);
072:                EasyMock.expect(this .resultSet.next()).andReturn(true);
073:                EasyMock.expect(this .resultSet.getString(1)).andReturn(
074:                        "sequence1");
075:                EasyMock.expect(this .resultSet.next()).andReturn(true);
076:                EasyMock.expect(this .resultSet.getString(1)).andReturn(
077:                        "sequence2");
078:                EasyMock.expect(this .resultSet.next()).andReturn(false);
079:
080:                this .statement.close();
081:
082:                this .replay();
083:
084:                Collection<QualifiedName> sequences = this .dialect
085:                        .getSequences(metaData);
086:
087:                this .verify();
088:
089:                assert sequences.size() == 2 : sequences.size();
090:
091:                Iterator<QualifiedName> iterator = sequences.iterator();
092:                QualifiedName sequence = iterator.next();
093:                String schema = sequence.getSchema();
094:                String name = sequence.getName();
095:
096:                assert schema == null : schema;
097:                assert name.equals("sequence1") : name;
098:
099:                sequence = iterator.next();
100:                schema = sequence.getSchema();
101:                name = sequence.getName();
102:
103:                assert schema == null : schema;
104:                assert name.equals("sequence2") : name;
105:
106:                return sequences;
107:            }
108:
109:            @Override
110:            @DataProvider(name="sequence-sql")
111:            Object[][] sequenceSQLProvider() {
112:                return new Object[][] {
113:                        new Object[] { "SELECT NEXT VALUE FOR success" },
114:                        new Object[] { "SELECT CURRENT VALUE FOR success" },
115:                        new Object[] { "SELECT NEXT VALUE FOR success, * FROM table" },
116:                        new Object[] { "SELECT CURRENT VALUE FOR success, * FROM table" },
117:                        new Object[] { "INSERT INTO table VALUES (NEXT VALUE FOR success, 0)" },
118:                        new Object[] { "INSERT INTO table VALUES (CURRENT VALUE FOR success, 0)" },
119:                        new Object[] { "UPDATE table SET id = NEXT VALUE FOR success" },
120:                        new Object[] { "UPDATE table SET id = CURRENT VALUE FOR success" },
121:                        new Object[] { "SELECT success.nextval" },
122:                        new Object[] { "SELECT success.currval" },
123:                        new Object[] { "SELECT success.nextval, * FROM table" },
124:                        new Object[] { "SELECT success.currval, * FROM table" },
125:                        new Object[] { "INSERT INTO table VALUES (success.nextval, 0)" },
126:                        new Object[] { "INSERT INTO table VALUES (success.currval, 0)" },
127:                        new Object[] { "UPDATE table SET id = success.nextval" },
128:                        new Object[] { "UPDATE table SET id = success.currval" },
129:                        new Object[] { "SELECT * FROM table" }, };
130:            }
131:
132:            @Override
133:            @DataProvider(name="current-date")
134:            Object[][] currentDateProvider() {
135:                java.sql.Date date = new java.sql.Date(System
136:                        .currentTimeMillis());
137:
138:                return new Object[][] {
139:                        new Object[] { "SELECT CURRENT_DATE FROM success", date },
140:                        new Object[] { "SELECT DATE('TODAY') FROM success",
141:                                date },
142:                        new Object[] { "SELECT DATE ( 'TODAY' ) FROM success",
143:                                date },
144:                        new Object[] { "SELECT CURRENT_DATES FROM failure",
145:                                date },
146:                        new Object[] { "SELECT CCURRENT_DATE FROM failure",
147:                                date },
148:                        new Object[] { "SELECT DDATE('TODAY') FROM failure",
149:                                date },
150:                        new Object[] { "SELECT 1 FROM failure", date }, };
151:            }
152:
153:            @Override
154:            @DataProvider(name="current-time")
155:            Object[][] currentTimeProvider() {
156:                java.sql.Time date = new java.sql.Time(System
157:                        .currentTimeMillis());
158:
159:                return new Object[][] {
160:                        new Object[] { "SELECT CURRENT_TIME FROM success", date },
161:                        new Object[] { "SELECT LOCAL_TIME FROM success", date },
162:                        new Object[] { "SELECT CURRENT_TIMESTAMP FROM failure",
163:                                date },
164:                        new Object[] { "SELECT CCURRENT_TIME FROM failure",
165:                                date },
166:                        new Object[] { "SELECT LOCAL_TIMESTAMP FROM failure",
167:                                date },
168:                        new Object[] { "SELECT LLOCAL_TIME FROM failure", date },
169:                        new Object[] { "SELECT 1 FROM failure", date }, };
170:            }
171:
172:            @Override
173:            @DataProvider(name="current-timestamp")
174:            Object[][] currentTimestampProvider() {
175:                java.sql.Timestamp date = new java.sql.Timestamp(System
176:                        .currentTimeMillis());
177:
178:                return new Object[][] {
179:                        new Object[] { "SELECT CURRENT_TIMESTAMP FROM success",
180:                                date },
181:                        new Object[] { "SELECT LOCAL_TIMESTAMP FROM success",
182:                                date },
183:                        new Object[] { "SELECT DATE('NOW') FROM success", date },
184:                        new Object[] { "SELECT DATE( 'NOW' ) FROM success",
185:                                date },
186:                        new Object[] {
187:                                "SELECT CURRENT_TIMESTAMPS FROM failure", date },
188:                        new Object[] {
189:                                "SELECT CCURRENT_TIMESTAMP FROM failure", date },
190:                        new Object[] { "SELECT LOCAL_TIMESTAMPS FROM failure",
191:                                date },
192:                        new Object[] { "SELECT LLOCAL_TIMESTAMP FROM failure",
193:                                date },
194:                        new Object[] { "SELECT DDATE('NOW') FROM failure", date },
195:                        new Object[] { "SELECT 1 FROM failure", date }, };
196:            }
197:
198:            @Override
199:            @DataProvider(name="random")
200:            Object[][] randomProvider() {
201:                return new Object[][] {
202:                        new Object[] { "SELECT RANDOMF() FROM success" },
203:                        new Object[] { "SELECT RANDOMF ( ) FROM success" },
204:                        new Object[] { "SELECT OPERANDOMF( ) FROM failure" },
205:                        new Object[] { "SELECT RAND() FROM failure" },
206:                        new Object[] { "SELECT 1 FROM failure" }, };
207:            }
208:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.