Source Code Cross Referenced for Oracle9iDBQueryEngineTest.java in  » Database-Client » DBBrowser » org » dbbrowser » db » engine » queryengine » 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 Client » DBBrowser » org.dbbrowser.db.engine.queryengine 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.dbbrowser.db.engine.queryengine;
002:
003:        import infrastructure.logging.Log;
004:        import java.io.IOException;
005:        import java.sql.Connection;
006:        import java.sql.SQLException;
007:        import java.util.Iterator;
008:        import java.util.List;
009:        import org.dbbrowser.db.engine.exception.DBEngineException;
010:        import org.dbbrowser.db.engine.model.DBTable;
011:        import org.dbbrowser.drivermanager.ConnectionInfo;
012:        import org.dbbrowser.drivermanager.ConnectionInfoSerializer;
013:        import org.dbbrowser.drivermanager.DBBrowserDriverManager;
014:        import org.dbbrowser.drivermanager.DriverManagerException;
015:        import junit.framework.TestCase;
016:
017:        public class Oracle9iDBQueryEngineTest extends TestCase {
018:            private Oracle9iDBQueryEngine oracle9iDBQueryEngine = null;
019:            private static final String SCHEMA_NAME = "XCSSYS";
020:            private static final String TABLE_NAME = "CLAIM";
021:
022:            public Oracle9iDBQueryEngineTest(String name) {
023:                super (name);
024:            }
025:
026:            public void setUp() {
027:                try {
028:                    Log
029:                            .getInstance()
030:                            .debugMessage(
031:                                    "*** Setting up connection for Oracle database *** ",
032:                                    this .getClass().getName());
033:
034:                    //Get the connection info
035:                    List listOfConnectionInfo = ConnectionInfoSerializer
036:                            .deserialize();
037:
038:                    //Get the Oracle connection info
039:                    Iterator i = listOfConnectionInfo.iterator();
040:                    ConnectionInfo ci = null;
041:                    while (i.hasNext()) {
042:                        ConnectionInfo connectionInfo = (ConnectionInfo) i
043:                                .next();
044:                        if (connectionInfo.getName().equals(
045:                                "XCSSYS for Data Migration")) {
046:                            ci = connectionInfo;
047:                            break;
048:                        }
049:                    }
050:
051:                    //Get the connection if connection info is not null
052:                    if (ci != null) {
053:                        Connection conn = DBBrowserDriverManager.getInstance()
054:                                .getConnection(ci, null);
055:
056:                        //Setup the query engine
057:                        oracle9iDBQueryEngine = new Oracle9iDBQueryEngine(conn
058:                                .createStatement());
059:                    } else {
060:                        Log
061:                                .getInstance()
062:                                .fatalMessage(
063:                                        "*** No Connection info found for Oracle database *** ",
064:                                        this .getClass().getName());
065:                        fail("*** No Connection info found for Oracle database *** ");
066:                    }
067:                } catch (ClassNotFoundException exc) {
068:                    Log.getInstance().fatalMessage(
069:                            "*** ClassNotFoundException *** "
070:                                    + exc.getMessage(),
071:                            this .getClass().getName());
072:                    fail(exc.getMessage());
073:                } catch (IOException exc) {
074:                    Log.getInstance().fatalMessage(
075:                            "*** IOException *** " + exc.getMessage(),
076:                            this .getClass().getName());
077:                    fail(exc.getMessage());
078:                } catch (DriverManagerException exc) {
079:                    Log.getInstance().fatalMessage(
080:                            "*** DriverManagerException *** "
081:                                    + exc.getMessage(),
082:                            this .getClass().getName());
083:                    fail(exc.getMessage());
084:                } catch (SQLException exc) {
085:                    Log.getInstance().fatalMessage(
086:                            "*** SQLException *** " + exc.getMessage(),
087:                            this .getClass().getName());
088:                    fail(exc.getMessage());
089:                }
090:            }
091:
092:            public void testGetAllDataInATable() {
093:                try {
094:                    Log.getInstance().debugMessage(
095:                            "*** testCountNumberOfRows for Oracle DBMS *** ",
096:                            this .getClass().getName());
097:
098:                    //Get the number of rows in a table
099:                    Integer rowCount = oracle9iDBQueryEngine.getRowCount(
100:                            SCHEMA_NAME, TABLE_NAME);
101:
102:                    assertTrue("Number of rows in " + TABLE_NAME + " is "
103:                            + rowCount.intValue(), rowCount.intValue() == 663);
104:                } catch (DBEngineException exc) {
105:                    Log.getInstance().fatalMessage(
106:                            "*** DriverManagerException *** "
107:                                    + exc.getMessage(),
108:                            this .getClass().getName());
109:                    fail(exc.getMessage());
110:                }
111:            }
112:
113:            public void testListIndexes() {
114:                try {
115:                    Log.getInstance().debugMessage(
116:                            "*** testListIndexes for Oracle DBMS *** ",
117:                            this .getClass().getName());
118:
119:                    //Get the number of rows in a table
120:                    DBTable table = oracle9iDBQueryEngine.listIndexes();
121:
122:                    assertTrue("Number of indexes is "
123:                            + table.getListOfRows().size(), table
124:                            .getListOfRows().size() == 52);
125:                } catch (DBEngineException exc) {
126:                    Log.getInstance().fatalMessage(
127:                            "*** DriverManagerException *** "
128:                                    + exc.getMessage(),
129:                            this .getClass().getName());
130:                    fail(exc.getMessage());
131:                }
132:            }
133:
134:            public void testCountNumberOfRows() {
135:                try {
136:                    Log.getInstance().debugMessage(
137:                            "*** testCountNumberOfRows for Oracle DBMS *** ",
138:                            this .getClass().getName());
139:
140:                    //Get the number of rows in a table
141:                    Integer rowCount = oracle9iDBQueryEngine.getRowCount(
142:                            SCHEMA_NAME, TABLE_NAME);
143:
144:                    assertTrue("Number of rows in " + TABLE_NAME + " is "
145:                            + rowCount.intValue(), rowCount.intValue() == 663);
146:                } catch (DBEngineException exc) {
147:                    Log.getInstance().fatalMessage(
148:                            "*** DriverManagerException *** "
149:                                    + exc.getMessage(),
150:                            this .getClass().getName());
151:                    fail(exc.getMessage());
152:                }
153:            }
154:
155:            public void testListSchemas() {
156:                try {
157:                    Log.getInstance().debugMessage(
158:                            "*** testListSchemas for Oracle DBMS *** ",
159:                            this .getClass().getName());
160:
161:                    //Get the list of table spaces
162:                    List listOfSchemas = oracle9iDBQueryEngine.listSchemas();
163:
164:                    assertTrue("Schema " + SCHEMA_NAME + " found",
165:                            listOfSchemas.contains(SCHEMA_NAME));
166:                } catch (DBEngineException exc) {
167:                    Log.getInstance().fatalMessage(
168:                            "*** DriverManagerException *** "
169:                                    + exc.getMessage(),
170:                            this .getClass().getName());
171:                    fail(exc.getMessage());
172:                }
173:            }
174:
175:            public void testListConstraints() {
176:                try {
177:                    Log.getInstance().debugMessage(
178:                            "*** testListConstraints for Oracle DBMS *** ",
179:                            this .getClass().getName());
180:
181:                    //Get the list of table spaces
182:                    DBTable tableForConstraints = oracle9iDBQueryEngine
183:                            .listConstraints();
184:
185:                    assertTrue("Number of constraints in " + SCHEMA_NAME
186:                            + " is "
187:                            + tableForConstraints.getListOfRows().size(),
188:                            tableForConstraints.getListOfRows().size() == 203);
189:                } catch (DBEngineException exc) {
190:                    Log.getInstance().fatalMessage(
191:                            "*** DriverManagerException *** "
192:                                    + exc.getMessage(),
193:                            this .getClass().getName());
194:                    fail(exc.getMessage());
195:                }
196:            }
197:
198:            public void testListTablesInSchema() {
199:                try {
200:                    Log.getInstance().debugMessage(
201:                            "*** testListTablesInSchema for Oracle DBMS *** ",
202:                            this .getClass().getName());
203:
204:                    //Get the list of tables
205:                    List listOfTables = oracle9iDBQueryEngine
206:                            .listTablesInSchema(SCHEMA_NAME);
207:
208:                    assertTrue("Table " + TABLE_NAME + " found in schema "
209:                            + SCHEMA_NAME, listOfTables.contains(TABLE_NAME));
210:                } catch (DBEngineException exc) {
211:                    Log.getInstance().fatalMessage(
212:                            "*** DriverManagerException *** "
213:                                    + exc.getMessage(),
214:                            this .getClass().getName());
215:                    fail(exc.getMessage());
216:                }
217:            }
218:
219:            /*public void testGetAllFilteredDataInATable()
220:            {
221:            	try
222:            	{
223:            		Log.getInstance().debugMessage("*** testGetAllFilteredDataInATable for Oracle DBMS *** ", this.getClass().getName());
224:
225:                    //Build the filters
226:                    ColumnInfo ci1 = new ColumnInfo("UCR", ColumnInfo.COLUMN_TYPE_VARCHAR, "java.lang.String", new Integer(17), ColumnInfo.COLUMN_NULLABLE, Boolean.FALSE, Boolean.FALSE, Boolean.TRUE, null);
227:                    DBTableCell dbTableCell1 = new DBTableCell(ci1, "B0423LINKED1", Boolean.FALSE);
228:                    ColumnInfo ci2 = new ColumnInfo("client_name", ColumnInfo.COLUMN_TYPE_VARCHAR, "java.lang.String", new Integer(17), ColumnInfo.COLUMN_NULLABLE, Boolean.FALSE, Boolean.FALSE, Boolean.TRUE, null);
229:                    DBTableCell dbTableCell2 = new DBTableCell(ci2, "Ascot", Boolean.FALSE);
230:
231:                    List listOfFilters = new ArrayList();
232:                    listOfFilters.add( dbTableCell1 );
233:                    listOfFilters.add( dbTableCell2 );
234:
235:                    //Get the data in the form of a dbtable
236:                	DBTable dbTable = oracle9iDBQueryEngine.testGetAllFilteredDataInATable(SCHEMA_NAME, TABLE_NAME, listOfFilters);
237:                    Log.getInstance().debugMessage("List of rows size is: " + dbTable.getListOfRows().size(), this.getClass().getName());
238:
239:                    assertTrue("Should return 1 record", dbTable.getListOfRows().size() == 1);
240:                }
241:            	catch(DBEngineException exc)
242:            	{
243:                    Log.getInstance().fatalMessage("*** DBEngineException *** " + exc.getMessage(), this.getClass().getName());
244:                    fail(exc.getMessage());        	    		
245:            	}    	
246:            }*/
247:
248:            public void testGetPrimaryKeyColumnNames() {
249:                try {
250:                    Log
251:                            .getInstance()
252:                            .debugMessage(
253:                                    "*** testGetPrimaryKeyColumnNames for Oracle DBMS *** ",
254:                                    this .getClass().getName());
255:
256:                    //Get the primary keys for the table
257:                    List listOfPrimaryKeyColumnNames = oracle9iDBQueryEngine
258:                            .getPrimaryKeyColumnNames(SCHEMA_NAME, TABLE_NAME);
259:                    assertTrue("List of primary key in table " + TABLE_NAME
260:                            + " should be 1", listOfPrimaryKeyColumnNames
261:                            .size() == 1);
262:                } catch (DBEngineException exc) {
263:                    Log.getInstance().fatalMessage(
264:                            "*** DBEngineException *** " + exc.getMessage(),
265:                            this .getClass().getName());
266:                    fail(exc.getMessage());
267:                }
268:            }
269:
270:            public void testListColumnsInATable() {
271:                try {
272:                    Log.getInstance().debugMessage(
273:                            "*** testListColumnsInATable for Oracle DBMS *** ",
274:                            this .getClass().getName());
275:
276:                    //Get the list of columns in the table
277:                    List listColumnInfos = oracle9iDBQueryEngine
278:                            .listColumnsInATable(SCHEMA_NAME, TABLE_NAME);
279:                    assertTrue("List of columns in table " + TABLE_NAME
280:                            + " should be 52", listColumnInfos.size() == 55);
281:                } catch (DBEngineException exc) {
282:                    Log.getInstance().fatalMessage(
283:                            "*** DBEngineException *** " + exc.getMessage(),
284:                            this.getClass().getName());
285:                    fail(exc.getMessage());
286:                }
287:            }
288:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.