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


001:        package org.dbbrowser.db.engine.rawsqlengine;
002:
003:        import junit.framework.TestCase;
004:        import org.dbbrowser.db.engine.exception.DBEngineException;
005:        import org.dbbrowser.db.engine.model.DBTable;
006:        import org.dbbrowser.db.engine.rawsqlengine.GenericRawSQLEngine;
007:        import org.dbbrowser.drivermanager.ConnectionInfoSerializer;
008:        import org.dbbrowser.drivermanager.ConnectionInfo;
009:        import org.dbbrowser.drivermanager.DBBrowserDriverManager;
010:        import org.dbbrowser.drivermanager.DriverManagerException;
011:        import infrastructure.logging.Log;
012:        import java.util.List;
013:        import java.util.Iterator;
014:        import java.sql.Connection;
015:        import java.sql.SQLException;
016:        import java.io.IOException;
017:
018:        public class MySQLGenericRawSQLEngineAutoCommitOffTest extends TestCase {
019:            private GenericRawSQLEngine genericRawSQLEngine = null;
020:            private Connection conn = null;
021:
022:            public MySQLGenericRawSQLEngineAutoCommitOffTest(String name) {
023:                super (name);
024:            }
025:
026:            public void setUp() {
027:                try {
028:                    Log
029:                            .getInstance()
030:                            .debugMessage(
031:                                    "*** Setting up connection for MySQL 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("HWW on MySQL")) {
045:                            ci = connectionInfo;
046:                            break;
047:                        }
048:                    }
049:
050:                    //Get the connection if connection info is not null
051:                    if (ci != null) {
052:                        this .conn = DBBrowserDriverManager.getInstance()
053:                                .getConnection(ci, null);
054:
055:                        //Setup the update engine
056:                        genericRawSQLEngine = new GenericRawSQLEngine(conn
057:                                .createStatement());
058:
059:                        //Set autocommit off
060:                        conn.setAutoCommit(false);
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 testRunRawSelectSQLStatement() {
095:                try {
096:                    Log
097:                            .getInstance()
098:                            .debugMessage(
099:                                    "*** MySQLGenericRawSQLEngineAutoCommitOffTest.testRunRawSelectSQLStatement *** ",
100:                                    this .getClass().getName());
101:
102:                    DBTable dbTable = this .genericRawSQLEngine
103:                            .runRawSQL("select count(*) from hww.customer");
104:                    assertTrue("Number of rows should be 1", dbTable
105:                            .getNumberOfRowsInTable().intValue() == 1);
106:                } catch (DBEngineException exc) {
107:                    Log.getInstance().fatalMessage(
108:                            "*** DBEngineException *** " + exc.getMessage(),
109:                            this .getClass().getName());
110:                    fail(exc.getMessage());
111:                }
112:            }
113:
114:            public void testRunRawInsertSQLStatement() {
115:                try {
116:                    Log
117:                            .getInstance()
118:                            .debugMessage(
119:                                    "*** MySQLGenericRawSQLEngineAutoCommitOffTest.testRunRawInsertSQLStatement *** ",
120:                                    this .getClass().getName());
121:
122:                    String sql = "insert into hww.customer (pk_customerid, last_updated_at, last_updated_by "
123:                            + ") values ( 3, '2005-10-21', 'JUnit')";
124:                    DBTable dbTable = this .genericRawSQLEngine.runRawSQL(sql);
125:                    assertTrue("DBTable should be null", dbTable == null);
126:                    this .conn.commit();
127:                } catch (DBEngineException exc) {
128:                    Log.getInstance().fatalMessage(
129:                            "*** DBEngineException *** " + exc.getMessage(),
130:                            this .getClass().getName());
131:                    fail(exc.getMessage());
132:                } catch (SQLException exc) {
133:                    Log.getInstance().fatalMessage(
134:                            "*** SQLException *** " + exc.getMessage(),
135:                            this .getClass().getName());
136:                    fail(exc.getMessage());
137:                }
138:            }
139:
140:            public void testRunRawUpdateSQLStatement() {
141:                try {
142:                    Log
143:                            .getInstance()
144:                            .debugMessage(
145:                                    "*** MySQLGenericRawSQLEngineAutoCommitOffTest.testRunRawUpdateSQLStatement *** ",
146:                                    this .getClass().getName());
147:
148:                    DBTable dbTable = this .genericRawSQLEngine
149:                            .runRawSQL("update hww.customer set firstname = 'JUnit' where pk_customerid=3");
150:                    assertTrue(
151:                            "MySQLGenericRawSQLEngineAutoCommitOffTest.testRunRawUpdateSQLStatement should be null",
152:                            dbTable == null);
153:                    this .conn.commit();
154:                } catch (DBEngineException exc) {
155:                    Log.getInstance().fatalMessage(
156:                            "*** DBEngineException *** " + exc.getMessage(),
157:                            this .getClass().getName());
158:                    fail(exc.getMessage());
159:                } catch (SQLException exc) {
160:                    Log.getInstance().fatalMessage(
161:                            "*** SQLException *** " + exc.getMessage(),
162:                            this .getClass().getName());
163:                    fail(exc.getMessage());
164:                }
165:            }
166:
167:            public void testRunRawDeleteSQLStatement() {
168:                try {
169:                    Log
170:                            .getInstance()
171:                            .debugMessage(
172:                                    "*** MySQLGenericRawSQLEngineAutoCommitOffTest.testRunRawDeleteSQLStatement *** ",
173:                                    this .getClass().getName());
174:
175:                    DBTable dbTable = this .genericRawSQLEngine
176:                            .runRawSQL("delete from hww.customer where pk_customerid=3");
177:                    assertTrue(
178:                            "MySQLGenericRawSQLEngineAutoCommitOffTest.testRunRawDeleteSQLStatement should be null",
179:                            dbTable == null);
180:                    this .conn.commit();
181:                } catch (DBEngineException exc) {
182:                    Log.getInstance().fatalMessage(
183:                            "*** DBEngineException *** " + exc.getMessage(),
184:                            this .getClass().getName());
185:                    fail(exc.getMessage());
186:                } catch (SQLException exc) {
187:                    Log.getInstance().fatalMessage(
188:                            "*** SQLException *** " + exc.getMessage(),
189:                            this .getClass().getName());
190:                    fail(exc.getMessage());
191:                }
192:            }
193:
194:            public void testRunRawAddColumnSQLStatement() {
195:                try {
196:                    Log
197:                            .getInstance()
198:                            .debugMessage(
199:                                    "*** MySQLGenericRawSQLEngineAutoCommitOffTest.testRunRawAddColumnSQLStatement *** ",
200:                                    this .getClass().getName());
201:
202:                    DBTable dbTable = this .genericRawSQLEngine
203:                            .runRawSQL("alter table hww.customer add test_column varchar(10)");
204:                    assertTrue(
205:                            "MySQLGenericRawSQLEngineAutoCommitOffTest.testRunRawAlterTableSQLStatement should be null",
206:                            dbTable == null);
207:                    this .conn.commit();
208:                } catch (DBEngineException exc) {
209:                    Log.getInstance().fatalMessage(
210:                            "*** DBEngineException *** " + exc.getMessage(),
211:                            this .getClass().getName());
212:                    fail(exc.getMessage());
213:                } catch (SQLException exc) {
214:                    Log.getInstance().fatalMessage(
215:                            "*** SQLException *** " + exc.getMessage(),
216:                            this .getClass().getName());
217:                    fail(exc.getMessage());
218:                }
219:            }
220:
221:            public void testRunRawDropColumnSQLStatement() {
222:                try {
223:                    Log
224:                            .getInstance()
225:                            .debugMessage(
226:                                    "*** MySQLGenericRawSQLEngineAutoCommitOffTest.testRunRawDropColumnSQLStatement *** ",
227:                                    this .getClass().getName());
228:
229:                    DBTable dbTable = this .genericRawSQLEngine
230:                            .runRawSQL("alter table hww.customer drop column test_column");
231:                    assertTrue(
232:                            "MySQLGenericRawSQLEngineAutoCommitOffTest.testRunRawAlterTableSQLStatement should be null",
233:                            dbTable == null);
234:                    this .conn.commit();
235:                } catch (DBEngineException exc) {
236:                    Log.getInstance().fatalMessage(
237:                            "*** DBEngineException *** " + exc.getMessage(),
238:                            this .getClass().getName());
239:                    fail(exc.getMessage());
240:                } catch (SQLException exc) {
241:                    Log.getInstance().fatalMessage(
242:                            "*** SQLException *** " + exc.getMessage(),
243:                            this .getClass().getName());
244:                    fail(exc.getMessage());
245:                }
246:            }
247:
248:            public void testStripComments() {
249:                Log
250:                        .getInstance()
251:                        .debugMessage(
252:                                "*** MySQLGenericRawSQLEngineAutoCommitOffTest.testStripComments *** ",
253:                                this .getClass().getName());
254:
255:                String sql = this .genericRawSQLEngine
256:                        .stripComments("alter table CLAIM_EXPERTS /*Test comments*/drop column test_column");
257:                assertTrue(
258:                        "GenericRawSQLEngineTest.testStripComments sql is incorrect",
259:                        "alter table CLAIM_EXPERTS drop column test_column"
260:                                .equals(sql));
261:            }
262:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.