Upgraded to jmock 2.4.0 from 1.1.0
[utils] / support / src / test / java / org / wamblee / test / SpringTestCase.java
index 8b66e0e2419473e240b830108fb843c3efbed599..9e25caaf8785291a3cbecf2a1872e659cbd18258 100644 (file)
@@ -41,7 +41,6 @@ import org.dbunit.dataset.IDataSet;
 import org.dbunit.dataset.filter.ITableFilter;
 import org.dbunit.operation.DatabaseOperation;
 import org.hibernate.SessionFactory;
-import org.jmock.cglib.MockObjectTestCase;
 import org.springframework.beans.factory.NoSuchBeanDefinitionException;
 import org.springframework.beans.factory.config.BeanDefinition;
 import org.springframework.beans.factory.support.RootBeanDefinition;
@@ -65,7 +64,7 @@ import org.wamblee.persistence.hibernate.HibernateMappingFiles;
 /**
  * Test case support class for spring tests.
  */
-public class SpringTestCase extends MockObjectTestCase {
+public class SpringTestCase extends TestCase {
 
     private static final Log LOG = LogFactory.getLog(SpringTestCase.class);
 
@@ -139,7 +138,6 @@ public class SpringTestCase extends MockObjectTestCase {
         if (_context == null) {
             _context = new ClassPathXmlApplicationContext(
                     (String[]) _configLocations, _parentContext);
-            assertNotNull(_context);
         }
         return _context;
     }
@@ -453,7 +451,7 @@ public class SpringTestCase extends MockObjectTestCase {
     }
 
     /**
-     * Executes an SQL query within a transaction.
+     * Executes an SQL query.
      * 
      * @param aSql
      *            Query to execute.
@@ -479,7 +477,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 +488,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 +568,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;
     }