Source Code Cross Referenced for MySQLDBQueryEngineTest.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 junit.framework.TestCase;
010:        import org.dbbrowser.db.engine.exception.DBEngineException;
011:        import org.dbbrowser.db.engine.model.DBTable;
012:        import org.dbbrowser.db.engine.queryengine.MySQLDBQueryEngine;
013:        import org.dbbrowser.drivermanager.ConnectionInfo;
014:        import org.dbbrowser.drivermanager.ConnectionInfoSerializer;
015:        import org.dbbrowser.drivermanager.DBBrowserDriverManager;
016:        import org.dbbrowser.drivermanager.DriverManagerException;
017:        import org.dbbrowser.ui.UIControllerForQueries;
018:
019:        public class MySQLDBQueryEngineTest extends TestCase {
020:            private MySQLDBQueryEngine mySQLDBQueryEngine = null;
021:            private static final String SCHEMA_NAME = "hww";
022:            private static final String TABLE_NAME = "customer";
023:
024:            public MySQLDBQueryEngineTest(String name) {
025:                super (name);
026:            }
027:
028:            public void setUp() {
029:                try {
030:                    Log
031:                            .getInstance()
032:                            .debugMessage(
033:                                    "*** Setting up connection for mySQL database *** ",
034:                                    this .getClass().getName());
035:
036:                    //Get the connection info
037:                    List listOfConnectionInfo = ConnectionInfoSerializer
038:                            .deserialize();
039:
040:                    //Get the first mysql connection info
041:                    Iterator i = listOfConnectionInfo.iterator();
042:                    ConnectionInfo ci = null;
043:                    while (i.hasNext()) {
044:                        ConnectionInfo connectionInfo = (ConnectionInfo) i
045:                                .next();
046:                        if (connectionInfo.getDBMSType().equals(
047:                                UIControllerForQueries.MYSQL_DBMS)) {
048:                            ci = connectionInfo;
049:                            break;
050:                        }
051:                    }
052:
053:                    //Get the connection if connection info is not null
054:                    if (ci != null) {
055:                        Connection conn = DBBrowserDriverManager.getInstance()
056:                                .getConnection(ci, null);
057:
058:                        //Setup the query engine
059:                        mySQLDBQueryEngine = new MySQLDBQueryEngine(conn
060:                                .createStatement());
061:                    } else {
062:                        Log
063:                                .getInstance()
064:                                .fatalMessage(
065:                                        "*** No Connection info found for MySQL database *** ",
066:                                        this .getClass().getName());
067:                        fail("*** No Connection info found for mySQL database *** ");
068:                    }
069:                } catch (ClassNotFoundException exc) {
070:                    Log.getInstance().fatalMessage(
071:                            "*** ClassNotFoundException *** "
072:                                    + exc.getMessage(),
073:                            this .getClass().getName());
074:                    fail(exc.getMessage());
075:                } catch (IOException exc) {
076:                    Log.getInstance().fatalMessage(
077:                            "*** IOException *** " + exc.getMessage(),
078:                            this .getClass().getName());
079:                    fail(exc.getMessage());
080:                } catch (DriverManagerException exc) {
081:                    Log.getInstance().fatalMessage(
082:                            "*** DriverManagerException *** "
083:                                    + exc.getMessage(),
084:                            this .getClass().getName());
085:                    fail(exc.getMessage());
086:                } catch (SQLException exc) {
087:                    Log.getInstance().fatalMessage(
088:                            "*** SQLException *** " + exc.getMessage(),
089:                            this .getClass().getName());
090:                    fail(exc.getMessage());
091:                }
092:            }
093:
094:            public void testListSchemas() {
095:                try {
096:                    Log.getInstance().debugMessage(
097:                            "*** testListSchemas mySQL database *** ",
098:                            this .getClass().getName());
099:
100:                    //Get the list of table spaces
101:                    List listOfSchemas = mySQLDBQueryEngine.listSchemas();
102:
103:                    assertTrue("Schema " + SCHEMA_NAME + " found",
104:                            listOfSchemas.contains(SCHEMA_NAME));
105:                } catch (DBEngineException exc) {
106:                    Log.getInstance().fatalMessage(
107:                            "*** DBEngineException *** " + 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 mySQL database *** ",
117:                            this .getClass().getName());
118:
119:                    //Get the list of table spaces
120:                    DBTable tableForIndexes = mySQLDBQueryEngine.listIndexes();
121:
122:                    assertTrue("MySQL database has "
123:                            + tableForIndexes.getListOfColumnInfos().size()
124:                            + " columns, should be 13", tableForIndexes
125:                            .getListOfColumnInfos().size() == 13);
126:                } catch (DBEngineException exc) {
127:                    Log.getInstance().fatalMessage(
128:                            "*** DBEngineException *** " + exc.getMessage(),
129:                            this .getClass().getName());
130:                    fail(exc.getMessage());
131:                }
132:            }
133:
134:            public void testListTablesInSchema() {
135:                try {
136:                    Log
137:                            .getInstance()
138:                            .debugMessage(
139:                                    "*** testListTablesInSchema for mySQL database *** ",
140:                                    this .getClass().getName());
141:
142:                    //Get the list of tables
143:                    List listOfTables = mySQLDBQueryEngine
144:                            .listTablesInSchema(SCHEMA_NAME);
145:
146:                    assertTrue("Table " + TABLE_NAME + " found in schema "
147:                            + SCHEMA_NAME, listOfTables.contains(TABLE_NAME));
148:                } catch (DBEngineException exc) {
149:                    Log.getInstance().fatalMessage(
150:                            "*** DBEngineException *** " + exc.getMessage(),
151:                            this .getClass().getName());
152:                    fail(exc.getMessage());
153:                }
154:            }
155:
156:            public void testGetAllDataInATable() {
157:                try {
158:                    Log
159:                            .getInstance()
160:                            .debugMessage(
161:                                    "*** testGetAllDataInATable for mySQL database *** ",
162:                                    this .getClass().getName());
163:
164:                    //Get the data in the form of a dbtable
165:                    DBTable dbTable = mySQLDBQueryEngine.getAllDataInATable(
166:                            SCHEMA_NAME, TABLE_NAME, new Integer(0),
167:                            new Integer(100));
168:                } catch (DBEngineException exc) {
169:                    Log.getInstance().fatalMessage(
170:                            "*** DBEngineException *** " + exc.getMessage(),
171:                            this .getClass().getName());
172:                    fail(exc.getMessage());
173:                }
174:            }
175:
176:            public void testGetPrimaryKeyColumnNames() {
177:                try {
178:                    Log
179:                            .getInstance()
180:                            .debugMessage(
181:                                    "*** testGetPrimaryKeyColumnNames for MySQL DBMS *** ",
182:                                    this .getClass().getName());
183:
184:                    //Get the primary keys for the table
185:                    List listOfPrimaryKeyColumnNames = mySQLDBQueryEngine
186:                            .getPrimaryKeyColumnNames(SCHEMA_NAME, TABLE_NAME);
187:                    assertTrue("List of primary key in table " + TABLE_NAME
188:                            + "should be 1",
189:                            listOfPrimaryKeyColumnNames.size() == 1);
190:                } catch (DBEngineException exc) {
191:                    Log.getInstance().fatalMessage(
192:                            "*** DBEngineException *** " + exc.getMessage(),
193:                            this .getClass().getName());
194:                    fail(exc.getMessage());
195:                }
196:            }
197:
198:            public void testListColumnsInATable() {
199:                try {
200:                    Log.getInstance().debugMessage(
201:                            "*** testListColumnsInATable for MySQL DBMS *** ",
202:                            this .getClass().getName());
203:
204:                    //Get the list of columns in the table
205:                    List listColumnInfos = mySQLDBQueryEngine
206:                            .listColumnsInATable(SCHEMA_NAME, TABLE_NAME);
207:                    assertTrue("List of columns in table " + TABLE_NAME
208:                            + "should be 13", listColumnInfos.size() == 13);
209:                } catch (DBEngineException exc) {
210:                    Log.getInstance().fatalMessage(
211:                            "*** DBEngineException *** " + exc.getMessage(),
212:                            this.getClass().getName());
213:                    fail(exc.getMessage());
214:                }
215:            }
216:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.