You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ibatis.apache.org by cb...@apache.org on 2008/10/26 22:39:35 UTC

svn commit: r708047 - in /ibatis/trunk/java/ibatis-3: ibatis-3-core/src/main/java/org/apache/ibatis/metadata/ ibatis-3-core/src/test/java/org/apache/ibatis/ ibatis-3-core/src/test/java/org/apache/ibatis/executor/ ibatis-3-core/src/test/java/org/apache/...

Author: cbegin
Date: Sun Oct 26 14:39:35 2008
New Revision: 708047

URL: http://svn.apache.org/viewvc?rev=708047&view=rev
Log:
refactored test pools

Modified:
    ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/metadata/DatabaseFactory.java
    ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/BaseDataTest.java
    ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/executor/BaseExecutorTest.java
    ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/jdbc/ScriptRunnerTest.java
    ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/jdbc/SqlRunnerTest.java
    ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/metadata/MetadataTest.java
    ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/MigratorTest.java
    ibatis/trunk/java/ibatis-3/ibatis-3-monarch/src/test/java/org/apache/ibatis/monarch/builder/MapperConfigParserTest.java

Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/metadata/DatabaseFactory.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/metadata/DatabaseFactory.java?rev=708047&r1=708046&r2=708047&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/metadata/DatabaseFactory.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/metadata/DatabaseFactory.java Sun Oct 26 14:39:35 2008
@@ -50,7 +50,8 @@
       }
 
     } finally {
-      conn.close();
+      try { conn.rollback(); } catch (Exception e) { /*ignore*/ }
+      try { conn.close(); } catch (Exception e) { /*ignore*/ }
     }
     return database;
   }

Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/BaseDataTest.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/BaseDataTest.java?rev=708047&r1=708046&r2=708047&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/BaseDataTest.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/BaseDataTest.java Sun Oct 26 14:39:35 2008
@@ -1,8 +1,9 @@
 package org.apache.ibatis;
 
 import org.apache.ibatis.io.Resources;
-import org.apache.ibatis.jdbc.PooledDataSource;
 import org.apache.ibatis.jdbc.ScriptRunner;
+import org.apache.ibatis.jdbc.UnpooledDataSource;
+import org.apache.ibatis.jdbc.PooledDataSource;
 import org.junit.Test;
 
 import javax.sql.DataSource;
@@ -20,6 +21,16 @@
   public static final String JPETSTORE_DDL = "databases/jpetstore/jpetstore-hsqldb-schema.sql";
   public static final String JPETSTORE_DATA = "databases/jpetstore/jpetstore-hsqldb-dataload.sql";
 
+  public static UnpooledDataSource createUnpooledDataSource(String resource) throws IOException {
+    Properties props = Resources.getResourceAsProperties(resource);
+    UnpooledDataSource ds = new UnpooledDataSource();
+    ds.setDriver(props.getProperty("driver"));
+    ds.setUrl(props.getProperty("url"));
+    ds.setUsername(props.getProperty("username"));
+    ds.setPassword(props.getProperty("password"));
+    return ds;
+  }
+
   public static PooledDataSource createPooledDataSource(String resource) throws IOException {
     Properties props = Resources.getResourceAsProperties(resource);
     PooledDataSource ds = new PooledDataSource();
@@ -52,6 +63,20 @@
     }
   }
 
+  public static DataSource createBlogDataSource() throws IOException, SQLException {
+    DataSource ds = createUnpooledDataSource(BLOG_PROPERTIES);
+    runScript(ds, BLOG_DDL);
+    runScript(ds, BLOG_DATA);
+    return ds;
+  }
+
+  public static DataSource createJPetstoreDataSource() throws IOException, SQLException {
+    DataSource ds = createUnpooledDataSource(JPETSTORE_PROPERTIES);
+    runScript(ds, JPETSTORE_DDL);
+    runScript(ds, JPETSTORE_DATA);
+    return ds;
+  }
+
   @Test
   public void dummy() {
   }

Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/executor/BaseExecutorTest.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/executor/BaseExecutorTest.java?rev=708047&r1=708046&r2=708047&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/executor/BaseExecutorTest.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/executor/BaseExecutorTest.java Sun Oct 26 14:39:35 2008
@@ -6,6 +6,7 @@
 import org.apache.ibatis.mapping.*;
 import org.junit.*;
 
+import javax.sql.DataSource;
 import java.io.IOException;
 import java.sql.*;
 import java.util.*;
@@ -23,66 +24,44 @@
     config.setDefaultStatementTimeout(5000);
   }
 
-  protected PooledDataSource createBlogDataSource() throws IOException, SQLException {
-    PooledDataSource ds = createPooledDataSource(BLOG_PROPERTIES);
-    runScript(ds, BLOG_DDL);
-    runScript(ds, BLOG_DATA);
-    return ds;
-  }
-
-  protected PooledDataSource createJPetstoreDataSource() throws IOException, SQLException {
-    PooledDataSource ds = createPooledDataSource(JPETSTORE_PROPERTIES);
-    runScript(ds, JPETSTORE_DDL);
-    runScript(ds, JPETSTORE_DATA);
-    return ds;
-  }
-
   @Test
   public void shouldInsertNewAuthor() throws Exception {
-    PooledDataSource ds = createBlogDataSource();
+    DataSource ds = createBlogDataSource();
     Connection connection = ds.getConnection();
-    try {
-      Executor executor = createExecutor(connection);
-      Author author = new Author(99, "someone", "******", "someone@apache.org", null, Section.NEWS);
-      MappedStatement insertStatement = ExecutorTestHelper.prepareInsertAuthorMappedStatement(config);
-      MappedStatement selectStatement = ExecutorTestHelper.prepareSelectOneAuthorMappedStatement(config);
-      int rows = executor.update(insertStatement, author);
-      List<Author> authors = executor.query(selectStatement, 99, Executor.NO_ROW_OFFSET, Executor.NO_ROW_LIMIT, Executor.NO_RESULT_HANDLER);
-      executor.flushStatements();
-      executor.rollback(true);
-      Assert.assertEquals(1, authors.size());
-      Assert.assertEquals(author.toString(), authors.get(0).toString());
-      Assert.assertTrue(1 == rows || BatchExecutor.BATCH_UPDATE_RETURN_VALUE == rows);
-    } finally {
-      ds.forceCloseAll();
-    }
+    Executor executor = createExecutor(connection);
+    Author author = new Author(99, "someone", "******", "someone@apache.org", null, Section.NEWS);
+    MappedStatement insertStatement = ExecutorTestHelper.prepareInsertAuthorMappedStatement(config);
+    MappedStatement selectStatement = ExecutorTestHelper.prepareSelectOneAuthorMappedStatement(config);
+    int rows = executor.update(insertStatement, author);
+    List<Author> authors = executor.query(selectStatement, 99, Executor.NO_ROW_OFFSET, Executor.NO_ROW_LIMIT, Executor.NO_RESULT_HANDLER);
+    executor.flushStatements();
+    executor.rollback(true);
+    Assert.assertEquals(1, authors.size());
+    Assert.assertEquals(author.toString(), authors.get(0).toString());
+    Assert.assertTrue(1 == rows || BatchExecutor.BATCH_UPDATE_RETURN_VALUE == rows);
   }
 
   @Test
   public void shouldSelectAllAuthorsAutoMapped() throws Exception {
-    PooledDataSource ds = createBlogDataSource();
+    DataSource ds = createBlogDataSource();
     Connection connection = ds.getConnection();
-    try {
-      Executor executor = createExecutor(connection);
-      MappedStatement selectStatement = ExecutorTestHelper.prepareSelectAllAuthorsAutoMappedStatement(config);
-      List<Author> authors = executor.query(selectStatement, null, Executor.NO_ROW_OFFSET, Executor.NO_ROW_LIMIT, Executor.NO_RESULT_HANDLER);
-      Assert.assertEquals(2, authors.size());
-      Author author = authors.get(0);
-      // id,username, password, email, bio, favourite_section
-      // (101,'jim','********','jim@ibatis.apache.org','','NEWS');
-      Assert.assertEquals(101, author.getId());
-      Assert.assertEquals("jim", author.getUsername());
-      Assert.assertEquals("jim@ibatis.apache.org", author.getEmail());
-      Assert.assertEquals("", author.getBio());
-      Assert.assertEquals(Section.NEWS, author.getFavouriteSection());
-    } finally {
-      ds.forceCloseAll();
-    }
+    Executor executor = createExecutor(connection);
+    MappedStatement selectStatement = ExecutorTestHelper.prepareSelectAllAuthorsAutoMappedStatement(config);
+    List<Author> authors = executor.query(selectStatement, null, Executor.NO_ROW_OFFSET, Executor.NO_ROW_LIMIT, Executor.NO_RESULT_HANDLER);
+    Assert.assertEquals(2, authors.size());
+    Author author = authors.get(0);
+    // id,username, password, email, bio, favourite_section
+    // (101,'jim','********','jim@ibatis.apache.org','','NEWS');
+    Assert.assertEquals(101, author.getId());
+    Assert.assertEquals("jim", author.getUsername());
+    Assert.assertEquals("jim@ibatis.apache.org", author.getEmail());
+    Assert.assertEquals("", author.getBio());
+    Assert.assertEquals(Section.NEWS, author.getFavouriteSection());
   }
 
   @Test
   public void shouldInsertNewAuthorWithAutoKey() throws Exception {
-    PooledDataSource ds = createBlogDataSource();
+    DataSource ds = createBlogDataSource();
     Connection connection = ds.getConnection();
     config.setGeneratedKeysEnabled(true);
     try {
@@ -101,253 +80,208 @@
         Assert.assertTrue(id >= 10000);
       }
     } finally {
-      ds.forceCloseAll();
       config.setGeneratedKeysEnabled(false);
     }
   }
 
   @Test
   public void shouldInsertNewAuthorByProc() throws Exception {
-    PooledDataSource ds = createBlogDataSource();
+    DataSource ds = createBlogDataSource();
     Connection connection = ds.getConnection();
-    try {
-      Executor executor = createExecutor(connection);
-      Author author = new Author(97, "someone", "******", "someone@apache.org", null, null);
-      MappedStatement insertStatement = ExecutorTestHelper.prepareInsertAuthorProc(config);
-      MappedStatement selectStatement = ExecutorTestHelper.prepareSelectOneAuthorMappedStatement(config);
-      int rows = executor.update(insertStatement, author);
-      List<Author> authors = executor.query(selectStatement, 97, Executor.NO_ROW_OFFSET, Executor.NO_ROW_LIMIT, Executor.NO_RESULT_HANDLER);
-      executor.flushStatements();
-      executor.rollback(true);
-      Assert.assertEquals(1, authors.size());
-      Assert.assertEquals(author.toString(), authors.get(0).toString());
-    } finally {
-      ds.forceCloseAll();
-    }
+    Executor executor = createExecutor(connection);
+    Author author = new Author(97, "someone", "******", "someone@apache.org", null, null);
+    MappedStatement insertStatement = ExecutorTestHelper.prepareInsertAuthorProc(config);
+    MappedStatement selectStatement = ExecutorTestHelper.prepareSelectOneAuthorMappedStatement(config);
+    int rows = executor.update(insertStatement, author);
+    List<Author> authors = executor.query(selectStatement, 97, Executor.NO_ROW_OFFSET, Executor.NO_ROW_LIMIT, Executor.NO_RESULT_HANDLER);
+    executor.flushStatements();
+    executor.rollback(true);
+    Assert.assertEquals(1, authors.size());
+    Assert.assertEquals(author.toString(), authors.get(0).toString());
   }
 
   @Test
   public void shouldInsertNewAuthorUsingSimpleNonPreparedStatements() throws Exception {
-    PooledDataSource ds = createBlogDataSource();
+    DataSource ds = createBlogDataSource();
     Connection connection = ds.getConnection();
-    try {
-      Executor executor = createExecutor(connection);
-      Author author = new Author(99, "someone", "******", "someone@apache.org", null, null);
-      MappedStatement insertStatement = ExecutorTestHelper.createInsertAuthorWithIDof99MappedStatement(config);
-      MappedStatement selectStatement = ExecutorTestHelper.createSelectAuthorWithIDof99MappedStatement(config);
-      int rows = executor.update(insertStatement, null);
-      List<Author> authors = executor.query(selectStatement, 99, Executor.NO_ROW_OFFSET, Executor.NO_ROW_LIMIT, Executor.NO_RESULT_HANDLER);
-      executor.flushStatements();
-      executor.rollback(true);
-      Assert.assertEquals(1, authors.size());
-      Assert.assertEquals(author.toString(), authors.get(0).toString());
-      Assert.assertTrue(1 == rows || BatchExecutor.BATCH_UPDATE_RETURN_VALUE == rows);
-    } finally {
-      ds.forceCloseAll();
-    }
+    Executor executor = createExecutor(connection);
+    Author author = new Author(99, "someone", "******", "someone@apache.org", null, null);
+    MappedStatement insertStatement = ExecutorTestHelper.createInsertAuthorWithIDof99MappedStatement(config);
+    MappedStatement selectStatement = ExecutorTestHelper.createSelectAuthorWithIDof99MappedStatement(config);
+    int rows = executor.update(insertStatement, null);
+    List<Author> authors = executor.query(selectStatement, 99, Executor.NO_ROW_OFFSET, Executor.NO_ROW_LIMIT, Executor.NO_RESULT_HANDLER);
+    executor.flushStatements();
+    executor.rollback(true);
+    Assert.assertEquals(1, authors.size());
+    Assert.assertEquals(author.toString(), authors.get(0).toString());
+    Assert.assertTrue(1 == rows || BatchExecutor.BATCH_UPDATE_RETURN_VALUE == rows);
   }
 
   @Test
   public void shouldUpdateAuthor() throws Exception {
-    PooledDataSource ds = createBlogDataSource();
+    DataSource ds = createBlogDataSource();
     Connection connection = ds.getConnection();
-    try {
-      Executor executor = createExecutor(connection);
-      Author author = new Author(101, "someone", "******", "someone@apache.org", null, Section.NEWS);
-      MappedStatement updateStatement = ExecutorTestHelper.prepareUpdateAuthorMappedStatement(config);
-      MappedStatement selectStatement = ExecutorTestHelper.prepareSelectOneAuthorMappedStatement(config);
-      int rows = executor.update(updateStatement, author);
-      List<Author> authors = executor.query(selectStatement, 101, Executor.NO_ROW_OFFSET, Executor.NO_ROW_LIMIT, Executor.NO_RESULT_HANDLER);
-      executor.flushStatements();
-      executor.rollback(true);
-      Assert.assertEquals(1, authors.size());
-      Assert.assertEquals(author.toString(), authors.get(0).toString());
-      Assert.assertTrue(1 == rows || BatchExecutor.BATCH_UPDATE_RETURN_VALUE == rows);
-    } finally {
-      ds.forceCloseAll();
-    }
+    Executor executor = createExecutor(connection);
+    Author author = new Author(101, "someone", "******", "someone@apache.org", null, Section.NEWS);
+    MappedStatement updateStatement = ExecutorTestHelper.prepareUpdateAuthorMappedStatement(config);
+    MappedStatement selectStatement = ExecutorTestHelper.prepareSelectOneAuthorMappedStatement(config);
+    int rows = executor.update(updateStatement, author);
+    List<Author> authors = executor.query(selectStatement, 101, Executor.NO_ROW_OFFSET, Executor.NO_ROW_LIMIT, Executor.NO_RESULT_HANDLER);
+    executor.flushStatements();
+    executor.rollback(true);
+    Assert.assertEquals(1, authors.size());
+    Assert.assertEquals(author.toString(), authors.get(0).toString());
+    Assert.assertTrue(1 == rows || BatchExecutor.BATCH_UPDATE_RETURN_VALUE == rows);
   }
 
   @Test
   public void shouldDeleteAuthor() throws Exception {
-    PooledDataSource ds = createBlogDataSource();
+    DataSource ds = createBlogDataSource();
     Connection connection = ds.getConnection();
-    try {
-      Executor executor = createExecutor(connection);
-      Author author = new Author(101, null, null, null, null, null);
-      MappedStatement deleteStatement = ExecutorTestHelper.prepareDeleteAuthorMappedStatement(config);
-      MappedStatement selectStatement = ExecutorTestHelper.prepareSelectOneAuthorMappedStatement(config);
-      int rows = executor.update(deleteStatement, author);
-      List<Author> authors = executor.query(selectStatement, 101, Executor.NO_ROW_OFFSET, Executor.NO_ROW_LIMIT, Executor.NO_RESULT_HANDLER);
-      executor.flushStatements();
-      executor.rollback(true);
-      Assert.assertEquals(0, authors.size());
-      Assert.assertTrue(1 == rows || BatchExecutor.BATCH_UPDATE_RETURN_VALUE == rows);
-    } finally {
-      ds.forceCloseAll();
-    }
+    Executor executor = createExecutor(connection);
+    Author author = new Author(101, null, null, null, null, null);
+    MappedStatement deleteStatement = ExecutorTestHelper.prepareDeleteAuthorMappedStatement(config);
+    MappedStatement selectStatement = ExecutorTestHelper.prepareSelectOneAuthorMappedStatement(config);
+    int rows = executor.update(deleteStatement, author);
+    List<Author> authors = executor.query(selectStatement, 101, Executor.NO_ROW_OFFSET, Executor.NO_ROW_LIMIT, Executor.NO_RESULT_HANDLER);
+    executor.flushStatements();
+    executor.rollback(true);
+    Assert.assertEquals(0, authors.size());
+    Assert.assertTrue(1 == rows || BatchExecutor.BATCH_UPDATE_RETURN_VALUE == rows);
   }
 
   @Test
   public void shouldSelectDiscriminatedProduct() throws Exception {
-    PooledDataSource ds = createJPetstoreDataSource();
+    DataSource ds = createJPetstoreDataSource();
     Connection connection = ds.getConnection();
-    try {
-      Executor executor = createExecutor(connection);
-      MappedStatement selectStatement = ExecutorTestHelper.prepareSelectDiscriminatedProduct(config);
-      List<Map> products = executor.query(selectStatement, null, Executor.NO_ROW_OFFSET, Executor.NO_ROW_LIMIT, Executor.NO_RESULT_HANDLER);
-      connection.rollback();
-      Assert.assertEquals(16, products.size());
-      for (Map m : products) {
-        if ("REPTILES".equals(m.get("category"))) {
-          Assert.assertNull(m.get("name"));
-        } else {
-          Assert.assertNotNull(m.get("name"));
-        }
+    Executor executor = createExecutor(connection);
+    MappedStatement selectStatement = ExecutorTestHelper.prepareSelectDiscriminatedProduct(config);
+    List<Map> products = executor.query(selectStatement, null, Executor.NO_ROW_OFFSET, Executor.NO_ROW_LIMIT, Executor.NO_RESULT_HANDLER);
+    connection.rollback();
+    Assert.assertEquals(16, products.size());
+    for (Map m : products) {
+      if ("REPTILES".equals(m.get("category"))) {
+        Assert.assertNull(m.get("name"));
+      } else {
+        Assert.assertNotNull(m.get("name"));
       }
-    } finally {
-      ds.forceCloseAll();
     }
   }
 
   @Test
   public void shouldSelect10DiscriminatedProducts() throws Exception {
-    PooledDataSource ds = createJPetstoreDataSource();
+    DataSource ds = createJPetstoreDataSource();
     Connection connection = ds.getConnection();
-    try {
-      Executor executor = createExecutor(connection);
-      MappedStatement selectStatement = ExecutorTestHelper.prepareSelectDiscriminatedProduct(config);
-      List<Map> products = executor.query(selectStatement, null, 4, 10, Executor.NO_RESULT_HANDLER);
-      connection.rollback();
-      Assert.assertEquals(10, products.size());
-      for (Map m : products) {
-        if ("REPTILES".equals(m.get("category"))) {
-          Assert.assertNull(m.get("name"));
-        } else {
-          Assert.assertNotNull(m.get("name"));
-        }
+    Executor executor = createExecutor(connection);
+    MappedStatement selectStatement = ExecutorTestHelper.prepareSelectDiscriminatedProduct(config);
+    List<Map> products = executor.query(selectStatement, null, 4, 10, Executor.NO_RESULT_HANDLER);
+    connection.rollback();
+    Assert.assertEquals(10, products.size());
+    for (Map m : products) {
+      if ("REPTILES".equals(m.get("category"))) {
+        Assert.assertNull(m.get("name"));
+      } else {
+        Assert.assertNotNull(m.get("name"));
       }
-    } finally {
-      ds.forceCloseAll();
     }
   }
 
   @Test
   public void shouldSelectTwoSetsOfAuthorsViaProc() throws Exception {
-    PooledDataSource ds = createBlogDataSource();
+    DataSource ds = createBlogDataSource();
     Connection connection = ds.getConnection();
     connection.setAutoCommit(false);
-    try {
-      Executor executor = createExecutor(connection);
-      MappedStatement selectStatement = ExecutorTestHelper.prepareSelectTwoSetsOfAuthorsProc(config);
-      List<List> authorSets = executor.query(selectStatement, new HashMap() {
-        {
-          put("id1", 101);
-          put("id2", 102);
-        }
-      }, Executor.NO_ROW_OFFSET, Executor.NO_ROW_LIMIT, Executor.NO_RESULT_HANDLER);
-      connection.rollback();
-      Assert.assertEquals(2, authorSets.size());
-      for (List authors : authorSets) {
-        Assert.assertEquals(2, authors.size());
-        for (Object author : authors) {
-          Assert.assertTrue(author instanceof Author);
-        }
+    Executor executor = createExecutor(connection);
+    MappedStatement selectStatement = ExecutorTestHelper.prepareSelectTwoSetsOfAuthorsProc(config);
+    List<List> authorSets = executor.query(selectStatement, new HashMap() {
+      {
+        put("id1", 101);
+        put("id2", 102);
+      }
+    }, Executor.NO_ROW_OFFSET, Executor.NO_ROW_LIMIT, Executor.NO_RESULT_HANDLER);
+    connection.rollback();
+    Assert.assertEquals(2, authorSets.size());
+    for (List authors : authorSets) {
+      Assert.assertEquals(2, authors.size());
+      for (Object author : authors) {
+        Assert.assertTrue(author instanceof Author);
       }
-    } finally {
-      ds.forceCloseAll();
     }
   }
 
   @Test
   public void shouldSelectAuthorViaOutParams() throws Exception {
-    PooledDataSource ds = createBlogDataSource();
+    DataSource ds = createBlogDataSource();
     Connection connection = ds.getConnection();
     connection.setAutoCommit(false);
-    try {
-      Executor executor = createExecutor(connection);
-      MappedStatement selectStatement = ExecutorTestHelper.prepareSelectAuthorViaOutParams(config);
-      Author author = new Author(102, null, null, null, null, null);
-      executor.query(selectStatement, author, Executor.NO_ROW_OFFSET, Executor.NO_ROW_LIMIT, Executor.NO_RESULT_HANDLER);
-      connection.rollback();
-
-      Assert.assertEquals("sally", author.getUsername());
-      Assert.assertEquals("********", author.getPassword());
-      Assert.assertEquals("sally@ibatis.apache.org", author.getEmail());
-      Assert.assertEquals(null, author.getBio());
-    } finally {
-      ds.forceCloseAll();
-    }
+    Executor executor = createExecutor(connection);
+    MappedStatement selectStatement = ExecutorTestHelper.prepareSelectAuthorViaOutParams(config);
+    Author author = new Author(102, null, null, null, null, null);
+    executor.query(selectStatement, author, Executor.NO_ROW_OFFSET, Executor.NO_ROW_LIMIT, Executor.NO_RESULT_HANDLER);
+    connection.rollback();
+
+    Assert.assertEquals("sally", author.getUsername());
+    Assert.assertEquals("********", author.getPassword());
+    Assert.assertEquals("sally@ibatis.apache.org", author.getEmail());
+    Assert.assertEquals(null, author.getBio());
   }
 
   @Test
   public void shouldFetchPostsForBlog() throws Exception {
-    PooledDataSource ds = createBlogDataSource();
+    DataSource ds = createBlogDataSource();
     Connection connection = ds.getConnection();
-    try {
-      Executor executor = createExecutor(connection);
-      MappedStatement selectBlog = ExecutorTestHelper.prepareComplexSelectBlogMappedStatement(config);
-      MappedStatement selectPosts = ExecutorTestHelper.prepareSelectPostsForBlogMappedStatement(config);
-      config.addMappedStatement(selectBlog);
-      config.addMappedStatement(selectPosts);
-      List<Post> posts = executor.query(selectPosts, 1, Executor.NO_ROW_OFFSET, Executor.NO_ROW_LIMIT, Executor.NO_RESULT_HANDLER);
-      executor.flushStatements();
-      Assert.assertEquals(2, posts.size());
-      Assert.assertNotNull(posts.get(1).getBlog());
-      Assert.assertEquals(1, posts.get(1).getBlog().getId());
-      executor.rollback(true);
-    } finally {
-      ds.forceCloseAll();
-    }
+    Executor executor = createExecutor(connection);
+    MappedStatement selectBlog = ExecutorTestHelper.prepareComplexSelectBlogMappedStatement(config);
+    MappedStatement selectPosts = ExecutorTestHelper.prepareSelectPostsForBlogMappedStatement(config);
+    config.addMappedStatement(selectBlog);
+    config.addMappedStatement(selectPosts);
+    List<Post> posts = executor.query(selectPosts, 1, Executor.NO_ROW_OFFSET, Executor.NO_ROW_LIMIT, Executor.NO_RESULT_HANDLER);
+    executor.flushStatements();
+    Assert.assertEquals(2, posts.size());
+    Assert.assertNotNull(posts.get(1).getBlog());
+    Assert.assertEquals(1, posts.get(1).getBlog().getId());
+    executor.rollback(true);
   }
 
   @Test
   public void shouldFetchOneOrphanedPostWithNoBlog() throws Exception {
-    PooledDataSource ds = createBlogDataSource();
+    DataSource ds = createBlogDataSource();
     Connection connection = ds.getConnection();
-    try {
-      Executor executor = createExecutor(connection);
-      MappedStatement selectBlog = ExecutorTestHelper.prepareComplexSelectBlogMappedStatement(config);
-      MappedStatement selectPost = ExecutorTestHelper.prepareSelectPostMappedStatement(config);
-      config.addMappedStatement(selectBlog);
-      config.addMappedStatement(selectPost);
-      List<Post> posts = executor.query(selectPost, 5, Executor.NO_ROW_OFFSET, Executor.NO_ROW_LIMIT, Executor.NO_RESULT_HANDLER);
-      executor.flushStatements();
-      executor.rollback(true);
-      Assert.assertEquals(1, posts.size());
-      Post post = posts.get(0);
-      Assert.assertNull(post.getBlog());
-    } finally {
-      ds.forceCloseAll();
-    }
+    Executor executor = createExecutor(connection);
+    MappedStatement selectBlog = ExecutorTestHelper.prepareComplexSelectBlogMappedStatement(config);
+    MappedStatement selectPost = ExecutorTestHelper.prepareSelectPostMappedStatement(config);
+    config.addMappedStatement(selectBlog);
+    config.addMappedStatement(selectPost);
+    List<Post> posts = executor.query(selectPost, 5, Executor.NO_ROW_OFFSET, Executor.NO_ROW_LIMIT, Executor.NO_RESULT_HANDLER);
+    executor.flushStatements();
+    executor.rollback(true);
+    Assert.assertEquals(1, posts.size());
+    Post post = posts.get(0);
+    Assert.assertNull(post.getBlog());
   }
 
   @Test
   public void shouldFetchPostWithBlogWithCompositeKey() throws Exception {
-    PooledDataSource ds = createBlogDataSource();
+    DataSource ds = createBlogDataSource();
     Connection connection = ds.getConnection();
-    try {
-      Executor executor = createExecutor(connection);
-      MappedStatement selectBlog = ExecutorTestHelper.prepareSelectBlogByIdAndAuthor(config);
-      MappedStatement selectPost = ExecutorTestHelper.prepareSelectPostWithBlogByAuthorMappedStatement(config);
-      config.addMappedStatement(selectBlog);
-      config.addMappedStatement(selectPost);
-      List<Post> posts = executor.query(selectPost, 2, Executor.NO_ROW_OFFSET, Executor.NO_ROW_LIMIT, Executor.NO_RESULT_HANDLER);
-      executor.flushStatements();
-      Assert.assertEquals(1, posts.size());
-      Post post = posts.get(0);
-      Assert.assertNotNull(post.getBlog());
-      Assert.assertEquals(101, post.getBlog().getAuthor().getId());
-      executor.rollback(true);
-    } finally {
-      ds.forceCloseAll();
-    }
+    Executor executor = createExecutor(connection);
+    MappedStatement selectBlog = ExecutorTestHelper.prepareSelectBlogByIdAndAuthor(config);
+    MappedStatement selectPost = ExecutorTestHelper.prepareSelectPostWithBlogByAuthorMappedStatement(config);
+    config.addMappedStatement(selectBlog);
+    config.addMappedStatement(selectPost);
+    List<Post> posts = executor.query(selectPost, 2, Executor.NO_ROW_OFFSET, Executor.NO_ROW_LIMIT, Executor.NO_RESULT_HANDLER);
+    executor.flushStatements();
+    Assert.assertEquals(1, posts.size());
+    Post post = posts.get(0);
+    Assert.assertNotNull(post.getBlog());
+    Assert.assertEquals(101, post.getBlog().getAuthor().getId());
+    executor.rollback(true);
   }
 
 
   @Test
   public void shouldFetchComplexBlogs() throws Exception {
-    PooledDataSource ds = createBlogDataSource();
+    DataSource ds = createBlogDataSource();
     Connection connection = ds.getConnection();
     try {
       Executor executor = createExecutor(connection);
@@ -363,28 +297,23 @@
       Assert.assertEquals(2, blogs.get(0).getPosts().size());
       Assert.assertEquals(1, blogs.get(0).getPosts().get(1).getBlog().getPosts().get(1).getBlog().getId());
     } finally {
-      ds.forceCloseAll();
       config.setLazyLoadingEnabled(true);
     }
   }
 
   @Test
   public void shouldMapConstructorResults() throws Exception {
-    PooledDataSource ds = createBlogDataSource();
+    DataSource ds = createBlogDataSource();
     Connection connection = ds.getConnection();
-    try {
-      Executor executor = createExecutor(connection);
-      MappedStatement selectStatement = ExecutorTestHelper.prepareSelectOneAuthorMappedStatementWithConstructorResults(config);
-      List<Author> authors = executor.query(selectStatement, 102, Executor.NO_ROW_OFFSET, Executor.NO_ROW_LIMIT, Executor.NO_RESULT_HANDLER);
-      executor.flushStatements();
-      executor.rollback(true);
-      Assert.assertEquals(1, authors.size());
+    Executor executor = createExecutor(connection);
+    MappedStatement selectStatement = ExecutorTestHelper.prepareSelectOneAuthorMappedStatementWithConstructorResults(config);
+    List<Author> authors = executor.query(selectStatement, 102, Executor.NO_ROW_OFFSET, Executor.NO_ROW_LIMIT, Executor.NO_RESULT_HANDLER);
+    executor.flushStatements();
+    executor.rollback(true);
+    Assert.assertEquals(1, authors.size());
 
-      Author author = authors.get(0);
-      Assert.assertEquals(102, author.getId());
-    } finally {
-      ds.forceCloseAll();
-    }
+    Author author = authors.get(0);
+    Assert.assertEquals(102, author.getId());
   }
 
   protected abstract Executor createExecutor(Connection connection);

Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/jdbc/ScriptRunnerTest.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/jdbc/ScriptRunnerTest.java?rev=708047&r1=708046&r2=708047&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/jdbc/ScriptRunnerTest.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/jdbc/ScriptRunnerTest.java Sun Oct 26 14:39:35 2008
@@ -3,7 +3,6 @@
 import org.apache.ibatis.BaseDataTest;
 import org.apache.ibatis.jdbc.SqlRunner;
 import org.apache.ibatis.io.Resources;
-import org.apache.ibatis.jdbc.*;
 import org.junit.*;
 
 import javax.sql.DataSource;
@@ -15,7 +14,7 @@
 
   @Test
   public void shouldRunScriptsUsingConnection() throws Exception {
-    PooledDataSource ds = createPooledDataSource(JPETSTORE_PROPERTIES);
+    DataSource ds = createUnpooledDataSource(JPETSTORE_PROPERTIES);
     Connection conn = ds.getConnection();
     ScriptRunner runner = new ScriptRunner(conn);
     runner.setAutoCommit(true);

Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/jdbc/SqlRunnerTest.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/jdbc/SqlRunnerTest.java?rev=708047&r1=708046&r2=708047&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/jdbc/SqlRunnerTest.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/jdbc/SqlRunnerTest.java Sun Oct 26 14:39:35 2008
@@ -6,6 +6,7 @@
 import org.apache.ibatis.jdbc.SqlRunner;
 import org.junit.*;
 
+import javax.sql.DataSource;
 import java.sql.Connection;
 import java.util.*;
 
@@ -13,100 +14,76 @@
 
   @Test
   public void shouldSelectOne() throws Exception {
-    PooledDataSource ds = createPooledDataSource(JPETSTORE_PROPERTIES);
+    DataSource ds = createUnpooledDataSource(JPETSTORE_PROPERTIES);
     runScript(ds, JPETSTORE_DDL);
     runScript(ds, JPETSTORE_DATA);
     Connection connection = ds.getConnection();
-    try {
-      SqlRunner exec = new SqlRunner(connection);
-      Map row = exec.selectOne("SELECT * FROM PRODUCT WHERE PRODUCTID = ?", "FI-SW-01");
-      Assert.assertEquals("FI-SW-01", row.get("PRODUCTID"));
-    } finally {
-      ds.forceCloseAll();
-    }
+    SqlRunner exec = new SqlRunner(connection);
+    Map row = exec.selectOne("SELECT * FROM PRODUCT WHERE PRODUCTID = ?", "FI-SW-01");
+    Assert.assertEquals("FI-SW-01", row.get("PRODUCTID"));
   }
 
   @Test
   public void shouldSelectList() throws Exception {
-    PooledDataSource ds = createPooledDataSource(JPETSTORE_PROPERTIES);
+    DataSource ds = createUnpooledDataSource(JPETSTORE_PROPERTIES);
     runScript(ds, JPETSTORE_DDL);
     runScript(ds, JPETSTORE_DATA);
     Connection connection = ds.getConnection();
-    try {
-      SqlRunner exec = new SqlRunner(connection);
-      List rows = exec.selectAll("SELECT * FROM PRODUCT");
-      Assert.assertEquals(16, rows.size());
-    } finally {
-      ds.forceCloseAll();
-    }
+    SqlRunner exec = new SqlRunner(connection);
+    List rows = exec.selectAll("SELECT * FROM PRODUCT");
+    Assert.assertEquals(16, rows.size());
   }
 
   @Test
   public void shouldInsert() throws Exception {
-    PooledDataSource ds = createPooledDataSource(BLOG_PROPERTIES);
+    DataSource ds = createUnpooledDataSource(BLOG_PROPERTIES);
     runScript(ds, BLOG_DDL);
     Connection connection = ds.getConnection();
-    try {
-      SqlRunner exec = new SqlRunner(connection);
-      exec.setForceGeneratedKeySupport(true);
-      int id = exec.insert("INSERT INTO author (username, password, email, bio) VALUES (?,?,?,?)", "someone", "******", "someone@apache.org", Null.LONGVARCHAR);
-      Map row = exec.selectOne("SELECT * FROM author WHERE username = ?", "someone");
-      connection.rollback();
-      Assert.assertTrue(SqlRunner.NO_GENERATED_KEY != id);
-      Assert.assertEquals("someone", row.get("USERNAME"));
-    } finally {
-      ds.forceCloseAll();
-    }
+    SqlRunner exec = new SqlRunner(connection);
+    exec.setForceGeneratedKeySupport(true);
+    int id = exec.insert("INSERT INTO author (username, password, email, bio) VALUES (?,?,?,?)", "someone", "******", "someone@apache.org", Null.LONGVARCHAR);
+    Map row = exec.selectOne("SELECT * FROM author WHERE username = ?", "someone");
+    connection.rollback();
+    Assert.assertTrue(SqlRunner.NO_GENERATED_KEY != id);
+    Assert.assertEquals("someone", row.get("USERNAME"));
   }
 
   @Test
   public void shouldUpdateCategory() throws Exception {
-    PooledDataSource ds = createPooledDataSource(JPETSTORE_PROPERTIES);
+    DataSource ds = createUnpooledDataSource(JPETSTORE_PROPERTIES);
     runScript(ds, JPETSTORE_DDL);
     runScript(ds, JPETSTORE_DATA);
     Connection connection = ds.getConnection();
-    try {
-      SqlRunner exec = new SqlRunner(connection);
-      int count = exec.update("update product set category = ? where productid = ?", "DOGS", "FI-SW-01");
-      Map row = exec.selectOne("SELECT * FROM PRODUCT WHERE PRODUCTID = ?", "FI-SW-01");
-      Assert.assertEquals("DOGS", row.get("CATEGORY"));
-      Assert.assertEquals(1, count);
-    } finally {
-      ds.forceCloseAll();
-    }
+    SqlRunner exec = new SqlRunner(connection);
+    int count = exec.update("update product set category = ? where productid = ?", "DOGS", "FI-SW-01");
+    Map row = exec.selectOne("SELECT * FROM PRODUCT WHERE PRODUCTID = ?", "FI-SW-01");
+    Assert.assertEquals("DOGS", row.get("CATEGORY"));
+    Assert.assertEquals(1, count);
   }
 
   @Test
   public void shouldDeleteOne() throws Exception {
-    PooledDataSource ds = createPooledDataSource(JPETSTORE_PROPERTIES);
+    DataSource ds = createUnpooledDataSource(JPETSTORE_PROPERTIES);
     runScript(ds, JPETSTORE_DDL);
     runScript(ds, JPETSTORE_DATA);
     Connection connection = ds.getConnection();
-    try {
-      SqlRunner exec = new SqlRunner(connection);
-      int count = exec.delete("delete from item");
-      List rows = exec.selectAll("SELECT * FROM ITEM");
-      Assert.assertEquals(28, count);
-      Assert.assertEquals(0, rows.size());
-    } finally {
-      ds.forceCloseAll();
-    }
+    SqlRunner exec = new SqlRunner(connection);
+    int count = exec.delete("delete from item");
+    List rows = exec.selectAll("SELECT * FROM ITEM");
+    Assert.assertEquals(28, count);
+    Assert.assertEquals(0, rows.size());
   }
 
   @Test
   public void shouldDemonstrateDDLThroughRunMethod() throws Exception {
-    PooledDataSource ds = createPooledDataSource(JPETSTORE_PROPERTIES);
+    DataSource ds = createUnpooledDataSource(JPETSTORE_PROPERTIES);
     Connection connection = ds.getConnection();
-    try {
-      SqlRunner exec = new SqlRunner(connection);
-      exec.run("CREATE TABLE BLAH(ID INTEGER)");
-      exec.run("insert into BLAH values (1)");
-      List rows = exec.selectAll("SELECT * FROM BLAH");
-      exec.run("DROP TABLE BLAH");
-      Assert.assertEquals(1, rows.size());
-    } finally {
-      ds.forceCloseAll();
-    }
+    SqlRunner exec = new SqlRunner(connection);
+    exec.run("CREATE TABLE BLAH(ID INTEGER)");
+    exec.run("insert into BLAH values (1)");
+    List rows = exec.selectAll("SELECT * FROM BLAH");
+    exec.run("DROP TABLE BLAH");
+    Assert.assertEquals(1, rows.size());
   }
 
 

Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/metadata/MetadataTest.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/metadata/MetadataTest.java?rev=708047&r1=708046&r2=708047&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/metadata/MetadataTest.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/metadata/MetadataTest.java Sun Oct 26 14:39:35 2008
@@ -16,7 +16,7 @@
 
   @Before
   public void setup() throws Exception {
-    dataSource = createPooledDataSource(BaseDataTest.BLOG_PROPERTIES);
+    dataSource = createUnpooledDataSource(BaseDataTest.BLOG_PROPERTIES);
   }
 
   @Test

Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/MigratorTest.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/MigratorTest.java?rev=708047&r1=708046&r2=708047&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/MigratorTest.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/MigratorTest.java Sun Oct 26 14:39:35 2008
@@ -2,7 +2,6 @@
 
 import org.apache.ibatis.BaseDataTest;
 import org.apache.ibatis.jdbc.SqlRunner;
-import org.apache.ibatis.jdbc.PooledDataSource;
 import org.apache.ibatis.io.Resources;
 import org.junit.*;
 
@@ -13,6 +12,8 @@
 
 import junit.framework.Assert;
 
+import javax.sql.DataSource;
+
 public class MigratorTest extends BaseDataTest {
 
   private static PrintStream out;
@@ -24,7 +25,7 @@
     buffer = new StringOutputStream();
     System.setOut(new PrintStream(buffer));
 
-    PooledDataSource ds = createPooledDataSource(BLOG_PROPERTIES);
+    DataSource ds = createUnpooledDataSource(BLOG_PROPERTIES);
     Connection conn = ds.getConnection();
     SqlRunner executor = new SqlRunner(conn);
     safeRun(executor, "DROP TABLE comment");

Modified: ibatis/trunk/java/ibatis-3/ibatis-3-monarch/src/test/java/org/apache/ibatis/monarch/builder/MapperConfigParserTest.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-monarch/src/test/java/org/apache/ibatis/monarch/builder/MapperConfigParserTest.java?rev=708047&r1=708046&r2=708047&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-monarch/src/test/java/org/apache/ibatis/monarch/builder/MapperConfigParserTest.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-monarch/src/test/java/org/apache/ibatis/monarch/builder/MapperConfigParserTest.java Sun Oct 26 14:39:35 2008
@@ -1,12 +1,13 @@
 package org.apache.ibatis.monarch.builder;
 
 import org.junit.Test;
+import org.apache.ibatis.BaseDataTest;
 
-public class MapperConfigParserTest {
+public class MapperConfigParserTest extends BaseDataTest {
 
   @Test
   public void shouldBuildBlogMappers() throws Exception {
-
+    
   }
 
 }