Source Code Cross Referenced for OracleGenericRawSQLEngineAutoCommitOffTest.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 OracleGenericRawSQLEngineAutoCommitOffTest extends
019:                TestCase {
020:            private GenericRawSQLEngine genericRawSQLEngine = null;
021:            private Connection conn = null;
022:
023:            public OracleGenericRawSQLEngineAutoCommitOffTest(String name) {
024:                super (name);
025:            }
026:
027:            public void setUp() {
028:                try {
029:                    Log
030:                            .getInstance()
031:                            .debugMessage(
032:                                    "*** Setting up connection for Oracle database *** ",
033:                                    this .getClass().getName());
034:
035:                    //Get the connection info
036:                    List listOfConnectionInfo = ConnectionInfoSerializer
037:                            .deserialize();
038:
039:                    //Get the Oracle connection info
040:                    Iterator i = listOfConnectionInfo.iterator();
041:                    ConnectionInfo ci = null;
042:                    while (i.hasNext()) {
043:                        ConnectionInfo connectionInfo = (ConnectionInfo) i
044:                                .next();
045:                        if (connectionInfo.getName().equals("Oracle PPDB")) {
046:                            ci = connectionInfo;
047:                            break;
048:                        }
049:                    }
050:
051:                    //Get the connection if connection info is not null
052:                    if (ci != null) {
053:                        this .conn = DBBrowserDriverManager.getInstance()
054:                                .getConnection(ci, null);
055:
056:                        //Setup the update engine
057:                        genericRawSQLEngine = new GenericRawSQLEngine(conn
058:                                .createStatement());
059:
060:                        //Set autocommit off
061:                        conn.setAutoCommit(false);
062:                    } else {
063:                        Log
064:                                .getInstance()
065:                                .fatalMessage(
066:                                        "*** No Connection info found for Oracle database *** ",
067:                                        this .getClass().getName());
068:                        fail("*** No Connection info found for Oracle database *** ");
069:                    }
070:                } catch (ClassNotFoundException exc) {
071:                    Log.getInstance().fatalMessage(
072:                            "*** ClassNotFoundException *** "
073:                                    + exc.getMessage(),
074:                            this .getClass().getName());
075:                    fail(exc.getMessage());
076:                } catch (IOException exc) {
077:                    Log.getInstance().fatalMessage(
078:                            "*** IOException *** " + exc.getMessage(),
079:                            this .getClass().getName());
080:                    fail(exc.getMessage());
081:                } catch (DriverManagerException exc) {
082:                    Log.getInstance().fatalMessage(
083:                            "*** DriverManagerException *** "
084:                                    + exc.getMessage(),
085:                            this .getClass().getName());
086:                    fail(exc.getMessage());
087:                } catch (SQLException exc) {
088:                    Log.getInstance().fatalMessage(
089:                            "*** SQLException *** " + exc.getMessage(),
090:                            this .getClass().getName());
091:                    fail(exc.getMessage());
092:                }
093:            }
094:
095:            public void testRunRawSelectSQLStatement() {
096:                try {
097:                    Log
098:                            .getInstance()
099:                            .debugMessage(
100:                                    "*** GenericRawSQLEngineTest.testRunRawSelectSQLStatement *** ",
101:                                    this .getClass().getName());
102:
103:                    DBTable dbTable = this .genericRawSQLEngine
104:                            .runRawSQL("select count(*) from claim_experts");
105:                    assertTrue("Number of rows should be 1", dbTable
106:                            .getNumberOfRowsInTable().intValue() == 1);
107:                } catch (DBEngineException exc) {
108:                    Log.getInstance().fatalMessage(
109:                            "*** DBEngineException *** " + exc.getMessage(),
110:                            this .getClass().getName());
111:                    fail(exc.getMessage());
112:                }
113:            }
114:
115:            public void testRunRawInsertSQLStatement() {
116:                try {
117:                    Log
118:                            .getInstance()
119:                            .debugMessage(
120:                                    "*** GenericRawSQLEngineTest.testRunRawInsertSQLStatement *** ",
121:                                    this .getClass().getName());
122:
123:                    String sql = "insert into CLAIM_EXPERTS (ID, CLAIM_ID, EXPERT_ID) "
124:                            + "values ( CLAIM_EXPERTS_SEQ.nextval, 4, 15)";
125:                    DBTable dbTable = this .genericRawSQLEngine.runRawSQL(sql);
126:                    assertTrue("DBTable should be null", dbTable == null);
127:                    this .conn.commit();
128:                } catch (DBEngineException exc) {
129:                    Log.getInstance().fatalMessage(
130:                            "*** DBEngineException *** " + exc.getMessage(),
131:                            this .getClass().getName());
132:                    fail(exc.getMessage());
133:                } catch (SQLException exc) {
134:                    Log.getInstance().fatalMessage(
135:                            "*** SQLException *** " + exc.getMessage(),
136:                            this .getClass().getName());
137:                    fail(exc.getMessage());
138:                }
139:            }
140:
141:            public void testRunRawUpdateSQLStatement() {
142:                try {
143:                    Log
144:                            .getInstance()
145:                            .debugMessage(
146:                                    "*** GenericRawSQLEngineTest.testRunRawUpdateSQLStatement *** ",
147:                                    this .getClass().getName());
148:
149:                    DBTable dbTable = this .genericRawSQLEngine
150:                            .runRawSQL("update CLAIM_EXPERTS set individual_name = 'Updated by JUnit' where CLAIM_ID=534");
151:                    assertTrue(
152:                            "GenericRawSQLEngineTest.testRunRawUpdateSQLStatement should be null",
153:                            dbTable == null);
154:                    this .conn.commit();
155:                } catch (DBEngineException exc) {
156:                    Log.getInstance().fatalMessage(
157:                            "*** DBEngineException *** " + exc.getMessage(),
158:                            this .getClass().getName());
159:                    fail(exc.getMessage());
160:                } catch (SQLException exc) {
161:                    Log.getInstance().fatalMessage(
162:                            "*** SQLException *** " + exc.getMessage(),
163:                            this .getClass().getName());
164:                    fail(exc.getMessage());
165:                }
166:            }
167:
168:            public void testRunRawDeleteSQLStatement() {
169:                try {
170:                    Log
171:                            .getInstance()
172:                            .debugMessage(
173:                                    "*** GenericRawSQLEngineTest.testRunRawDeleteSQLStatement *** ",
174:                                    this .getClass().getName());
175:
176:                    DBTable dbTable = this .genericRawSQLEngine
177:                            .runRawSQL("delete from CLAIM_EXPERTS where CLAIM_ID=534");
178:                    assertTrue(
179:                            "GenericRawSQLEngineTest.testRunRawDeleteSQLStatement should be null",
180:                            dbTable == null);
181:                    this .conn.commit();
182:                } catch (DBEngineException exc) {
183:                    Log.getInstance().fatalMessage(
184:                            "*** DBEngineException *** " + exc.getMessage(),
185:                            this .getClass().getName());
186:                    fail(exc.getMessage());
187:                } catch (SQLException exc) {
188:                    Log.getInstance().fatalMessage(
189:                            "*** SQLException *** " + exc.getMessage(),
190:                            this .getClass().getName());
191:                    fail(exc.getMessage());
192:                }
193:            }
194:
195:            public void testRunRawAddColumnSQLStatement() {
196:                try {
197:                    Log
198:                            .getInstance()
199:                            .debugMessage(
200:                                    "*** GenericRawSQLEngineTest.testRunRawAddColumnSQLStatement *** ",
201:                                    this .getClass().getName());
202:
203:                    DBTable dbTable = this .genericRawSQLEngine
204:                            .runRawSQL("alter table CLAIM_EXPERTS add test_column varchar(10)");
205:                    assertTrue(
206:                            "GenericRawSQLEngineTest.testRunRawAlterTableSQLStatement should be null",
207:                            dbTable == null);
208:                    this .conn.commit();
209:                } catch (DBEngineException exc) {
210:                    Log.getInstance().fatalMessage(
211:                            "*** DBEngineException *** " + exc.getMessage(),
212:                            this .getClass().getName());
213:                    fail(exc.getMessage());
214:                } catch (SQLException exc) {
215:                    Log.getInstance().fatalMessage(
216:                            "*** SQLException *** " + exc.getMessage(),
217:                            this .getClass().getName());
218:                    fail(exc.getMessage());
219:                }
220:            }
221:
222:            public void testRunRawDropColumnSQLStatement() {
223:                try {
224:                    Log
225:                            .getInstance()
226:                            .debugMessage(
227:                                    "*** GenericRawSQLEngineTest.testRunRawDropColumnSQLStatement *** ",
228:                                    this .getClass().getName());
229:
230:                    DBTable dbTable = this .genericRawSQLEngine
231:                            .runRawSQL("alter table CLAIM_EXPERTS drop column test_column");
232:                    assertTrue(
233:                            "GenericRawSQLEngineTest.testRunRawAlterTableSQLStatement should be null",
234:                            dbTable == null);
235:                    this .conn.commit();
236:                } catch (DBEngineException exc) {
237:                    Log.getInstance().fatalMessage(
238:                            "*** DBEngineException *** " + exc.getMessage(),
239:                            this .getClass().getName());
240:                    fail(exc.getMessage());
241:                } catch (SQLException exc) {
242:                    Log.getInstance().fatalMessage(
243:                            "*** SQLException *** " + exc.getMessage(),
244:                            this .getClass().getName());
245:                    fail(exc.getMessage());
246:                }
247:            }
248:
249:            public void testStripComments() {
250:                Log.getInstance().debugMessage(
251:                        "*** GenericRawSQLEngineTest.testStripComments *** ",
252:                        this .getClass().getName());
253:
254:                String sql = this .genericRawSQLEngine
255:                        .stripComments("alter table CLAIM_EXPERTS /*Test comments*/drop column test_column");
256:                assertTrue(
257:                        "GenericRawSQLEngineTest.testStripComments sql is incorrect",
258:                        "alter table CLAIM_EXPERTS drop column test_column"
259:                                .equals(sql));
260:            }
261:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.