added spring subsystem implementation.
[utils] / support / src / test / java / org / wamblee / test / SpringTestCase.java
index 8b66e0e2419473e240b830108fb843c3efbed599..556bac2af0f1140f541c978b68d8ae1e633b5172 100644 (file)
@@ -21,6 +21,7 @@ import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -139,7 +140,6 @@ public class SpringTestCase extends MockObjectTestCase {
         if (_context == null) {
             _context = new ClassPathXmlApplicationContext(
                     (String[]) _configLocations, _parentContext);
-            assertNotNull(_context);
         }
         return _context;
     }
@@ -453,7 +453,7 @@ public class SpringTestCase extends MockObjectTestCase {
     }
 
     /**
-     * Executes an SQL query within a transaction.
+     * Executes an SQL query.
      * 
      * @param aSql
      *            Query to execute.
@@ -479,7 +479,7 @@ public class SpringTestCase extends MockObjectTestCase {
     }
 
     /**
-     * Executes a query within a transaction. See
+     * Executes a query. See
      * {@link #setPreparedParam(int, PreparedStatement, Object)}for details on
      * supported argument types.
      * 
@@ -490,22 +490,16 @@ public class SpringTestCase extends MockObjectTestCase {
      * @return Result set.
      */
     public ResultSet executeQuery(final String aSql, final Object[] aArgs) {
-        Map results = executeTransaction(new TestTransactionCallback() {
-            public Map execute() throws Exception {
-                Connection connection = getConnection();
-
-                PreparedStatement statement = connection.prepareStatement(aSql);
-                setPreparedParams(aArgs, statement);
+        try {
+                       Connection connection = getConnection();
 
-                ResultSet resultSet = statement.executeQuery();
-                TreeMap results = new TreeMap();
-                results.put("resultSet", resultSet);
+                       PreparedStatement statement = connection.prepareStatement(aSql);
+                       setPreparedParams(aArgs, statement);
 
-                return results;
-            }
-        });
-
-        return (ResultSet) results.get("resultSet");
+                       return statement.executeQuery();
+               } catch (SQLException e) {
+                       throw new RuntimeException(e);
+               }
     }
 
     /**
@@ -576,14 +570,14 @@ public class SpringTestCase extends MockObjectTestCase {
      * @return
      * @throws SQLException
      */
-    protected int getTableSize(String aTable) throws SQLException {
+    protected int getTableSize(final String aTable) throws SQLException {
+
         ResultSet resultSet = executeQuery("select * from " + aTable);
         int count = 0;
 
         while (resultSet.next()) {
             count++;
         }
-
         return count;
     }