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


001:        /*
002:         * $Id: TestAxionStatement.java,v 1.12 2005/04/07 00:31:51 ahimanikya Exp $
003:         * =======================================================================
004:         * Copyright (c) 2002-2003 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:
041:        package org.axiondb.jdbc;
042:
043:        import java.sql.ResultSet;
044:        import java.sql.SQLException;
045:        import java.sql.Statement;
046:
047:        import junit.framework.Test;
048:        import junit.framework.TestSuite;
049:
050:        /**
051:         * @version $Revision: 1.12 $ $Date: 2005/04/07 00:31:51 $
052:         * @author Chuck Burdick
053:         */
054:        public class TestAxionStatement extends AxionTestCaseSupport {
055:
056:            public TestAxionStatement(String testName) {
057:                super (testName);
058:            }
059:
060:            public static Test suite() {
061:                return new TestSuite(TestAxionStatement.class);
062:            }
063:
064:            public void setUp() throws Exception {
065:                super .setUp();
066:                _stmt = getConnection().createStatement();
067:                _stmt.execute("create table foo ( id integer )");
068:                _stmt.execute("insert into foo ( id ) values ( 1 )");
069:                _stmt.execute("insert into foo ( id ) values ( 2 )");
070:
071:                _stmt
072:                        .execute("create table employees (id int, name varchar(25))");
073:            }
074:
075:            public void tearDown() throws Exception {
076:                try {
077:                    _stmt.close();
078:                } catch (Exception e) {
079:                }
080:                _stmt = null;
081:                super .tearDown();
082:            }
083:
084:            protected Statement getQueryStatement() {
085:                return _stmt;
086:            }
087:
088:            protected Statement getInsertStatement() {
089:                return _stmt;
090:            }
091:
092:            protected ResultSet executeQuery() throws SQLException {
093:                return _stmt.executeQuery(QUERY);
094:            }
095:
096:            protected boolean executeQueryViaExecute() throws SQLException {
097:                return _stmt.execute(QUERY);
098:            }
099:
100:            protected boolean executeInsertViaExecute() throws SQLException {
101:                return _stmt.execute(INSERT);
102:            }
103:
104:            public void testCreateStatement() throws Exception {
105:                assertNotNull("Statement should not be null",
106:                        getQueryStatement());
107:            }
108:
109:            public void testCancelIsNotSupported() throws Exception {
110:                try {
111:                    _stmt.cancel();
112:                    fail("Expected SQLException");
113:                } catch (SQLException e) {
114:                    // expected
115:                }
116:            }
117:
118:            public void testExecuteWithAutoGeneratedKeys() throws Exception {
119:                assertTrue(_stmt.execute("select * from foo",
120:                        Statement.NO_GENERATED_KEYS));
121:            }
122:
123:            public void testExecuteWithAutoGeneratedKeys2() throws Exception {
124:                try {
125:                    _stmt.execute("select * from foo",
126:                            Statement.RETURN_GENERATED_KEYS);
127:                    fail("Expected SQLException");
128:                } catch (SQLException e) {
129:                    // expected
130:                }
131:            }
132:
133:            public void testGetGeneratedKeys() throws Exception {
134:                ResultSet rset = _stmt.getGeneratedKeys();
135:                assertNotNull(rset);
136:                assertTrue(!rset.next());
137:                rset.close();
138:            }
139:
140:            public void testGetWarningsAndClearWarnings() throws Exception {
141:                assertNull(_stmt.getWarnings());
142:                _stmt.clearWarnings();
143:                assertNull(_stmt.getWarnings());
144:            }
145:
146:            public void testGetFetchDirection() throws Exception {
147:                assertEquals(ResultSet.FETCH_FORWARD, _stmt.getFetchDirection());
148:            }
149:
150:            public void testSetInvalidFetchDirection() throws Exception {
151:                int invalidFetchDirection = ResultSet.FETCH_FORWARD
152:                        + ResultSet.FETCH_REVERSE + ResultSet.FETCH_UNKNOWN;
153:                try {
154:                    _stmt.setFetchDirection(invalidFetchDirection);
155:                    fail("Expected SQLException");
156:                } catch (SQLException e) {
157:                    // expected
158:                }
159:            }
160:
161:            public void testSetFetchDirection() throws Exception {
162:                _stmt.setFetchDirection(ResultSet.FETCH_FORWARD);
163:                _stmt.setFetchDirection(ResultSet.FETCH_REVERSE);
164:                _stmt.setFetchDirection(ResultSet.FETCH_UNKNOWN);
165:            }
166:
167:            public void testGetSetFetchSize() throws Exception {
168:                assertEquals(0, _stmt.getFetchSize());
169:                _stmt.setFetchSize(0);
170:                assertEquals(0, _stmt.getFetchSize());
171:            }
172:
173:            public void testSetInvalidFetchSize() throws Exception {
174:                try {
175:                    _stmt.setFetchSize(-1);
176:                    fail("Expected SQLException");
177:                } catch (SQLException e) {
178:                    // expected
179:                }
180:            }
181:
182:            public void testGetSetMaxFieldSize() throws Exception {
183:                assertEquals(0, _stmt.getMaxFieldSize());
184:                _stmt.setMaxFieldSize(0);
185:                assertEquals(0, _stmt.getMaxFieldSize());
186:                try {
187:                    _stmt.setMaxFieldSize(-1);
188:                    fail("Expected SQLException");
189:                } catch (SQLException e) {
190:                    // expected
191:                }
192:                assertEquals(0, _stmt.getMaxFieldSize());
193:                try {
194:                    _stmt.setMaxFieldSize(100); // currently not supported
195:                    fail("Expected SQLException");
196:                } catch (SQLException e) {
197:                    // expected
198:                }
199:                assertEquals(0, _stmt.getMaxFieldSize());
200:            }
201:
202:            public void testSetCursorNameIsSafe() throws Exception {
203:                // "If the database doesn't suport positioned update/delete, this method is a noop."
204:                _stmt.setCursorName("foo");
205:            }
206:
207:            public void testGetSetQueryTimeout() throws Exception {
208:                assertEquals(0, _stmt.getQueryTimeout());
209:                _stmt.setQueryTimeout(0);
210:                try {
211:                    _stmt.setQueryTimeout(-1);
212:                    fail("Expected SQLException");
213:                } catch (SQLException e) {
214:                    // expected
215:                }
216:                assertEquals(0, _stmt.getQueryTimeout());
217:                try {
218:                    _stmt.setQueryTimeout(100); // currently not supported
219:                    fail("Expected SQLException");
220:                } catch (SQLException e) {
221:                    // expected
222:                }
223:                assertEquals(0, _stmt.getQueryTimeout());
224:            }
225:
226:            public void testGetResultSetType() throws Exception {
227:                assertEquals(ResultSet.TYPE_FORWARD_ONLY, _stmt
228:                        .getResultSetType());
229:            }
230:
231:            public void testGetResultSetConcurrency() throws Exception {
232:                assertEquals(ResultSet.CONCUR_READ_ONLY, _stmt
233:                        .getResultSetConcurrency());
234:            }
235:
236:            public void testSetEscapeProcessing() throws Exception {
237:                _stmt.setEscapeProcessing(true);
238:                try {
239:                    _stmt.setEscapeProcessing(false); // currently not supported
240:                    fail("Expected SQLException");
241:                } catch (SQLException e) {
242:                    // expected
243:                }
244:            }
245:
246:            public void testGetAndSetMaxRows() throws Exception {
247:                Statement stmt = getQueryStatement();
248:                assertEquals(0, stmt.getMaxRows());
249:                stmt.setMaxRows(100);
250:                assertEquals(100, stmt.getMaxRows());
251:                stmt.setMaxRows(3);
252:                assertEquals(3, stmt.getMaxRows());
253:                try {
254:                    stmt.setMaxRows(-1);
255:                    fail("Expected SQLException");
256:                } catch (SQLException e) {
257:                    // expected
258:                }
259:                assertEquals(3, stmt.getMaxRows());
260:            }
261:
262:            public void testDoubleClose() throws Exception {
263:                Statement stmt = getQueryStatement();
264:                stmt.close();
265:                stmt.close();
266:            }
267:
268:            public void testResultSetIsClosedByGetMoreResults()
269:                    throws SQLException {
270:                ResultSet rset = executeQuery();
271:                assertTrue(rset.next());
272:                assertTrue(!(getQueryStatement().getMoreResults()));
273:                try {
274:                    rset.next();
275:                    fail("Expected SQLException");
276:                } catch (SQLException e) {
277:                    // expected
278:                }
279:            }
280:
281:            public void testResultSetIsClosedByStatementClose()
282:                    throws SQLException {
283:                ResultSet rset = executeQuery();
284:                assertTrue(rset.next());
285:                getQueryStatement().close();
286:                try {
287:                    rset.next();
288:                    fail("Expected SQLException");
289:                } catch (SQLException e) {
290:                    // expected
291:                }
292:            }
293:
294:            public void testGetMoreResultsAfterQuery() throws SQLException {
295:                assertTrue(executeQueryViaExecute());
296:                assertEquals(-1, getQueryStatement().getUpdateCount());
297:                assertNotNull(getQueryStatement().getResultSet());
298:                assertTrue(!getQueryStatement().getMoreResults());
299:                assertEquals(-1, getQueryStatement().getUpdateCount());
300:                assertNull(getQueryStatement().getResultSet());
301:            }
302:
303:            public void testGetMoreResultsAfterInsert() throws SQLException {
304:                assertTrue(!executeInsertViaExecute());
305:                assertEquals(1, getInsertStatement().getUpdateCount());
306:                assertNull(getInsertStatement().getResultSet());
307:                assertTrue(!getInsertStatement().getMoreResults());
308:                assertEquals(-1, getInsertStatement().getUpdateCount());
309:                assertNull(getInsertStatement().getResultSet());
310:            }
311:
312:            public void testExecuteStatementWithNoResultSetFailure()
313:                    throws Exception {
314:                try {
315:                    _stmt.executeQuery(INSERT);
316:                    fail("Expected SQLException; associated statement does not return a ResultSet.");
317:                } catch (SQLException e) {
318:                    // expected
319:                }
320:            }
321:
322:            private Statement _stmt = null;
323:            protected static final String QUERY = "SELECT * FROM FOO";
324:            protected static final String INSERT = "INSERT INTO FOO VALUES ( 3 )";
325:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.