[teiid-commits] teiid SVN: r1293 - trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/api.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Fri Aug 28 19:08:58 EDT 2009


Author: vhalbert at redhat.com
Date: 2009-08-28 19:08:57 -0400 (Fri, 28 Aug 2009)
New Revision: 1293

Modified:
   trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/api/AbstractQueryTest.java
Log:
Teiid-777 :  consolidating the core logic for executing sql against a connection 

Modified: trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/api/AbstractQueryTest.java
===================================================================
--- trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/api/AbstractQueryTest.java	2009-08-28 22:42:55 UTC (rev 1292)
+++ trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/api/AbstractQueryTest.java	2009-08-28 23:08:57 UTC (rev 1293)
@@ -59,8 +59,21 @@
     protected Connection internalConnection = null;
     protected ResultSet internalResultSet = null;
     protected Statement internalStatement = null;
+    private SQLException internalException = null;
     protected int updateCount = -1;
     protected String DELIMITER = "    "; //$NON-NLS-1$ 
+    
+    public AbstractQueryTest() {
+    	super();
+    }
+    
+    
+    public AbstractQueryTest(Connection conn) {
+    	super();
+        this.internalConnection = conn;
+        
+    }
+    
      
     @After public void tearDown() throws Exception {
     	closeConnection();
@@ -118,8 +131,12 @@
             }
             return result;
         } catch (SQLException e) {
-            throw new RuntimeException(e);
-        }        
+            this.internalException = e;
+            if (!exceptionExpected()) {
+            	throw new RuntimeException(e);
+            }            
+        } 
+        return false;
     }
             
     private void setParameters(PreparedStatement stmt, Object[] params) throws SQLException{
@@ -159,8 +176,13 @@
             return this.internalStatement.executeBatch();
              
         } catch (SQLException e) {
-            throw new RuntimeException(e);
-        }
+            this.internalException = e;
+            if (!exceptionExpected()) {
+            	throw new RuntimeException(e);
+            }
+       }
+        
+        return null;
 
     }
     
@@ -181,8 +203,21 @@
     
     protected void assignExecutionProperties(Statement stmt) {
     }
-
     
+    
+    public boolean exceptionOccurred() {
+        return this.internalException != null;
+    }
+    
+    public boolean exceptionExpected() {
+        return false;
+    }
+    
+    
+    public SQLException getLastException() {
+        return this.internalException;
+    }
+    
     public void assertResultsSetEquals(File expected) {
     	assertResultsSetEquals(this.internalResultSet, expected);
     }
@@ -436,6 +471,8 @@
     }
 
     public void closeResultSet() {
+        this.internalException = null;
+
         if (this.internalResultSet != null) {        
             try {
                 this.internalResultSet.close();                
@@ -462,6 +499,13 @@
         }
     }
     
+    public void cancelQuery() throws SQLException {
+        assertNotNull(this.internalConnection);
+        assertTrue(!this.internalConnection.isClosed());
+        assertNotNull(this.internalStatement);
+        this.internalStatement.cancel();    
+    }  
+    
     public void print(String msg) {
         System.out.println(msg);
     }



More information about the teiid-commits mailing list