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


001:        /*
002:         * $Id: TestIndexSpecials.java,v 1.3 2005/04/09 02:04:39 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:
041:        package org.axiondb.functional;
042:
043:        import java.io.File;
044:        import java.sql.Connection;
045:        import java.sql.DriverManager;
046:        import java.sql.Statement;
047:
048:        import junit.framework.Test;
049:        import junit.framework.TestSuite;
050:
051:        /**
052:         * This class is designed two have only two tests Do not add more.
053:         * 
054:         * @author Ritesh adval
055:         */
056:        public class TestIndexSpecials extends AbstractFunctionalTest {
057:
058:            //------------------------------------------------------------ Conventional
059:
060:            public TestIndexSpecials(String testName) {
061:                super (testName);
062:            }
063:
064:            public static Test suite() {
065:                return new TestSuite(TestIndexSpecials.class);
066:            }
067:
068:            //--------------------------------------------------------------- Lifecycle
069:
070:            public void setUp() throws Exception {
071:                super .setUp();
072:            }
073:
074:            public void tearDown() throws Exception {
075:                try {
076:                    if (_rset != null)
077:                        _rset.close();
078:                } catch (Exception t) {
079:                }
080:                try {
081:                    if (_stmt != null)
082:                        _stmt.close();
083:                } catch (Exception t) {
084:                }
085:                try {
086:                    if (_conn != null)
087:                        _conn.close();
088:                } catch (Exception t) {
089:                }
090:                _rset = null;
091:                _stmt = null;
092:                _conn = null;
093:                {
094:                    Connection conn = DriverManager
095:                            .getConnection(getConnectString());
096:                    Statement stmt = conn.createStatement();
097:                    stmt.execute("shutdown");
098:                    stmt.close();
099:                    conn.close();
100:                }
101:                //delete data base dir after we execute two test cases
102:                if (!oneExecuted) {
103:                    deleteFile(getDatabaseDirectory());
104:                }
105:            }
106:
107:            protected String getConnectString() {
108:                return "jdbc:axiondb:testdb:testdb";
109:            }
110:
111:            protected File getDatabaseDirectory() {
112:                return new File(new File("."), "testdb");
113:            }
114:
115:            public void testTruncateOnIndexedTable1() throws Exception {
116:                if (!oneExecuted) {
117:                    truncateOnIndexedTable1();
118:                    oneExecuted = true;
119:                } else {
120:                    truncateOnIndexedTable2();
121:                    oneExecuted = false;
122:                }
123:            }
124:
125:            public void testTruncateOnIndexedTable2() throws Exception {
126:                if (!oneExecuted) {
127:                    truncateOnIndexedTable1();
128:                    oneExecuted = true;
129:                } else {
130:                    truncateOnIndexedTable2();
131:                    oneExecuted = false;
132:                }
133:            }
134:
135:            private void truncateOnIndexedTable1() throws Exception {
136:                //************(1)int btree index****************
137:                createXTable();
138:                //select
139:                _rset = _stmt.executeQuery("select id from x ");
140:                assertNotNull(_rset);
141:                assertTrue(_rset.next());
142:                assertTrue(_rset.next());
143:                assertTrue(!_rset.next());
144:                _rset.close();
145:
146:                //truncate
147:                _stmt.execute("truncate table x");
148:
149:                selectXAfterTruncate();
150:
151:                //**************(2)int array index****************
152:                createYTable();
153:                //select
154:                _rset = _stmt.executeQuery("select id from y ");
155:                assertNotNull(_rset);
156:                assertTrue(_rset.next());
157:                assertTrue(_rset.next());
158:                assertTrue(!_rset.next());
159:                _rset.close();
160:
161:                //truncate
162:                _stmt.execute("truncate table y");
163:
164:                selectYAfterTruncate();
165:
166:                //*****************(3) string btree index *******************
167:                createZTable();
168:                //select
169:                _rset = _stmt.executeQuery("select id from z ");
170:                assertNotNull(_rset);
171:                assertTrue(_rset.next());
172:                assertTrue(_rset.next());
173:                assertTrue(!_rset.next());
174:                _rset.close();
175:
176:                //truncate
177:                _stmt.execute("truncate table z");
178:
179:                selectZAfterTruncate();
180:
181:                //*****************(4) string btree index *******************
182:                createWTable();
183:                //select
184:                _rset = _stmt.executeQuery("select id from w ");
185:                assertNotNull(_rset);
186:                assertTrue(_rset.next());
187:                assertTrue(_rset.next());
188:                assertTrue(!_rset.next());
189:                _rset.close();
190:
191:                //truncate
192:                _stmt.execute("truncate table w");
193:
194:                selectWAfterTruncate();
195:
196:            }
197:
198:            private void truncateOnIndexedTable2() throws Exception {
199:                //***************(1) int btree index******************
200:                //select id again
201:                selectXAfterTruncate();
202:
203:                _stmt.execute("insert into x values ( 1)");
204:                _stmt.execute("insert into x values ( 2)");
205:
206:                //select
207:                _rset = _stmt.executeQuery("select id from x ");
208:                assertNotNull(_rset);
209:                assertTrue(_rset.next());
210:                assertTrue(_rset.next());
211:                assertTrue(!_rset.next());
212:                _rset.close();
213:
214:                //truncate
215:                _stmt.execute("truncate table x");
216:
217:                selectXAfterTruncate();
218:
219:                //***************(2)int array index*****************
220:                //select id again
221:                selectYAfterTruncate();
222:
223:                _stmt.execute("insert into y values ( 1)");
224:                _stmt.execute("insert into y values ( 2)");
225:
226:                //select
227:                _rset = _stmt.executeQuery("select id from y ");
228:                assertNotNull(_rset);
229:                assertTrue(_rset.next());
230:                assertTrue(_rset.next());
231:                assertTrue(!_rset.next());
232:                _rset.close();
233:
234:                //truncate
235:                _stmt.execute("truncate table y");
236:
237:                selectYAfterTruncate();
238:
239:                //*********************(3) string btree index *****************
240:                //select id again
241:                selectZAfterTruncate();
242:
243:                _stmt.execute("insert into z values ( '1')");
244:                _stmt.execute("insert into z values ( '2')");
245:
246:                //select
247:                _rset = _stmt.executeQuery("select id from z ");
248:                assertNotNull(_rset);
249:                assertTrue(_rset.next());
250:                assertTrue(_rset.next());
251:                assertTrue(!_rset.next());
252:                _rset.close();
253:
254:                //truncate
255:                _stmt.execute("truncate table z");
256:
257:                selectZAfterTruncate();
258:
259:                //*********************(4) string array index *****************
260:                //select id again
261:                selectWAfterTruncate();
262:
263:                _stmt.execute("insert into w values ( '1')");
264:                _stmt.execute("insert into w values ( '2')");
265:
266:                //select
267:                _rset = _stmt.executeQuery("select id from w ");
268:                assertNotNull(_rset);
269:                assertTrue(_rset.next());
270:                assertTrue(_rset.next());
271:                assertTrue(!_rset.next());
272:                _rset.close();
273:
274:                //truncate
275:                _stmt.execute("truncate table w");
276:
277:                selectWAfterTruncate();
278:            }
279:
280:            private void createXTable() throws Exception {
281:                _stmt.execute("create table x ( id int)");
282:                _stmt.execute("create btree index idx_x on x (id)");
283:                _stmt.execute("insert into x values ( 1)");
284:                _stmt.execute("insert into x values ( 2)");
285:
286:            }
287:
288:            private void createYTable() throws Exception {
289:                _stmt.execute("create table y ( id int)");
290:                _stmt.execute("create index idx_y on y (id)");
291:                _stmt.execute("insert into y values ( 1)");
292:                _stmt.execute("insert into y values ( 2)");
293:            }
294:
295:            private void createZTable() throws Exception {
296:                _stmt.execute("create table z ( id varchar)");
297:                _stmt.execute("create btree index idx_z on z (id)");
298:                _stmt.execute("insert into z values ( '1')");
299:                _stmt.execute("insert into z values ( '2')");
300:
301:            }
302:
303:            private void createWTable() throws Exception {
304:                _stmt.execute("create table w ( id varchar)");
305:                _stmt.execute("create index idx_w on w (id)");
306:                _stmt.execute("insert into w values ( '1')");
307:                _stmt.execute("insert into w values ( '2')");
308:
309:            }
310:
311:            private void selectXAfterTruncate() throws Exception {
312:                //      select id again
313:                _rset = _stmt.executeQuery("select id from x ");
314:                assertNotNull(_rset);
315:                assertTrue(!_rset.next());
316:
317:                //select where id = 1 condition
318:                _rset = _stmt.executeQuery("select id from x where id = 1");
319:                assertNotNull(_rset);
320:                assertTrue(!_rset.next());
321:                _rset.close();
322:
323:                //select where id = 2 condition
324:                _rset = _stmt.executeQuery("select id from x where id = 2");
325:                assertNotNull(_rset);
326:                assertTrue(!_rset.next());
327:                _rset.close();
328:
329:            }
330:
331:            private void selectYAfterTruncate() throws Exception {
332:                //      select id again
333:                _rset = _stmt.executeQuery("select id from y ");
334:                assertNotNull(_rset);
335:                assertTrue(!_rset.next());
336:
337:                //select where id = 1 condition
338:                _rset = _stmt.executeQuery("select id from y where id = 1");
339:                assertNotNull(_rset);
340:                assertTrue(!_rset.next());
341:                _rset.close();
342:
343:                //select where id = 2 condition
344:                _rset = _stmt.executeQuery("select id from y where id = 2");
345:                assertNotNull(_rset);
346:                assertTrue(!_rset.next());
347:                _rset.close();
348:
349:            }
350:
351:            private void selectZAfterTruncate() throws Exception {
352:                //      select id again
353:                _rset = _stmt.executeQuery("select id from z ");
354:                assertNotNull(_rset);
355:                assertTrue(!_rset.next());
356:
357:                //select where id = 1 condition
358:                _rset = _stmt
359:                        .executeQuery("select id from z where id like '1' ");
360:                assertNotNull(_rset);
361:                assertTrue(!_rset.next());
362:                _rset.close();
363:
364:                //select where id = 2 condition
365:                _rset = _stmt
366:                        .executeQuery("select id from z where id like '2' ");
367:                assertNotNull(_rset);
368:                assertTrue(!_rset.next());
369:                _rset.close();
370:
371:            }
372:
373:            private void selectWAfterTruncate() throws Exception {
374:                //      select id again
375:                _rset = _stmt.executeQuery("select id from w ");
376:                assertNotNull(_rset);
377:                assertTrue(!_rset.next());
378:
379:                //select where id = 1 condition
380:                _rset = _stmt
381:                        .executeQuery("select id from w where id like '1' ");
382:                assertNotNull(_rset);
383:                assertTrue(!_rset.next());
384:                _rset.close();
385:
386:                //select where id = 2 condition
387:                _rset = _stmt
388:                        .executeQuery("select id from w where id like '2' ");
389:                assertNotNull(_rset);
390:                assertTrue(!_rset.next());
391:                _rset.close();
392:
393:            }
394:
395:            private static boolean oneExecuted = false;
396:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.