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