tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kkoli...@apache.org
Subject svn commit: r1459975 [1/2] - in /tomcat/tc7.0.x/trunk: ./ modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/
Date Fri, 22 Mar 2013 20:41:47 GMT
Author: kkolinko
Date: Fri Mar 22 20:41:46 2013
New Revision: 1459975

URL: http://svn.apache.org/r1459975
Log:
Merged revisions r1435505 r1435509 r1435759 from tomcat/trunk:
Convert jdbc-pool tests to JUnit 4

Modified:
    tomcat/tc7.0.x/trunk/   (props changed)
    tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/AbandonPercentageTest.java
    tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/AlternateUsernameTest.java
    tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/Async0IdleTestBug50477.java
    tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/BorrowWaitTest.java
    tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/Bug50571.java
    tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/Bug50805.java
    tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/CheckOutThreadTest.java
    tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/ConnectCountTest.java
    tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/CreateTestTable.java
    tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/DefaultTestCase.java
    tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/EqualsHashCodeTest.java
    tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/FairnessTest.java
    tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/JmxPasswordTest.java
    tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/MultipleCloseTest.java
    tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/PoolCleanerTest.java
    tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/PoolPurgeTest.java
    tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/StarvationTest.java
    tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/StatementFinalizerTest.java
    tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestAsyncQueue.java
    tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestConcurrency.java
    tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestConnectionState.java
    tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestException.java
    tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestGCClose.java
    tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestGetConnection.java
    tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestInterceptorShortName.java
    tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestQueryTimeoutInterceptor.java
    tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestSizePreservation.java
    tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestSlowQueryReport.java
    tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestStatementCache.java
    tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestSuspectTimeout.java
    tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestTimeout.java
    tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TwoDataSources.java

Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
  Merged /tomcat/trunk:r1435505,1435509,1435759

Modified: tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/AbandonPercentageTest.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/AbandonPercentageTest.java?rev=1459975&r1=1459974&r2=1459975&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/AbandonPercentageTest.java (original)
+++ tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/AbandonPercentageTest.java Fri Mar 22 20:41:46 2013
@@ -14,21 +14,19 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
 package org.apache.tomcat.jdbc.test;
 
 import java.sql.Connection;
 
+import org.junit.Assert;
+import org.junit.Test;
+
 import org.apache.tomcat.jdbc.pool.interceptor.ResetAbandonedTimer;
 
 public class AbandonPercentageTest extends DefaultTestCase {
 
-    public AbandonPercentageTest(String name) {
-        super(name);
-    }
-
+    @Test
     public void testDefaultAbandon() throws Exception {
-        this.init();
         this.datasource.setMaxActive(100);
         this.datasource.setMaxIdle(100);
         this.datasource.setInitialSize(0);
@@ -37,15 +35,15 @@ public class AbandonPercentageTest exten
         this.datasource.getPoolProperties().setRemoveAbandoned(true);
         this.datasource.getPoolProperties().setRemoveAbandonedTimeout(1);
         Connection con = datasource.getConnection();
-        assertEquals("Number of connections active/busy should be 1",1,datasource.getPool().getActive());
+        Assert.assertEquals("Number of connections active/busy should be 1",1,datasource.getPool().getActive());
         Thread.sleep(2000);
-        assertEquals("Number of connections active/busy should be 0",0,datasource.getPool().getActive());
+        Assert.assertEquals("Number of connections active/busy should be 0",0,datasource.getPool().getActive());
         con.close();
     }
 
+    @Test
     public void testMaxedOutAbandon() throws Exception {
         int size = 100;
-        this.init();
         this.datasource.setMaxActive(size);
         this.datasource.setMaxIdle(size);
         this.datasource.setInitialSize(0);
@@ -54,15 +52,15 @@ public class AbandonPercentageTest exten
         this.datasource.getPoolProperties().setRemoveAbandoned(true);
         this.datasource.getPoolProperties().setRemoveAbandonedTimeout(1);
         Connection con = datasource.getConnection();
-        assertEquals("Number of connections active/busy should be 1",1,datasource.getPool().getActive());
+        Assert.assertEquals("Number of connections active/busy should be 1",1,datasource.getPool().getActive());
         Thread.sleep(2000);
-        assertEquals("Number of connections active/busy should be 1",1,datasource.getPool().getActive());
+        Assert.assertEquals("Number of connections active/busy should be 1",1,datasource.getPool().getActive());
         con.close();
     }
 
+    @Test
     public void testResetConnection() throws Exception {
         int size = 1;
-        this.init();
         this.datasource.setMaxActive(size);
         this.datasource.setMaxIdle(size);
         this.datasource.setInitialSize(0);
@@ -72,18 +70,18 @@ public class AbandonPercentageTest exten
         this.datasource.getPoolProperties().setRemoveAbandonedTimeout(1);
         this.datasource.getPoolProperties().setJdbcInterceptors(ResetAbandonedTimer.class.getName());
         Connection con = datasource.getConnection();
-        assertEquals("Number of connections active/busy should be 1",1,datasource.getPool().getActive());
+        Assert.assertEquals("Number of connections active/busy should be 1",1,datasource.getPool().getActive());
         for (int i=0; i<20; i++) {
             Thread.sleep(200);
             con.isClosed();
         }
-        assertEquals("Number of connections active/busy should be 1",1,datasource.getPool().getActive());
+        Assert.assertEquals("Number of connections active/busy should be 1",1,datasource.getPool().getActive());
         con.close();
     }
 
+    @Test
     public void testHalfway() throws Exception {
         int size = 100;
-        this.init();
         this.datasource.setMaxActive(size);
         this.datasource.setMaxIdle(size);
         this.datasource.setInitialSize(0);
@@ -93,25 +91,25 @@ public class AbandonPercentageTest exten
         this.datasource.getPoolProperties().setRemoveAbandonedTimeout(1);
         Connection[] con = new Connection[size];
         con[0] = datasource.getConnection();
-        assertEquals("Number of connections active/busy should be 1",1,datasource.getPool().getActive());
+        Assert.assertEquals("Number of connections active/busy should be 1",1,datasource.getPool().getActive());
         for (int i=1; i<25; i++) {
             con[i] = datasource.getConnection();
         }
-        assertEquals("Number of connections active/busy should be 25",25,datasource.getPool().getActive());
+        Assert.assertEquals("Number of connections active/busy should be 25",25,datasource.getPool().getActive());
         Thread.sleep(2500);
-        assertEquals("Number of connections active/busy should be 25",25,datasource.getPool().getActive());
+        Assert.assertEquals("Number of connections active/busy should be 25",25,datasource.getPool().getActive());
         this.datasource.getPoolProperties().setRemoveAbandonedTimeout(100);
         for (int i=25; i<con.length; i++) {
             con[i] = datasource.getConnection();
         }
         int active = datasource.getPool().getActive();
         System.out.println("Active:"+active);
-        assertEquals("Number of connections active/busy should be "+con.length,con.length,datasource.getPool().getActive());
+        Assert.assertEquals("Number of connections active/busy should be "+con.length,con.length,datasource.getPool().getActive());
         this.datasource.getPoolProperties().setRemoveAbandonedTimeout(1);
         Thread.sleep(2500);
-        assertTrue("Number of connections should be less than 50.", (datasource.getPool().getActive()<50));
+        Assert.assertTrue("Number of connections should be less than 50.", (datasource.getPool().getActive()<50));
         this.datasource.getPoolProperties().setAbandonWhenPercentageFull(0);
         Thread.sleep(2500);
-        assertEquals("Number of connections active/busy should be "+0,0,datasource.getPool().getActive());
+        Assert.assertEquals("Number of connections active/busy should be "+0,0,datasource.getPool().getActive());
     }
 }

Modified: tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/AlternateUsernameTest.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/AlternateUsernameTest.java?rev=1459975&r1=1459974&r2=1459975&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/AlternateUsernameTest.java (original)
+++ tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/AlternateUsernameTest.java Fri Mar 22 20:41:46 2013
@@ -14,7 +14,6 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
 package org.apache.tomcat.jdbc.test;
 
 import java.sql.SQLException;
@@ -27,16 +26,17 @@ import java.util.concurrent.Future;
 
 import javax.sql.PooledConnection;
 
+import org.junit.Assert;
+import org.junit.Test;
+
 import org.apache.tomcat.jdbc.test.driver.Connection;
 import org.apache.tomcat.jdbc.test.driver.Driver;
 
-
 public class AlternateUsernameTest extends DefaultTestCase {
 
     private static final int iterations = 500000; //(new Random(System.currentTimeMillis())).nextInt(1000000)+100000;
-    public AlternateUsernameTest(String name) {
-        super(name);
-    }
+
+    @Test
     public void testUsernameCompare() throws Exception {
         testUsername(true);
     }
@@ -45,7 +45,6 @@ public class AlternateUsernameTest exten
         long start = System.currentTimeMillis();
         int withoutuser =10;
         int withuser = withoutuser;
-        this.init();
         this.datasource.setMaxActive(withuser+withoutuser);
         this.datasource.setDriverClassName(Driver.class.getName());
         this.datasource.setUrl("jdbc:tomcat:test");
@@ -70,7 +69,7 @@ public class AlternateUsernameTest exten
             total+=results.get(i+withuser).get().iterations;
         }
         long stop = System.currentTimeMillis();
-        assertEquals("Nr of failures was:"+failures,0, failures);
+        Assert.assertEquals("Nr of failures was:"+failures,0, failures);
         svc.shutdownNow();
         this.datasource.close();
         System.out.println("Nr of connect() calls:"+Driver.connectCount.get());
@@ -79,10 +78,12 @@ public class AlternateUsernameTest exten
 
     }
 
+    @Test
     public void testUsernameCompareAgain() throws Exception {
         testUsernameCompare();
     }
 
+    @Test
     public void testUsernameCompareNotAllowed() throws Exception {
         testUsername(false);
     }
@@ -120,8 +121,8 @@ public class AlternateUsernameTest exten
 
                     Connection con = (Connection)pcon.getConnection();
 
-                    assertTrue("Username mismatch: Requested User:"+username+" Actual user:"+con.getUsername(), con.getUsername().equals(username));
-                    assertTrue("Password mismatch: Requested Password:"+password+" Actual password:"+con.getPassword(), con.getPassword().equals(password));
+                    Assert.assertTrue("Username mismatch: Requested User:"+username+" Actual user:"+con.getUsername(), con.getUsername().equals(username));
+                    Assert.assertTrue("Password mismatch: Requested Password:"+password+" Actual password:"+con.getPassword(), con.getPassword().equals(password));
                 }catch (SQLException x) {
                     test.failures++;
                     test.lastMessage = x.getMessage();

Modified: tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/Async0IdleTestBug50477.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/Async0IdleTestBug50477.java?rev=1459975&r1=1459974&r2=1459975&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/Async0IdleTestBug50477.java (original)
+++ tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/Async0IdleTestBug50477.java Fri Mar 22 20:41:46 2013
@@ -20,21 +20,15 @@ import java.sql.Connection;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 
+import org.junit.Test;
+
 import org.apache.tomcat.jdbc.pool.DataSourceProxy;
 
-/**
- * @author Filip Hanik
- * @version 1.0
- */
 public class Async0IdleTestBug50477 extends DefaultTestCase {
-    public Async0IdleTestBug50477(String name) {
-        super(name);
-    }
-
 
+    @Test
     public void testAsync0Idle0Size() throws Exception {
         System.out.println("[testPoolThreads20Connections10FairAsync] Starting fairness - Tomcat JDBC - Fair - Async");
-        init();
         this.datasource.getPoolProperties().setMaxActive(10);
         this.datasource.getPoolProperties().setFairQueue(true);
         this.datasource.getPoolProperties().setInitialSize(0);

Modified: tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/BorrowWaitTest.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/BorrowWaitTest.java?rev=1459975&r1=1459974&r2=1459975&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/BorrowWaitTest.java (original)
+++ tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/BorrowWaitTest.java Fri Mar 22 20:41:46 2013
@@ -14,34 +14,32 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
 package org.apache.tomcat.jdbc.test;
 
 import java.sql.Connection;
 import java.sql.SQLException;
 
-public class BorrowWaitTest extends DefaultTestCase {
+import org.junit.Assert;
+import org.junit.Test;
 
-    public BorrowWaitTest(String name) {
-        super(name);
-    }
+public class BorrowWaitTest extends DefaultTestCase {
 
+    @Test
     public void testWaitTime() throws Exception {
 
         int wait = 10000;
-        this.init();
         this.datasource.setMaxActive(1);
         this.datasource.setMaxWait(wait);
         Connection con = datasource.getConnection();
         long start = System.currentTimeMillis();
         try {
             Connection con2 = datasource.getConnection();
-            assertFalse("This should not happen, connection should be unavailable.",true);
+            Assert.assertFalse("This should not happen, connection should be unavailable.",true);
             con2.close();
         }catch (SQLException x) {
             long delta = System.currentTimeMillis() - start;
             boolean inrange = Math.abs(wait-delta) <= 1000;
-            assertTrue("Connection should have been acquired within +/- 1 second, but was "+(wait-delta)+" ms.",inrange);
+            Assert.assertTrue("Connection should have been acquired within +/- 1 second, but was "+(wait-delta)+" ms.",inrange);
         }
         con.close();
     }
@@ -53,7 +51,6 @@ public class BorrowWaitTest extends Defa
         }
         /*
         int wait = -1;
-        this.init();
         this.datasource.setMaxActive(1);
         this.datasource.setMaxWait(wait);
         Connection con = datasource.getConnection();

Modified: tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/Bug50571.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/Bug50571.java?rev=1459975&r1=1459974&r2=1459975&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/Bug50571.java (original)
+++ tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/Bug50571.java Fri Mar 22 20:41:46 2013
@@ -16,23 +16,22 @@
  */
 package org.apache.tomcat.jdbc.test;
 
+import org.junit.Before;
+import org.junit.Test;
+
 import org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;
 
 public class Bug50571 extends DefaultTestCase{
 
-    public Bug50571(String name) {
-        super(name);
-    }
-
-    @Override
+    @Before
     public void setUp() throws Exception {
-        super.setUp();
         this.datasource.setUrl("jdbc:h2:~/.h2/test;QUERY_TIMEOUT=0;DB_CLOSE_ON_EXIT=FALSE");
         this.datasource.setJdbcInterceptors(ConnectionState.class.getName());
         this.datasource.setDefaultTransactionIsolation(-55);
         this.datasource.setInitialSize(1);
     }
 
+    @Test
     public void testBug50571() throws Exception {
         this.datasource.getConnection().close();
     }

Modified: tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/Bug50805.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/Bug50805.java?rev=1459975&r1=1459974&r2=1459975&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/Bug50805.java (original)
+++ tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/Bug50805.java Fri Mar 22 20:41:46 2013
@@ -19,36 +19,36 @@ package org.apache.tomcat.jdbc.test;
 import java.sql.Connection;
 import java.util.concurrent.Future;
 
+import org.junit.Assert;
+import org.junit.Test;
+
 public class Bug50805 extends DefaultTestCase {
-    public Bug50805(String name) {
-        super(name);
-    }
 
+    @Test
     public void test50805() throws Exception {
-        init();
         this.datasource.setInitialSize(0);
         this.datasource.setMaxActive(10);
         this.datasource.setMinIdle(1);
 
-        assertEquals("Current size should be 0.", 0, this.datasource.getSize());
+        Assert.assertEquals("Current size should be 0.", 0, this.datasource.getSize());
 
         this.datasource.getConnection().close();
 
-        assertEquals("Current size should be 1.", 1, this.datasource.getSize());
-        assertEquals("Idle size should be 1.", 1, this.datasource.getIdle());
-        assertEquals("Busy size should be 0.", 0, this.datasource.getActive());
+        Assert.assertEquals("Current size should be 1.", 1, this.datasource.getSize());
+        Assert.assertEquals("Idle size should be 1.", 1, this.datasource.getIdle());
+        Assert.assertEquals("Busy size should be 0.", 0, this.datasource.getActive());
 
         Future<Connection> fc = this.datasource.getConnectionAsync();
 
         Connection con = fc.get();
 
-        assertEquals("Current size should be 1.", 1, this.datasource.getSize());
-        assertEquals("Idle size should be 0.", 0, this.datasource.getIdle());
-        assertEquals("Busy size should be 1.", 1, this.datasource.getActive());
+        Assert.assertEquals("Current size should be 1.", 1, this.datasource.getSize());
+        Assert.assertEquals("Idle size should be 0.", 0, this.datasource.getIdle());
+        Assert.assertEquals("Busy size should be 1.", 1, this.datasource.getActive());
 
         con.close();
-        assertEquals("Current size should be 1.", 1, this.datasource.getSize());
-        assertEquals("Idle size should be 1.", 1, this.datasource.getIdle());
-        assertEquals("Busy size should be 0.", 0, this.datasource.getActive());
+        Assert.assertEquals("Current size should be 1.", 1, this.datasource.getSize());
+        Assert.assertEquals("Idle size should be 1.", 1, this.datasource.getIdle());
+        Assert.assertEquals("Busy size should be 0.", 0, this.datasource.getActive());
     }
 }

Modified: tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/CheckOutThreadTest.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/CheckOutThreadTest.java?rev=1459975&r1=1459974&r2=1459975&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/CheckOutThreadTest.java (original)
+++ tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/CheckOutThreadTest.java Fri Mar 22 20:41:46 2013
@@ -23,20 +23,14 @@ import java.util.concurrent.CountDownLat
 
 import javax.sql.DataSource;
 
+import org.junit.Test;
 
-/**
- * @author Filip Hanik
- * @version 1.0
- */
 public class CheckOutThreadTest extends DefaultTestCase {
-    public CheckOutThreadTest(String name) {
-        super(name);
-    }
 
     CountDownLatch latch = null;
 
+    @Test
     public void testDBCPThreads10Connections10() throws Exception {
-        init();
         this.datasource.getPoolProperties().setMaxActive(10);
         this.threadcount = 10;
         this.transferProperties();
@@ -55,8 +49,8 @@ public class CheckOutThreadTest extends 
         tearDown();
     }
 
+    @Test
     public void testPoolThreads10Connections10() throws Exception {
-        init();
         this.datasource.getPoolProperties().setMaxActive(10);
         this.datasource.getPoolProperties().setFairQueue(false);
         this.threadcount = 10;
@@ -76,8 +70,8 @@ public class CheckOutThreadTest extends 
         tearDown();
     }
 
+    @Test
     public void testPoolThreads10Connections10Fair() throws Exception {
-        init();
         this.datasource.getPoolProperties().setMaxActive(10);
         this.datasource.getPoolProperties().setFairQueue(true);
         this.threadcount = 10;
@@ -97,8 +91,8 @@ public class CheckOutThreadTest extends 
         tearDown();
     }
 
+//    @Test
 //    public void testC3P0Threads10Connections10() throws Exception {
-//        init();
 //        this.datasource.getPoolProperties().setMaxActive(10);
 //        this.threadcount = 10;
 //        this.transferPropertiesToC3P0();
@@ -117,8 +111,8 @@ public class CheckOutThreadTest extends 
 //        tearDown();
 //    }
 
+    @Test
     public void testDBCPThreads20Connections10() throws Exception {
-        init();
         this.datasource.getPoolProperties().setMaxActive(10);
         this.threadcount = 20;
         this.transferProperties();
@@ -137,8 +131,8 @@ public class CheckOutThreadTest extends 
         tearDown();
     }
 
+    @Test
     public void testPoolThreads20Connections10() throws Exception {
-        init();
         this.datasource.getPoolProperties().setMaxActive(10);
         this.datasource.getPoolProperties().setFairQueue(false);
         this.threadcount = 20;
@@ -158,8 +152,8 @@ public class CheckOutThreadTest extends 
         tearDown();
     }
 
+    @Test
     public void testPoolThreads20Connections10Fair() throws Exception {
-        init();
         this.datasource.getPoolProperties().setMaxActive(10);
         this.datasource.getPoolProperties().setFairQueue(true);
         this.threadcount = 20;
@@ -179,8 +173,8 @@ public class CheckOutThreadTest extends 
         tearDown();
     }
 
+//    @Test
 //    public void testC3P0Threads20Connections10() throws Exception {
-//        init();
 //        this.datasource.getPoolProperties().setMaxActive(10);
 //        this.threadcount = 20;
 //        this.transferPropertiesToC3P0();
@@ -199,8 +193,8 @@ public class CheckOutThreadTest extends 
 //        tearDown();
 //    }
 
+    @Test
     public void testDBCPThreads10Connections10Validate() throws Exception {
-        init();
         this.datasource.getPoolProperties().setMaxActive(10);
         this.datasource.getPoolProperties().setTestOnBorrow(true);
         this.threadcount = 10;
@@ -220,8 +214,8 @@ public class CheckOutThreadTest extends 
         tearDown();
     }
 
+    @Test
     public void testPoolThreads10Connections10Validate() throws Exception {
-        init();
         this.datasource.getPoolProperties().setMaxActive(10);
         this.datasource.getPoolProperties().setTestOnBorrow(true);
         this.datasource.getPoolProperties().setFairQueue(false);
@@ -242,8 +236,8 @@ public class CheckOutThreadTest extends 
         tearDown();
     }
 
+    @Test
     public void testPoolThreads10Connections10ValidateFair() throws Exception {
-        init();
         this.datasource.getPoolProperties().setMaxActive(10);
         this.datasource.getPoolProperties().setTestOnBorrow(true);
         this.datasource.getPoolProperties().setFairQueue(true);
@@ -264,8 +258,8 @@ public class CheckOutThreadTest extends 
         tearDown();
     }
 
+//    @Test
 //    public void testC3P0Threads10Connections10Validate() throws Exception {
-//        init();
 //        this.datasource.getPoolProperties().setMaxActive(10);
 //        this.datasource.getPoolProperties().setTestOnBorrow(true);
 //        this.threadcount = 10;
@@ -285,8 +279,8 @@ public class CheckOutThreadTest extends 
 //        tearDown();
 //    }
 
+    @Test
     public void testDBCPThreads20Connections10Validate() throws Exception {
-        init();
         this.datasource.getPoolProperties().setMaxActive(10);
         this.datasource.getPoolProperties().setTestOnBorrow(true);
         this.threadcount = 20;
@@ -306,8 +300,8 @@ public class CheckOutThreadTest extends 
         tearDown();
     }
 
+    @Test
     public void testPoolThreads10Connections20Validate() throws Exception {
-        init();
         this.datasource.getPoolProperties().setMaxActive(10);
         this.datasource.getPoolProperties().setTestOnBorrow(true);
         this.datasource.getPoolProperties().setFairQueue(false);
@@ -328,8 +322,8 @@ public class CheckOutThreadTest extends 
         tearDown();
     }
 
+    @Test
     public void testPoolThreads10Connections20ValidateFair() throws Exception {
-        init();
         this.datasource.getPoolProperties().setMaxActive(10);
         this.datasource.getPoolProperties().setTestOnBorrow(true);
         this.datasource.getPoolProperties().setFairQueue(true);
@@ -350,8 +344,8 @@ public class CheckOutThreadTest extends 
         tearDown();
     }
 
+//    @Test
 //    public void testC3P0Threads10Connections20Validate() throws Exception {
-//        init();
 //        this.datasource.getPoolProperties().setMaxActive(10);
 //        this.datasource.getPoolProperties().setTestOnBorrow(true);
 //        this.threadcount = 20;

Modified: tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/ConnectCountTest.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/ConnectCountTest.java?rev=1459975&r1=1459974&r2=1459975&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/ConnectCountTest.java (original)
+++ tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/ConnectCountTest.java Fri Mar 22 20:41:46 2013
@@ -25,17 +25,13 @@ import java.util.concurrent.TimeUnit;
 
 import javax.sql.DataSource;
 
+import org.junit.After;
+import org.junit.Test;
+
 import org.apache.tomcat.jdbc.pool.DataSourceProxy;
 import org.apache.tomcat.jdbc.test.driver.Driver;
 
-/**
- * @author Filip Hanik
- * @version 1.0
- */
 public class ConnectCountTest extends DefaultTestCase {
-    public ConnectCountTest(String name) {
-        super(name);
-    }
 
     protected boolean run = true;
     protected long sleep = Long.getLong("sleep", 10).longValue();
@@ -59,7 +55,8 @@ public class ConnectCountTest extends De
 
 
     @Override
-    protected void tearDown() throws Exception {
+    @After
+    public void tearDown() throws Exception {
         Driver.reset();
         super.tearDown();
     }
@@ -83,14 +80,12 @@ public class ConnectCountTest extends De
                            (((float)totalfetch))/(float)threads.length);
         System.out.println("["+name+"] Max wait:"+maxwait/1000000f+"ms. Min wait:"+minwait/1000000f+"ms. Average wait:"+(((((float)totalwait))/(float)totalfetch)/1000000f)+" ms.");
         System.out.println("["+name+"] Max active:"+active+" Expected Active:"+expected);
-
-
     }
 
+    @Test
     public void testDBCPThreads20Connections10() throws Exception {
         System.out.println("[testDBCPThreads20Connections10] Starting fairness - DBCP");
         this.threadcount = 20;
-        init();
         this.transferProperties();
         this.tDatasource.getConnection().close();
         latch = new CountDownLatch(threadcount);
@@ -112,12 +107,11 @@ public class ConnectCountTest extends De
         long delta = System.currentTimeMillis() - start;
         printThreadResults(threads,"testDBCPThreads20Connections10",Driver.connectCount.get(),10);
         System.out.println("Test completed in: " + delta + "ms.");
-        tearDown();
     }
 
+    @Test
     public void testPoolThreads20Connections10() throws Exception {
         System.out.println("[testPoolThreads20Connections10] Starting fairness - Tomcat JDBC - Non Fair");
-        init();
         this.threadcount = 20;
         this.transferProperties();
         this.datasource.getConnection().close();
@@ -140,13 +134,11 @@ public class ConnectCountTest extends De
         long delta = System.currentTimeMillis() - start;
         printThreadResults(threads,"testPoolThreads20Connections10",Driver.connectCount.get(),10);
         System.out.println("Test completed in: " + delta + "ms.");
-        tearDown();
-
     }
 
+    @Test
     public void testPoolThreads20Connections10Fair() throws Exception {
         System.out.println("[testPoolThreads20Connections10Fair] Starting fairness - Tomcat JDBC - Fair");
-        init();
         this.threadcount = 20;
         this.datasource.getPoolProperties().setFairQueue(true);
         this.transferProperties();
@@ -170,12 +162,11 @@ public class ConnectCountTest extends De
         long delta = System.currentTimeMillis() - start;
         printThreadResults(threads,"testPoolThreads20Connections10Fair",Driver.connectCount.get(),10);
         System.out.println("Test completed in: " + delta + "ms.");
-        tearDown();
     }
 
+    @Test
     public void testPoolThreads20Connections10FairAsync() throws Exception {
         System.out.println("[testPoolThreads20Connections10FairAsync] Starting fairness - Tomcat JDBC - Fair - Async");
-        init();
         this.threadcount = 20;
         this.datasource.getPoolProperties().setFairQueue(true);
         this.datasource.getPoolProperties().setInitialSize(this.datasource.getPoolProperties().getMaxActive());
@@ -201,12 +192,11 @@ public class ConnectCountTest extends De
         long delta = System.currentTimeMillis() - start;
         printThreadResults(threads,"testPoolThreads20Connections10FairAsync",Driver.connectCount.get(),10);
         System.out.println("Test completed in: " + delta + "ms.");
-        tearDown();
     }
 
+//    @Test
 //    public void testC3P0Threads20Connections10() throws Exception {
 //        System.out.println("[testC3P0Threads20Connections10] Starting fairness - C3P0");
-//        init();
 //        this.threadcount = 20;
 //        this.transferPropertiesToC3P0();
 //        this.datasource.getConnection().close();
@@ -228,8 +218,6 @@ public class ConnectCountTest extends De
 //        this.run = false;
 //        long delta = System.currentTimeMillis() - start;
 //        printThreadResults(threads,"testC3P0Threads20Connections10",Driver.connectCount.get(),10);
-//        tearDown();
-//
 //    }
 
 
@@ -301,4 +289,3 @@ public class ConnectCountTest extends De
         }
     }
 }
-

Modified: tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/CreateTestTable.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/CreateTestTable.java?rev=1459975&r1=1459974&r2=1459975&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/CreateTestTable.java (original)
+++ tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/CreateTestTable.java Fri Mar 22 20:41:46 2013
@@ -14,7 +14,6 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
 package org.apache.tomcat.jdbc.test;
 
 import java.sql.Connection;
@@ -23,18 +22,16 @@ import java.sql.ResultSet;
 import java.sql.Statement;
 import java.util.Random;
 
+import org.junit.Test;
+
 import org.apache.tomcat.jdbc.pool.interceptor.ResetAbandonedTimer;
 
 public class CreateTestTable extends DefaultTestCase {
 
     public static volatile boolean recreate = Boolean.getBoolean("recreate");
 
-    public CreateTestTable(String name) {
-        super(name);
-    }
-
+    @Test
     public void testCreateTestTable() throws Exception {
-        this.init();
         Connection con = datasource.getConnection();
         Statement st = con.createStatement();
         try {
@@ -47,7 +44,6 @@ public class CreateTestTable extends Def
     public int testCheckData() throws Exception {
         int count = 0;
         String check = "select count (*) from test";
-        this.init();
         Connection con = datasource.getConnection();
         Statement st = con.createStatement();
         try {
@@ -63,6 +59,7 @@ public class CreateTestTable extends Def
         return count;
     }
 
+    @Test
     public void testPopulateData() throws Exception {
         int count = 100000;
         int actual = testCheckData();
@@ -73,7 +70,6 @@ public class CreateTestTable extends Def
 
         datasource.setJdbcInterceptors(ResetAbandonedTimer.class.getName());
         String insert = "insert into test values (?,?,?,?,?)";
-        this.init();
         this.datasource.setRemoveAbandoned(false);
         Connection con = datasource.getConnection();
 
@@ -131,8 +127,7 @@ public class CreateTestTable extends Def
 
     public static void main(String[] args) throws Exception {
         recreate = true;
-        CreateTestTable test = new CreateTestTable("CreateTestTable");
+        CreateTestTable test = new CreateTestTable();
         test.testPopulateData();
     }
-
 }

Modified: tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/DefaultTestCase.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/DefaultTestCase.java?rev=1459975&r1=1459974&r2=1459975&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/DefaultTestCase.java (original)
+++ tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/DefaultTestCase.java Fri Mar 22 20:41:46 2013
@@ -19,7 +19,8 @@ package org.apache.tomcat.jdbc.test;
 import java.lang.reflect.Method;
 import java.util.Properties;
 
-import junit.framework.TestCase;
+import org.junit.After;
+import org.junit.Before;
 
 import org.apache.tomcat.dbcp.dbcp.BasicDataSource;
 import org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory;
@@ -34,20 +35,13 @@ import org.apache.tomcat.jdbc.pool.PoolP
  * @author Filip Hanik
  * @version 1.0
  */
-public class DefaultTestCase extends TestCase {
+public abstract class DefaultTestCase {
+
     protected org.apache.tomcat.jdbc.pool.DataSource datasource;
     protected BasicDataSource tDatasource;
 //    protected ComboPooledDataSource c3p0Datasource;
     protected int threadcount = 10;
     protected int iterations = 100000;
-    public DefaultTestCase(String name) {
-        super(name);
-    }
-
-    @Override
-    public void setUp() throws Exception {
-        init();
-    }
 
     public org.apache.tomcat.jdbc.pool.DataSource createDefaultDataSource() {
         org.apache.tomcat.jdbc.pool.DataSource datasource = null;
@@ -72,7 +66,8 @@ public class DefaultTestCase extends Tes
         return datasource;
     }
 
-    protected void init() throws Exception {
+    @Before
+    public void init() throws Exception {
         this.datasource = createDefaultDataSource();
     }
 
@@ -178,8 +173,8 @@ public class DefaultTestCase extends Tes
     }
 
 
-    @Override
-    protected void tearDown() throws Exception {
+    @After
+    public void tearDown() throws Exception {
         try {datasource.close();}catch(Exception ignore){}
         try {tDatasource.close();}catch(Exception ignore){}
         //try {((ComboPooledDataSource)c3p0Datasource).close(true);}catch(Exception ignore){}

Modified: tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/EqualsHashCodeTest.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/EqualsHashCodeTest.java?rev=1459975&r1=1459974&r2=1459975&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/EqualsHashCodeTest.java (original)
+++ tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/EqualsHashCodeTest.java Fri Mar 22 20:41:46 2013
@@ -20,19 +20,18 @@ import java.sql.Connection;
 
 import javax.sql.PooledConnection;
 
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
 import org.apache.tomcat.jdbc.test.driver.Driver;
 
 public class EqualsHashCodeTest extends DefaultTestCase{
     public static final String password = "password";
     public static final String username = "username";
 
-    public EqualsHashCodeTest(String s) {
-        super(s);
-    }
-
-    @Override
+    @Before
     public void setUp() throws Exception {
-        super.setUp();
         this.datasource.setDriverClassName(Driver.class.getName());
         this.datasource.setUrl("jdbc:tomcat:test");
         this.datasource.setPassword(password);
@@ -44,30 +43,32 @@ public class EqualsHashCodeTest extends 
         datasource.createPool();
     }
 
+    @Test
     public void testEquals() throws Exception {
         Connection con1 = datasource.getConnection();
         Connection real1 = ((PooledConnection)con1).getConnection();
-        assertEquals(con1, con1);
+        Assert.assertEquals(con1, con1);
         con1.close();
-        assertEquals(con1, con1);
+        Assert.assertEquals(con1, con1);
         Connection con2 = datasource.getConnection();
         Connection real2 = ((PooledConnection)con2).getConnection();
-        assertEquals(real1,real2);
-        assertEquals(con2, con2);
-        assertNotSame(con1, con2);
+        Assert.assertEquals(real1,real2);
+        Assert.assertEquals(con2, con2);
+        Assert.assertNotSame(con1, con2);
         con2.close();
-        assertEquals(con2, con2);
+        Assert.assertEquals(con2, con2);
     }
 
+    @Test
     public void testHashCode() throws Exception {
         Connection con1 = datasource.getConnection();
-        assertEquals(con1.hashCode(), con1.hashCode());
+        Assert.assertEquals(con1.hashCode(), con1.hashCode());
         con1.close();
-        assertEquals(con1.hashCode(), con1.hashCode());
+        Assert.assertEquals(con1.hashCode(), con1.hashCode());
         Connection con2 = datasource.getConnection();
-        assertEquals(con2.hashCode(), con2.hashCode());
-        assertTrue(con1.hashCode() != con2.hashCode());
+        Assert.assertEquals(con2.hashCode(), con2.hashCode());
+        Assert.assertTrue(con1.hashCode() != con2.hashCode());
         con2.close();
-        assertEquals(con2.hashCode(), con2.hashCode());
+        Assert.assertEquals(con2.hashCode(), con2.hashCode());
     }
 }

Modified: tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/FairnessTest.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/FairnessTest.java?rev=1459975&r1=1459974&r2=1459975&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/FairnessTest.java (original)
+++ tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/FairnessTest.java Fri Mar 22 20:41:46 2013
@@ -25,16 +25,11 @@ import java.util.concurrent.TimeUnit;
 
 import javax.sql.DataSource;
 
+import org.junit.Test;
+
 import org.apache.tomcat.jdbc.pool.DataSourceProxy;
 
-/**
- * @author Filip Hanik
- * @version 1.0
- */
 public class FairnessTest extends DefaultTestCase {
-    public FairnessTest(String name) {
-        super(name);
-    }
 
     protected boolean run = true;
     protected long sleep = Long.getLong("sleep", 10).longValue();
@@ -63,9 +58,9 @@ public class FairnessTest extends Defaul
 
     }
 
+    @Test
     public void testDBCPThreads20Connections10() throws Exception {
         System.out.println("[testDBCPThreads20Connections10] Starting fairness - DBCP");
-        init();
         this.datasource.getPoolProperties().setMaxActive(10);
         this.threadcount = 20;
         this.transferProperties();
@@ -89,12 +84,11 @@ public class FairnessTest extends Defaul
         long delta = System.currentTimeMillis() - start;
         printThreadResults(threads,"testDBCPThreads20Connections10",this.tDatasource.getNumActive(),10);
         System.out.println("Test completed in: " + delta + "ms.");
-        tearDown();
     }
 
+    @Test
     public void testPoolThreads20Connections10() throws Exception {
         System.out.println("[testPoolThreads20Connections10] Starting fairness - Tomcat JDBC - Non Fair");
-        init();
         this.datasource.getPoolProperties().setMaxActive(10);
         this.datasource.getPoolProperties().setFairQueue(false);
         this.threadcount = 20;
@@ -119,12 +113,11 @@ public class FairnessTest extends Defaul
         long delta = System.currentTimeMillis() - start;
         printThreadResults(threads,"testPoolThreads20Connections10",this.datasource.getSize(),10);
         System.out.println("Test completed in: " + delta + "ms.");
-        tearDown();
     }
 
+    @Test
     public void testPoolThreads20Connections10Fair() throws Exception {
         System.out.println("[testPoolThreads20Connections10Fair] Starting fairness - Tomcat JDBC - Fair");
-        init();
         this.datasource.getPoolProperties().setMaxActive(10);
         this.datasource.getPoolProperties().setFairQueue(true);
         this.threadcount = 20;
@@ -149,12 +142,11 @@ public class FairnessTest extends Defaul
         long delta = System.currentTimeMillis() - start;
         printThreadResults(threads,"testPoolThreads20Connections10Fair",this.datasource.getSize(),10);
         System.out.println("Test completed in: " + delta + "ms.");
-        tearDown();
     }
 
+    @Test
     public void testPoolThreads20Connections10FairAsync() throws Exception {
         System.out.println("[testPoolThreads20Connections10FairAsync] Starting fairness - Tomcat JDBC - Fair - Async");
-        init();
         this.datasource.getPoolProperties().setMaxActive(10);
         this.datasource.getPoolProperties().setFairQueue(true);
         this.threadcount = 20;
@@ -180,12 +172,11 @@ public class FairnessTest extends Defaul
         long delta = System.currentTimeMillis() - start;
         printThreadResults(threads,"testPoolThreads20Connections10FairAsync",this.datasource.getSize(),10);
         System.out.println("Test completed in: " + delta + "ms.");
-        tearDown();
     }
 
+//    @Test
 //    public void testC3P0Threads20Connections10() throws Exception {
 //        System.out.println("[testC3P0Threads20Connections10] Starting fairness - C3P0");
-//        init();
 //        this.datasource.getPoolProperties().setMaxActive(10);
 //        this.datasource.getPoolProperties().setFairQueue(false);
 //        this.threadcount = 20;
@@ -209,8 +200,6 @@ public class FairnessTest extends Defaul
 //        this.run = false;
 //        long delta = System.currentTimeMillis() - start;
 //        printThreadResults(threads,"testC3P0Threads20Connections10",c3p0Datasource.getNumConnectionsAllUsers(),10);
-//        tearDown();
-//
 //    }
 
 
@@ -282,4 +271,3 @@ public class FairnessTest extends Defaul
         }
     }
 }
-

Modified: tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/JmxPasswordTest.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/JmxPasswordTest.java?rev=1459975&r1=1459974&r2=1459975&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/JmxPasswordTest.java (original)
+++ tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/JmxPasswordTest.java Fri Mar 22 20:41:46 2013
@@ -24,6 +24,10 @@ import javax.management.JMX;
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
 
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
 import org.apache.tomcat.jdbc.pool.ConnectionPool;
 import org.apache.tomcat.jdbc.pool.PoolUtilities;
 import org.apache.tomcat.jdbc.pool.jmx.ConnectionPoolMBean;
@@ -34,13 +38,8 @@ public class JmxPasswordTest extends Def
     public static final String username = "username";
     public static ObjectName oname = null;
 
-    public JmxPasswordTest(String s) {
-        super(s);
-    }
-
-    @Override
+    @Before
     public void setUp() throws Exception {
-        super.setUp();
         this.datasource.setDriverClassName(Driver.class.getName());
         this.datasource.setUrl("jdbc:tomcat:test");
         this.datasource.setPassword(password);
@@ -58,14 +57,14 @@ public class JmxPasswordTest extends Def
 
     }
 
+    @Test
     public void testPassword() throws Exception {
-        assertEquals("Passwords should match when not using JMX.",password,datasource.getPoolProperties().getPassword());
+        Assert.assertEquals("Passwords should match when not using JMX.",password,datasource.getPoolProperties().getPassword());
         MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
         ConnectionPoolMBean mbean = JMX.newMBeanProxy(mbs, oname, ConnectionPoolMBean.class);
         String jmxPassword = mbean.getPassword();
         Properties jmxProperties = mbean.getDbProperties();
-        assertFalse("Passwords should not match.", password.equals(jmxPassword));
-        assertFalse("Password property should be missing", jmxProperties.containsKey(PoolUtilities.PROP_PASSWORD));
+        Assert.assertFalse("Passwords should not match.", password.equals(jmxPassword));
+        Assert.assertFalse("Password property should be missing", jmxProperties.containsKey(PoolUtilities.PROP_PASSWORD));
     }
-
 }

Modified: tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/MultipleCloseTest.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/MultipleCloseTest.java?rev=1459975&r1=1459974&r2=1459975&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/MultipleCloseTest.java (original)
+++ tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/MultipleCloseTest.java Fri Mar 22 20:41:46 2013
@@ -14,19 +14,18 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
 package org.apache.tomcat.jdbc.test;
 
 import java.sql.Connection;
 
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Test;
+
 import org.apache.tomcat.jdbc.test.driver.Driver;
 
 public class MultipleCloseTest extends DefaultTestCase {
 
-    public MultipleCloseTest(String name) {
-        super(name);
-    }
-
     @Override
     public org.apache.tomcat.jdbc.pool.DataSource createDefaultDataSource() {
         org.apache.tomcat.jdbc.pool.DataSource ds = super.createDefaultDataSource();
@@ -40,29 +39,31 @@ public class MultipleCloseTest extends D
         return ds;
     }
 
+    @After
     @Override
-    protected void tearDown() throws Exception {
+    public void tearDown() throws Exception {
         Driver.reset();
         super.tearDown();
     }
 
+    @Test
     public void testClosedConnectionsNotReused() throws Exception {
         this.init();
 
         Connection con1 = datasource.getConnection();
 
         // A new connection is open
-        assertFalse(con1.isClosed());
+        Assert.assertFalse(con1.isClosed());
 
         con1.close();
 
         // Confirm that a closed connection is closed
-        assertTrue(con1.isClosed());
+        Assert.assertTrue(con1.isClosed());
 
         // Open a new connection (This will re-use the previous pooled connection)
         datasource.getConnection();
 
         // A connection, once closed, should stay closed
-        assertTrue(con1.isClosed());
+        Assert.assertTrue(con1.isClosed());
     }
 }

Modified: tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/PoolCleanerTest.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/PoolCleanerTest.java?rev=1459975&r1=1459974&r2=1459975&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/PoolCleanerTest.java (original)
+++ tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/PoolCleanerTest.java Fri Mar 22 20:41:46 2013
@@ -14,20 +14,18 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
 package org.apache.tomcat.jdbc.test;
 
 import java.util.Map;
 
+import org.junit.Assert;
+import org.junit.Test;
+
 import org.apache.tomcat.jdbc.pool.ConnectionPool;
 import org.apache.tomcat.jdbc.pool.DataSource;
 
 public class PoolCleanerTest extends DefaultTestCase {
 
-    public PoolCleanerTest(String name) {
-        super(name);
-    }
-
     private int countPoolCleanerThreads() {
         Map<Thread, StackTraceElement[]> threadmap = Thread.getAllStackTraces();
         int result = 0;
@@ -37,52 +35,55 @@ public class PoolCleanerTest extends Def
         return result;
     }
 
+    @Test
     public void testPoolCleaner() throws Exception {
         datasource.getPoolProperties().setTimeBetweenEvictionRunsMillis(2000);
         datasource.getPoolProperties().setTestWhileIdle(true);
-        assertEquals("Pool cleaner should not be started yet.",0,ConnectionPool.getPoolCleaners().size() );
-        assertNull("Pool timer should be null", ConnectionPool.getPoolTimer());
-        assertEquals("Pool cleaner threads should not be present.",0, countPoolCleanerThreads());
+        Assert.assertEquals("Pool cleaner should not be started yet.",0,ConnectionPool.getPoolCleaners().size() );
+        Assert.assertNull("Pool timer should be null", ConnectionPool.getPoolTimer());
+        Assert.assertEquals("Pool cleaner threads should not be present.",0, countPoolCleanerThreads());
 
         datasource.getConnection().close();
-        assertEquals("Pool cleaner should have 1 cleaner.",1,ConnectionPool.getPoolCleaners().size() );
-        assertNotNull("Pool timer should not be null", ConnectionPool.getPoolTimer());
-        assertEquals("Pool cleaner threads should be 1.",1, countPoolCleanerThreads());
+        Assert.assertEquals("Pool cleaner should have 1 cleaner.",1,ConnectionPool.getPoolCleaners().size() );
+        Assert.assertNotNull("Pool timer should not be null", ConnectionPool.getPoolTimer());
+        Assert.assertEquals("Pool cleaner threads should be 1.",1, countPoolCleanerThreads());
 
         datasource.close();
-        assertEquals("Pool shutdown, no cleaners should be present.",0,ConnectionPool.getPoolCleaners().size() );
-        assertNull("Pool timer should be null after shutdown", ConnectionPool.getPoolTimer());
-        assertEquals("Pool cleaner threads should not be present after close.",0, countPoolCleanerThreads());
+        Assert.assertEquals("Pool shutdown, no cleaners should be present.",0,ConnectionPool.getPoolCleaners().size() );
+        Assert.assertNull("Pool timer should be null after shutdown", ConnectionPool.getPoolTimer());
+        Assert.assertEquals("Pool cleaner threads should not be present after close.",0, countPoolCleanerThreads());
 
 
     }
 
+    @Test
     public void test2PoolCleaners() throws Exception {
         datasource.getPoolProperties().setTimeBetweenEvictionRunsMillis(2000);
         datasource.getPoolProperties().setTestWhileIdle(true);
 
         DataSource ds2 = new DataSource(datasource.getPoolProperties());
 
-        assertEquals("Pool cleaner should not be started yet.",0,ConnectionPool.getPoolCleaners().size() );
-        assertNull("Pool timer should be null", ConnectionPool.getPoolTimer());
-        assertEquals("Pool cleaner threads should not be present.",0, countPoolCleanerThreads());
+        Assert.assertEquals("Pool cleaner should not be started yet.",0,ConnectionPool.getPoolCleaners().size() );
+        Assert.assertNull("Pool timer should be null", ConnectionPool.getPoolTimer());
+        Assert.assertEquals("Pool cleaner threads should not be present.",0, countPoolCleanerThreads());
 
         datasource.getConnection().close();
         ds2.getConnection().close();
-        assertEquals("Pool cleaner should have 2 cleaner.",2,ConnectionPool.getPoolCleaners().size() );
-        assertNotNull("Pool timer should not be null", ConnectionPool.getPoolTimer());
-        assertEquals("Pool cleaner threads should be 1.",1, countPoolCleanerThreads());
+        Assert.assertEquals("Pool cleaner should have 2 cleaner.",2,ConnectionPool.getPoolCleaners().size() );
+        Assert.assertNotNull("Pool timer should not be null", ConnectionPool.getPoolTimer());
+        Assert.assertEquals("Pool cleaner threads should be 1.",1, countPoolCleanerThreads());
 
         datasource.close();
-        assertEquals("Pool cleaner should have 1 cleaner.",1,ConnectionPool.getPoolCleaners().size() );
-        assertNotNull("Pool timer should not be null", ConnectionPool.getPoolTimer());
+        Assert.assertEquals("Pool cleaner should have 1 cleaner.",1,ConnectionPool.getPoolCleaners().size() );
+        Assert.assertNotNull("Pool timer should not be null", ConnectionPool.getPoolTimer());
 
         ds2.close();
-        assertEquals("Pool shutdown, no cleaners should be present.",0,ConnectionPool.getPoolCleaners().size() );
-        assertNull("Pool timer should be null after shutdown", ConnectionPool.getPoolTimer());
-        assertEquals("Pool cleaner threads should not be present after close.",0, countPoolCleanerThreads());
+        Assert.assertEquals("Pool shutdown, no cleaners should be present.",0,ConnectionPool.getPoolCleaners().size() );
+        Assert.assertNull("Pool timer should be null after shutdown", ConnectionPool.getPoolTimer());
+        Assert.assertEquals("Pool cleaner threads should not be present after close.",0, countPoolCleanerThreads());
     }
 
+    @Test
     public void testIdleTimeout() throws Exception {
         datasource.getPoolProperties().setTimeBetweenEvictionRunsMillis(2000);
         datasource.getPoolProperties().setTestWhileIdle(true);
@@ -91,10 +92,8 @@ public class PoolCleanerTest extends Def
         datasource.getPoolProperties().setMinIdle(0);
         datasource.getPoolProperties().setMinEvictableIdleTimeMillis(1000);
         datasource.getConnection().close();
-        assertEquals("Pool should have 1 idle.", 1, datasource.getIdle());
+        Assert.assertEquals("Pool should have 1 idle.", 1, datasource.getIdle());
         Thread.sleep(3000);
-        assertEquals("Pool should have 0 idle.", 0, datasource.getIdle());
+        Assert.assertEquals("Pool should have 0 idle.", 0, datasource.getIdle());
     }
-
-
 }

Modified: tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/PoolPurgeTest.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/PoolPurgeTest.java?rev=1459975&r1=1459974&r2=1459975&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/PoolPurgeTest.java (original)
+++ tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/PoolPurgeTest.java Fri Mar 22 20:41:46 2013
@@ -18,16 +18,13 @@ package org.apache.tomcat.jdbc.test;
 
 import java.sql.Connection;
 
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Test;
+
 import org.apache.tomcat.jdbc.test.driver.Driver;
 
-/**
- * @author Filip Hanik
- * @version 1.0
- */
 public class PoolPurgeTest extends DefaultTestCase {
-    public PoolPurgeTest(String name) {
-        super(name);
-    }
 
     static final int expectedSize = 2;
 
@@ -49,43 +46,41 @@ public class PoolPurgeTest extends Defau
 
 
     @Override
-    protected void tearDown() throws Exception {
+    @After
+    public void tearDown() throws Exception {
         Driver.reset();
         super.tearDown();
     }
 
 
-
+    @Test
     public void testPoolPurge() throws Exception {
-        init();
         this.datasource.getConnection().close();
-        assertEquals("Nr of connections should be "+expectedSize, expectedSize , datasource.getSize());
+        Assert.assertEquals("Nr of connections should be "+expectedSize, expectedSize , datasource.getSize());
         this.datasource.purge();
-        assertEquals("Nr of connections should be 0", 0 , datasource.getSize());
-        tearDown();
+        Assert.assertEquals("Nr of connections should be 0", 0 , datasource.getSize());
     }
 
+    @Test
     public void testPoolPurgeWithActive() throws Exception {
-        init();
         Connection con = datasource.getConnection();
-        assertEquals("Nr of connections should be "+expectedSize, expectedSize , datasource.getSize());
+        Assert.assertEquals("Nr of connections should be "+expectedSize, expectedSize , datasource.getSize());
         this.datasource.purge();
-        assertEquals("Nr of connections should be "+(expectedSize-1), (expectedSize-1) , datasource.getSize());
+        Assert.assertEquals("Nr of connections should be "+(expectedSize-1), (expectedSize-1) , datasource.getSize());
         con.close();
-        assertEquals("Nr of connections should be 0", 0 , datasource.getSize());
-        tearDown();
+        Assert.assertEquals("Nr of connections should be 0", 0 , datasource.getSize());
     }
 
+    @Test
     public void testPoolPurgeOnReturn() throws Exception {
         init();
         Connection con = datasource.getConnection();
-        assertEquals("Nr of connections should be "+expectedSize, expectedSize , datasource.getSize());
+        Assert.assertEquals("Nr of connections should be "+expectedSize, expectedSize , datasource.getSize());
         this.datasource.purgeOnReturn();
-        assertEquals("Nr of connections should be "+expectedSize, expectedSize , datasource.getSize());
+        Assert.assertEquals("Nr of connections should be "+expectedSize, expectedSize , datasource.getSize());
         con.close();
-        assertEquals("Nr of connections should be "+(expectedSize-1), (expectedSize-1) , datasource.getSize());
+        Assert.assertEquals("Nr of connections should be "+(expectedSize-1), (expectedSize-1) , datasource.getSize());
         tearDown();
     }
-
 }
 

Modified: tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/StarvationTest.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/StarvationTest.java?rev=1459975&r1=1459974&r2=1459975&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/StarvationTest.java (original)
+++ tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/StarvationTest.java Fri Mar 22 20:41:46 2013
@@ -19,20 +19,17 @@ package org.apache.tomcat.jdbc.test;
 import java.sql.Connection;
 import java.sql.SQLException;
 
+import org.junit.Assert;
+import org.junit.Test;
+
 /**
  * If a connection is abandoned and closed,
  * then that should free up a spot in the pool, and other threads
  * that are waiting should not time out and throw an error but be
  * able to acquire a connection, since one was just released.
- * @author fhanik
- *
  */
 public class StarvationTest extends DefaultTestCase {
 
-    public StarvationTest(String name) {
-        super(name);
-    }
-
     private void config() {
         datasource.getPoolProperties().setMaxActive(1);
         datasource.getPoolProperties().setMaxIdle(1);
@@ -44,8 +41,8 @@ public class StarvationTest extends Defa
         datasource.getPoolProperties().setLogAbandoned(true);
     }
 
+//    @Test
 //    public void testDBCPConnectionStarvation() throws Exception {
-//        init();
 //        config();
 //        this.transferProperties();
 //        this.tDatasource.getConnection().close();
@@ -65,11 +62,10 @@ public class StarvationTest extends Defa
 //        }finally {
 //            if (con2!=null) con2.close();
 //        }
-//
 //    }
 
+    @Test
     public void testConnectionStarvation() throws Exception {
-        init();
         config();
         Connection con1 = datasource.getConnection();
         Connection con2 = null;
@@ -78,16 +74,17 @@ public class StarvationTest extends Defa
             try {
                 con2.setCatalog("mysql");//make sure connection is valid
             }catch (SQLException x) {
-                assertFalse("2nd Connection is not valid:"+x.getMessage(),true);
+                Assert.assertFalse("2nd Connection is not valid:"+x.getMessage(),true);
             }
-            assertTrue("Connection 1 should be closed.",con1.isClosed()); //first connection should be closed
+            Assert.assertTrue("Connection 1 should be closed.",con1.isClosed()); //first connection should be closed
         }catch (Exception x) {
-            assertFalse("Connection got starved:"+x.getMessage(),true);
+            Assert.assertFalse("Connection got starved:"+x.getMessage(),true);
         }finally {
             if (con2!=null) con2.close();
         }
     }
 
+    @Test
     public void testFairConnectionStarvation() throws Exception {
         init();
         config();
@@ -99,11 +96,11 @@ public class StarvationTest extends Defa
             try {
                 con2.setCatalog("mysql");//make sure connection is valid
             }catch (SQLException x) {
-                assertFalse("2nd Connection is not valid:"+x.getMessage(),true);
+                Assert.assertFalse("2nd Connection is not valid:"+x.getMessage(),true);
             }
-            assertTrue("Connection 1 should be closed.",con1.isClosed()); //first connection should be closed
+            Assert.assertTrue("Connection 1 should be closed.",con1.isClosed()); //first connection should be closed
         }catch (Exception x) {
-            assertFalse("Connection got starved:"+x.getMessage(),true);
+            Assert.assertFalse("Connection got starved:"+x.getMessage(),true);
         }finally {
             if (con2!=null) con2.close();
         }

Modified: tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/StatementFinalizerTest.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/StatementFinalizerTest.java?rev=1459975&r1=1459974&r2=1459975&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/StatementFinalizerTest.java (original)
+++ tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/StatementFinalizerTest.java Fri Mar 22 20:41:46 2013
@@ -14,28 +14,25 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
 package org.apache.tomcat.jdbc.test;
 
 import java.sql.Connection;
 import java.sql.Statement;
 
+import org.junit.Assert;
+import org.junit.Test;
+
 import org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer;
 
 public class StatementFinalizerTest extends DefaultTestCase {
 
-    public StatementFinalizerTest(String name) {
-        super(name);
-    }
-
+    @Test
     public void testStatementFinalization() throws Exception {
-        this.init();
         datasource.setJdbcInterceptors(StatementFinalizer.class.getName());
         Connection con = datasource.getConnection();
         Statement st = con.createStatement();
-        assertFalse("Statement should not be closed.",st.isClosed());
+        Assert.assertFalse("Statement should not be closed.",st.isClosed());
         con.close();
-        assertTrue("Statement should be closed.",st.isClosed());
+        Assert.assertTrue("Statement should be closed.",st.isClosed());
     }
-
 }

Modified: tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestAsyncQueue.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestAsyncQueue.java?rev=1459975&r1=1459974&r2=1459975&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestAsyncQueue.java (original)
+++ tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestAsyncQueue.java Fri Mar 22 20:41:46 2013
@@ -21,32 +21,38 @@ import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 
-import junit.framework.TestCase;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
 
 import org.apache.tomcat.jdbc.pool.FairBlockingQueue;
 
-public class TestAsyncQueue extends TestCase {
+public class TestAsyncQueue {
+
     protected FairBlockingQueue<Object> queue = null;
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
+
+    @Before
+    public void setUp() throws Exception {
         this.queue = new FairBlockingQueue<Object>();
     }
 
-    @Override
-    protected void tearDown() throws Exception {
+    @After
+    public void tearDown() throws Exception {
         this.queue = null;
-        super.tearDown();
     }
 
 
+    @Test
     public void testAsyncPoll1() throws Exception {
         Object item = new Object();
         queue.offer(item);
         Future<Object> future = queue.pollAsync();
-        assertEquals(future.get(),item);
+        Assert.assertEquals(future.get(),item);
     }
 
+
+    @Test
     public void testAsyncPoll2() throws Exception {
         Object item = new Object();
         OfferThread thread = new OfferThread(item,5000);
@@ -54,14 +60,14 @@ public class TestAsyncQueue extends Test
         Future<Object> future = queue.pollAsync();
         try {
             future.get(2000, TimeUnit.MILLISECONDS);
-            assertFalse("Request should have timed out",true);
+            Assert.assertFalse("Request should have timed out",true);
         }catch (TimeoutException x) {
-            assertTrue("Request timed out properly",true);
+            Assert.assertTrue("Request timed out properly",true);
         }catch (Exception x) {
-            assertTrue("Request threw an error",false);
+            Assert.assertTrue("Request threw an error",false);
             x.printStackTrace();
         }
-        assertEquals(future.get(),item);
+        Assert.assertEquals(future.get(),item);
     }
 
     protected class OfferThread extends Thread {

Modified: tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestConcurrency.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestConcurrency.java?rev=1459975&r1=1459974&r2=1459975&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestConcurrency.java (original)
+++ tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestConcurrency.java Fri Mar 22 20:41:46 2013
@@ -14,12 +14,16 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
 package org.apache.tomcat.jdbc.test;
 
 import java.sql.Connection;
 import java.util.concurrent.atomic.AtomicInteger;
 
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
 import org.apache.tomcat.jdbc.pool.DataSource;
 import org.apache.tomcat.jdbc.test.driver.Driver;
 
@@ -29,13 +33,8 @@ public class TestConcurrency extends Def
 
     protected volatile DataSource ds = null;
 
-    public TestConcurrency(String name) {
-        super(name);
-    }
-
-    @Override
+    @Before
     public void setUp() throws Exception {
-        super.setUp();
         ds = createDefaultDataSource();
         ds.getPoolProperties().setDriverClassName(Driver.class.getName());
         ds.getPoolProperties().setUrl(Driver.url);
@@ -52,12 +51,14 @@ public class TestConcurrency extends Def
     }
 
     @Override
-    protected void tearDown() throws Exception {
+    @After
+    public void tearDown() throws Exception {
         ds.close(true);
         Driver.reset();
         super.tearDown();
     }
 
+    @Test
     public void testSimple() throws Exception {
         ds.getConnection().close();
         final int iter = 1000 * 10;
@@ -86,7 +87,7 @@ public class TestConcurrency extends Def
         }
         try {
             while (loopcount.get()<iter) {
-                assertTrue("Size comparison(less than 11):",ds.getPool().getSize()<=10);
+                Assert.assertTrue("Size comparison(less than 11):",ds.getPool().getSize()<=10);
                 if (debug) {
                     System.out.println("Size: "+ds.getPool().getSize());
                     System.out.println("Used: "+ds.getPool().getActive());
@@ -102,13 +103,14 @@ public class TestConcurrency extends Def
         for (int i=0; i<threads.length; i++) {
             threads[i].join();
         }
-        assertEquals("Size comparison:",10, ds.getPool().getSize());
-        assertEquals("Idle comparison:",10, ds.getPool().getIdle());
-        assertEquals("Used comparison:",0, ds.getPool().getActive());
-        assertEquals("Connect count",10,Driver.connectCount.get());
+        Assert.assertEquals("Size comparison:",10, ds.getPool().getSize());
+        Assert.assertEquals("Idle comparison:",10, ds.getPool().getIdle());
+        Assert.assertEquals("Used comparison:",0, ds.getPool().getActive());
+        Assert.assertEquals("Connect count",10,Driver.connectCount.get());
 
     }
 
+    @Test
     public void testBrutal() throws Exception {
         ds.getPoolProperties().setRemoveAbandoned(false);
         ds.getPoolProperties().setRemoveAbandonedTimeout(1);
@@ -140,7 +142,7 @@ public class TestConcurrency extends Def
         }
         try {
             while (loopcount.get()<iter) {
-                assertTrue("Size comparison(less than 11):",ds.getPool().getSize()<=10);
+                Assert.assertTrue("Size comparison(less than 11):",ds.getPool().getSize()<=10);
                 ds.getPool().testAllIdle();
                 ds.getPool().checkAbandoned();
                 ds.getPool().checkIdle();
@@ -154,12 +156,13 @@ public class TestConcurrency extends Def
         }
         System.out.println("Connect count:"+Driver.connectCount.get());
         System.out.println("DisConnect count:"+Driver.disconnectCount.get());
-        assertEquals("Size comparison:",10, ds.getPool().getSize());
-        assertEquals("Idle comparison:",10, ds.getPool().getIdle());
-        assertEquals("Used comparison:",0, ds.getPool().getActive());
-        assertEquals("Connect count",10,Driver.connectCount.get());
+        Assert.assertEquals("Size comparison:",10, ds.getPool().getSize());
+        Assert.assertEquals("Idle comparison:",10, ds.getPool().getIdle());
+        Assert.assertEquals("Used comparison:",0, ds.getPool().getActive());
+        Assert.assertEquals("Connect count",10,Driver.connectCount.get());
     }
 
+    @Test
     public void testBrutalNonFair() throws Exception {
         ds.getPoolProperties().setRemoveAbandoned(false);
         ds.getPoolProperties().setRemoveAbandonedTimeout(1);
@@ -191,7 +194,7 @@ public class TestConcurrency extends Def
         }
         try {
             while (loopcount.get()<iter) {
-                assertTrue("Size comparison(less than 11):",ds.getPool().getSize()<=10);
+                Assert.assertTrue("Size comparison(less than 11):",ds.getPool().getSize()<=10);
                 ds.getPool().testAllIdle();
                 ds.getPool().checkAbandoned();
                 ds.getPool().checkIdle();
@@ -205,10 +208,9 @@ public class TestConcurrency extends Def
         }
         System.out.println("Connect count:"+Driver.connectCount.get());
         System.out.println("DisConnect count:"+Driver.disconnectCount.get());
-        assertEquals("Size comparison:",10, ds.getPool().getSize());
-        assertEquals("Idle comparison:",10, ds.getPool().getIdle());
-        assertEquals("Used comparison:",0, ds.getPool().getActive());
-        assertEquals("Connect count",10,Driver.connectCount.get());
+        Assert.assertEquals("Size comparison:",10, ds.getPool().getSize());
+        Assert.assertEquals("Idle comparison:",10, ds.getPool().getIdle());
+        Assert.assertEquals("Used comparison:",0, ds.getPool().getActive());
+        Assert.assertEquals("Connect count",10,Driver.connectCount.get());
     }
-
 }

Modified: tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestConnectionState.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestConnectionState.java?rev=1459975&r1=1459974&r2=1459975&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestConnectionState.java (original)
+++ tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestConnectionState.java Fri Mar 22 20:41:46 2013
@@ -18,15 +18,15 @@ package org.apache.tomcat.jdbc.test;
 
 import java.sql.Connection;
 
+import org.junit.Assert;
+import org.junit.Test;
+
 import org.apache.tomcat.jdbc.pool.DataSourceProxy;
 import org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;
 
 public class TestConnectionState extends DefaultTestCase {
 
-    public TestConnectionState(String name) {
-        super(name);
-    }
-
+    @Test
     public void testAutoCommitFalse() throws Exception {
         DataSourceProxy d1 = this.createDefaultDataSource();
         d1.setMaxActive(1);
@@ -35,16 +35,17 @@ public class TestConnectionState extends
         d1.setJdbcInterceptors(ConnectionState.class.getName());
         d1.setDefaultAutoCommit(Boolean.FALSE);
         Connection c1 = d1.getConnection();
-        assertFalse("Auto commit should be false",c1.getAutoCommit());
+        Assert.assertFalse("Auto commit should be false",c1.getAutoCommit());
         c1.setAutoCommit(true);
-        assertTrue("Auto commit should be true",c1.getAutoCommit());
+        Assert.assertTrue("Auto commit should be true",c1.getAutoCommit());
         c1.close();
         c1 = d1.getConnection();
-        assertFalse("Auto commit should be false for a reused connection",c1.getAutoCommit());
+        Assert.assertFalse("Auto commit should be false for a reused connection",c1.getAutoCommit());
         d1.close(true);
-        assertTrue("Connection should be closed",c1.isClosed());
+        Assert.assertTrue("Connection should be closed",c1.isClosed());
     }
 
+    @Test
     public void testAutoCommitTrue() throws Exception {
         DataSourceProxy d1 = this.createDefaultDataSource();
         d1.setMaxActive(1);
@@ -52,14 +53,15 @@ public class TestConnectionState extends
         d1.setDefaultAutoCommit(Boolean.TRUE);
         d1.setMinIdle(1);
         Connection c1 = d1.getConnection();
-        assertTrue("Auto commit should be true",c1.getAutoCommit());
+        Assert.assertTrue("Auto commit should be true",c1.getAutoCommit());
         c1.setAutoCommit(false);
-        assertFalse("Auto commit should be false",c1.getAutoCommit());
+        Assert.assertFalse("Auto commit should be false",c1.getAutoCommit());
         c1.close();
         c1 = d1.getConnection();
-        assertTrue("Auto commit should be true for a reused connection",c1.getAutoCommit());
+        Assert.assertTrue("Auto commit should be true for a reused connection",c1.getAutoCommit());
     }
 
+    @Test
     public void testDefaultCatalog() throws Exception {
         DataSourceProxy d1 = this.createDefaultDataSource();
         d1.setMaxActive(1);
@@ -67,16 +69,14 @@ public class TestConnectionState extends
         d1.setDefaultCatalog("information_schema");
         d1.setMinIdle(1);
         Connection c1 = d1.getConnection();
-        assertEquals("Catalog should be information_schema",c1.getCatalog(),"information_schema");
+        Assert.assertEquals("Catalog should be information_schema",c1.getCatalog(),"information_schema");
         c1.close();
         c1 = d1.getConnection();
-        assertEquals("Catalog should be information_schema",c1.getCatalog(),"information_schema");
+        Assert.assertEquals("Catalog should be information_schema",c1.getCatalog(),"information_schema");
         c1.setCatalog("mysql");
-        assertEquals("Catalog should be information_schema",c1.getCatalog(),"mysql");
+        Assert.assertEquals("Catalog should be information_schema",c1.getCatalog(),"mysql");
         c1.close();
         c1 = d1.getConnection();
-        assertEquals("Catalog should be information_schema",c1.getCatalog(),"information_schema");
+        Assert.assertEquals("Catalog should be information_schema",c1.getCatalog(),"information_schema");
     }
-
-
 }

Modified: tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestException.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestException.java?rev=1459975&r1=1459974&r2=1459975&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestException.java (original)
+++ tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestException.java Fri Mar 22 20:41:46 2013
@@ -14,29 +14,26 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
 package org.apache.tomcat.jdbc.test;
 
 import java.sql.Connection;
 
+import org.junit.Test;
+
 import org.apache.tomcat.jdbc.pool.ConnectionPool;
 import org.apache.tomcat.jdbc.pool.JdbcInterceptor;
 import org.apache.tomcat.jdbc.pool.PooledConnection;
 
 public class TestException extends DefaultTestCase {
 
-    public TestException(String name) {
-        super(name);
-    }
-
+    @Test
     public void testException() throws Exception {
-        init();
         datasource.getPoolProperties().setJdbcInterceptors(TestInterceptor.class.getName());
         Connection con = datasource.getConnection();
         try {
             con.createStatement();
         }catch (Exception x) {
-
+            // Ignore
         }
     }
 
@@ -46,10 +43,6 @@ public class TestException extends Defau
         @Override
         public void reset(ConnectionPool parent, PooledConnection con) {
             // TODO Auto-generated method stub
-
         }
-
-
     }
-
 }

Modified: tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestGCClose.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestGCClose.java?rev=1459975&r1=1459974&r2=1459975&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestGCClose.java (original)
+++ tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestGCClose.java Fri Mar 22 20:41:46 2013
@@ -16,25 +16,20 @@
  */
 package org.apache.tomcat.jdbc.test;
 
-/**
- * @author Filip Hanik
- * @version 1.0
- */
+import org.junit.Test;
+
 public class TestGCClose extends DefaultTestCase {
-    public TestGCClose(String name) {
-        super(name);
-    }
 
+    @Test
     public void testGCStop() throws Exception {
-        init();
         datasource.getConnection();
         System.out.println("Got a connection, but didn't return it");
         tearDown();
         Thread.sleep(20000);
     }
 
+    @Test
     public void testClose() throws Exception {
-        init();
         datasource.getConnection();
         System.out.println("Got a connection, but didn't return it");
         datasource.close(true);

Modified: tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestGetConnection.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestGetConnection.java?rev=1459975&r1=1459974&r2=1459975&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestGetConnection.java (original)
+++ tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestGetConnection.java Fri Mar 22 20:41:46 2013
@@ -14,27 +14,23 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
 package org.apache.tomcat.jdbc.test;
 
 import java.sql.Connection;
 
 import javax.sql.PooledConnection;
 
-public class TestGetConnection extends DefaultTestCase {
+import org.junit.Assert;
+import org.junit.Test;
 
-    public TestGetConnection(String name) {
-        super(name);
-    }
+public class TestGetConnection extends DefaultTestCase {
 
+    @Test
     public void testGetConnection() throws Exception {
-        this.init();
         Connection con = this.datasource.getConnection();
-        assertTrue("Connection should implement javax.sql.PooledConnection",con instanceof PooledConnection);
+        Assert.assertTrue("Connection should implement javax.sql.PooledConnection",con instanceof PooledConnection);
         Connection actual = ((PooledConnection)con).getConnection();
-        assertNotNull("Connection delegate should not be null.",actual);
+        Assert.assertNotNull("Connection delegate should not be null.",actual);
         System.out.println("Actual connection:"+actual.getClass().getName());
-
     }
-
 }

Modified: tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestInterceptorShortName.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestInterceptorShortName.java?rev=1459975&r1=1459974&r2=1459975&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestInterceptorShortName.java (original)
+++ tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestInterceptorShortName.java Fri Mar 22 20:41:46 2013
@@ -14,34 +14,31 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
 package org.apache.tomcat.jdbc.test;
 
 import java.sql.Connection;
 
+import org.junit.Assert;
+import org.junit.Test;
+
 import org.apache.tomcat.jdbc.pool.interceptor.TestInterceptor;
 
 public class TestInterceptorShortName extends DefaultTestCase {
 
-    public TestInterceptorShortName(String name) {
-        super(name);
-    }
-
+    @Test
     public void testShortInterceptor() throws Exception {
         this.datasource = this.createDefaultDataSource();
         this.datasource.setJdbcInterceptors("TestInterceptor");
         this.datasource.setUseDisposableConnectionFacade(false);
         this.datasource.setMaxActive(1);
         this.datasource.createPool();
-        assertEquals("Only one interceptor should have been called setProperties[1]",1,TestInterceptor.instancecount.get());
+        Assert.assertEquals("Only one interceptor should have been called setProperties[1]",1,TestInterceptor.instancecount.get());
         TestInterceptor.instancecount.set(0);
         Connection con = this.datasource.getConnection();
-        assertTrue("Pool should have been started.",TestInterceptor.poolstarted);
-        assertEquals("Only one interceptor should have been called setProperties[2]",1,TestInterceptor.instancecount.get());
+        Assert.assertTrue("Pool should have been started.",TestInterceptor.poolstarted);
+        Assert.assertEquals("Only one interceptor should have been called setProperties[2]",1,TestInterceptor.instancecount.get());
         con.close();
         this.datasource.close();
-        assertTrue("Pool should have been closed.",TestInterceptor.poolclosed);
+        Assert.assertTrue("Pool should have been closed.",TestInterceptor.poolclosed);
     }
-
-
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message