commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject svn commit: r1649422 [2/2] - in /commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2: ./ cpdsadapter/ datasources/ managed/
Date Sun, 04 Jan 2015 21:10:47 GMT
Modified: commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestSharedPoolDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestSharedPoolDataSource.java?rev=1649422&r1=1649421&r2=1649422&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestSharedPoolDataSource.java
(original)
+++ commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestSharedPoolDataSource.java
Sun Jan  4 21:10:47 2015
@@ -17,6 +17,11 @@
 
 package org.apache.commons.dbcp2.datasources;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
@@ -30,16 +35,15 @@ import org.apache.commons.dbcp2.Delegati
 import org.apache.commons.dbcp2.TestConnectionPool;
 import org.apache.commons.dbcp2.TesterDriver;
 import org.apache.commons.dbcp2.cpdsadapter.DriverAdapterCPDS;
+import org.junit.Before;
+import org.junit.Test;
 
 /**
  * @author John McNally
  * @author Dirk Verbeeck
- * @version $Revision$ $Date$
+ * @version $Id$
  */
 public class TestSharedPoolDataSource extends TestConnectionPool {
-    public TestSharedPoolDataSource(String testName) {
-        super(testName);
-    }
 
     @Override
     protected Connection getConnection() throws Exception {
@@ -49,9 +53,8 @@ public class TestSharedPoolDataSource ex
     private DriverAdapterCPDS pcds;
     private DataSource ds;
 
-    @Override
+    @Before
     public void setUp() throws Exception {
-        super.setUp();
         pcds = new DriverAdapterCPDS();
         pcds.setDriver("org.apache.commons.dbcp2.TesterDriver");
         pcds.setUrl("jdbc:apache:commons:testdriver");
@@ -81,6 +84,7 @@ public class TestSharedPoolDataSource ex
      * then correct password for same user illustrates
      * JIRA: DBCP-245
      */
+    @Test
     public void testIncorrectPassword() throws Exception {
 
         ds.getConnection("u2", "p2").close();
@@ -118,6 +122,7 @@ public class TestSharedPoolDataSource ex
 
 
     @Override
+    @Test
     public void testSimple() throws Exception
     {
         Connection conn = ds.getConnection();
@@ -132,6 +137,7 @@ public class TestSharedPoolDataSource ex
         conn.close();
     }
 
+    @Test
     public void testSimpleWithUsername() throws Exception
     {
         Connection conn = ds.getConnection("u1", "p1");
@@ -146,6 +152,7 @@ public class TestSharedPoolDataSource ex
         conn.close();
     }
 
+    @Test
     public void testClosingWithUserName()
         throws Exception
     {
@@ -177,6 +184,7 @@ public class TestSharedPoolDataSource ex
     }
 
     @Override
+    @Test
     public void testSimple2()
         throws Exception
     {
@@ -231,6 +239,7 @@ public class TestSharedPoolDataSource ex
     }
 
     @Override
+    @Test
     public void testOpening()
         throws Exception
     {
@@ -252,6 +261,7 @@ public class TestSharedPoolDataSource ex
     }
 
     @Override
+    @Test
     public void testClosing()
         throws Exception
     {
@@ -279,6 +289,7 @@ public class TestSharedPoolDataSource ex
      *
      * @throws Exception
      */
+    @Test
     public void testClosePool() throws Exception {
       ((SharedPoolDataSource)ds).close();
       SharedPoolDataSource tds = new SharedPoolDataSource();
@@ -287,6 +298,7 @@ public class TestSharedPoolDataSource ex
     }
 
     @Override
+    @Test
     public void testMaxTotal() throws Exception {
         Connection[] c = new Connection[getMaxTotal()];
         for (int i=0; i<c.length; i++) {
@@ -306,6 +318,7 @@ public class TestSharedPoolDataSource ex
         }
     }
 
+    @Test
     public void testMaxWaitMillis() throws Exception {
         final int maxWaitMillis = 1000;
         final int theadCount = 20;
@@ -350,6 +363,7 @@ public class TestSharedPoolDataSource ex
         }
     }
 
+    @Test
     public void testMultipleThreads1() throws Exception {
         // Override wait time in order to allow for Thread.sleep(1) sometimes taking a lot
longer on
         // some JVMs, e.g. Windows.
@@ -358,12 +372,14 @@ public class TestSharedPoolDataSource ex
         multipleThreads(1, false, false, defaultMaxWaitMillis);
     }
 
+    @Test
     public void testMultipleThreads2() throws Exception {
         final int defaultMaxWaitMillis = 500;
         ((SharedPoolDataSource) ds).setDefaultMaxWaitMillis(defaultMaxWaitMillis);
         multipleThreads(2 * defaultMaxWaitMillis, true, true, defaultMaxWaitMillis);
     }
 
+    @Test
     public void testTransactionIsolationBehavior() throws Exception {
         Connection conn = getConnection();
         assertNotNull(conn);
@@ -385,6 +401,7 @@ public class TestSharedPoolDataSource ex
 
     // Bugzilla Bug 24136 ClassCastException in DriverAdapterCPDS
     // when setPoolPreparedStatements(true)
+    @Test
     public void testPoolPrepareStatement() throws Exception
     {
         pcds.setPoolPreparedStatements(true);
@@ -522,6 +539,8 @@ public class TestSharedPoolDataSource ex
         conn.close();
         conn = null;
     }
+
+    @Test
     public void testPoolPreparedStatements() throws Exception {
         doTestPoolPreparedStatements(new PscbString());
         doTestPoolPreparedStatements(new PscbStringIntInt());
@@ -532,6 +551,7 @@ public class TestSharedPoolDataSource ex
     }
 
     // See DBCP-8
+    @Test
     public void testChangePassword() throws Exception {
         try (Connection c = ds.getConnection("foo", "bay")){
             fail("Should have generated SQLException");
@@ -566,6 +586,7 @@ public class TestSharedPoolDataSource ex
         }
     }
 
+    @Test
     public void testDbcp369() {
         final ArrayList<SharedPoolDataSource> dataSources = new ArrayList<>();
         for (int j = 0; j < 10000; j++) {

Modified: commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestBasicManagedDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestBasicManagedDataSource.java?rev=1649422&r1=1649421&r2=1649422&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestBasicManagedDataSource.java
(original)
+++ commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestBasicManagedDataSource.java
Sun Jan  4 21:10:47 2015
@@ -17,18 +17,20 @@
  */
 package org.apache.commons.dbcp2.managed;
 
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
 import java.sql.SQLException;
+
 import org.apache.commons.dbcp2.BasicDataSource;
 import org.apache.commons.dbcp2.TestBasicDataSource;
 import org.apache.geronimo.transaction.manager.TransactionManagerImpl;
+import org.junit.Test;
 
 /**
  * TestSuite for BasicManagedDataSource
  */
 public class TestBasicManagedDataSource extends TestBasicDataSource {
-    public TestBasicManagedDataSource(String testName) {
-        super(testName);
-    }
 
     @Override
     protected BasicDataSource createDataSource() throws Exception {
@@ -42,6 +44,7 @@ public class TestBasicManagedDataSource
      * Verify that PoolableConnections created by BasicManagedDataSource unregister themselves
      * when reallyClosed.
      */
+    @Test
     public void testReallyClose() throws Exception {
         BasicManagedDataSource basicManagedDataSource = new BasicManagedDataSource();
         basicManagedDataSource.setTransactionManager(new TransactionManagerImpl());

Modified: commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestDataSourceXAConnectionFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestDataSourceXAConnectionFactory.java?rev=1649422&r1=1649421&r2=1649422&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestDataSourceXAConnectionFactory.java
(original)
+++ commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestDataSourceXAConnectionFactory.java
Sun Jan  4 21:10:47 2015
@@ -17,6 +17,8 @@
  */
 package org.apache.commons.dbcp2.managed;
 
+import static org.junit.Assert.assertEquals;
+
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
@@ -30,6 +32,8 @@ import javax.sql.XADataSource;
 
 import org.apache.commons.dbcp2.TestBasicDataSource;
 import org.apache.geronimo.transaction.manager.TransactionManagerImpl;
+import org.junit.Before;
+import org.junit.Test;
 
 /**
  * TestSuite for BasicManagedDataSource when using a
@@ -37,15 +41,11 @@ import org.apache.geronimo.transaction.m
  */
 public class TestDataSourceXAConnectionFactory extends TestBasicDataSource {
 
-    public TestDataSourceXAConnectionFactory(String testName) {
-        super(testName);
-    }
-
     protected BasicManagedDataSource bmds;
 
     public AtomicInteger closeCounter = new AtomicInteger();
 
-    @Override
+    @Before
     public void setUp() throws Exception {
         super.setUp();
         bmds = new BasicManagedDataSource();
@@ -93,6 +93,7 @@ public class TestDataSourceXAConnectionF
     /**
      * JIRA: DBCP-355
      */
+    @Test
     public void testPhysicalClose() throws Exception {
         bmds.setMaxIdle(1);
         Connection conn1 = bmds.getConnection();

Modified: commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSource.java?rev=1649422&r1=1649421&r2=1649422&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSource.java
(original)
+++ commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSource.java
Sun Jan  4 21:10:47 2015
@@ -17,6 +17,12 @@
  */
 package org.apache.commons.dbcp2.managed;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
 import org.apache.commons.dbcp2.ConnectionFactory;
 import org.apache.commons.dbcp2.DelegatingConnection;
 import org.apache.commons.dbcp2.DriverConnectionFactory;
@@ -27,7 +33,10 @@ import org.apache.commons.dbcp2.TestConn
 import org.apache.commons.dbcp2.TesterDriver;
 import org.apache.commons.pool2.impl.GenericObjectPool;
 import org.apache.geronimo.transaction.manager.TransactionManagerImpl;
+import org.junit.After;
 import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
 
 import javax.transaction.TransactionManager;
 
@@ -38,12 +47,9 @@ import java.util.Properties;
  * TestSuite for ManagedDataSource without a transaction in progress.
  *
  * @author Dain Sundstrom
- * @version $Revision$
+ * @version $Id:$
  */
 public class TestManagedDataSource extends TestConnectionPool {
-    public TestManagedDataSource(String testName) {
-        super(testName);
-    }
 
     @Override
     protected Connection getConnection() throws Exception {
@@ -54,10 +60,8 @@ public class TestManagedDataSource exten
     private GenericObjectPool<PoolableConnection> pool = null;
     protected TransactionManager transactionManager;
 
-    @Override
+    @Before
     public void setUp() throws Exception {
-        super.setUp();
-
         // create a GeronimoTransactionManager for testing
         transactionManager = new TransactionManagerImpl();
 
@@ -88,15 +92,16 @@ public class TestManagedDataSource exten
         ds.setAccessToUnderlyingConnectionAllowed(true);
     }
 
-    @Override
+    @After
     public void tearDown() throws Exception {
         pool.close();
         super.tearDown();
     }
 
     /**
-     * Verify the accessToUnderlyingConnectionAllowed propertly limits access to the physical
connection.
+     * Verify the accessToUnderlyingConnectionAllowed properly limits access to the physical
connection.
      */
+    @Test
     public void testAccessToUnderlyingConnectionAllowed() throws Exception {
         ds.setAccessToUnderlyingConnectionAllowed(true);
         ManagedConnection<?> connection = (ManagedConnection<?>) newConnection();
@@ -116,6 +121,7 @@ public class TestManagedDataSource exten
     /**
      * Verify that connection sharing is working (or not working) as expected.
      */
+    @Test
     public void testSharedConnection() throws Exception {
         DelegatingConnection<?> connectionA = (DelegatingConnection<?>) newConnection();
         DelegatingConnection<?> connectionB = (DelegatingConnection<?>) newConnection();
@@ -128,7 +134,8 @@ public class TestManagedDataSource exten
         connectionA.close();
         connectionB.close();
     }
-    
+
+    @Test
     public void testConnectionReturnOnCommit() throws Exception {
         transactionManager.begin();
         DelegatingConnection<?> connectionA = (DelegatingConnection<?>) newConnection();
@@ -139,7 +146,7 @@ public class TestManagedDataSource exten
         assertEquals(0, pool.getNumActive());
     }
 
-    
+    @Test
     public void testManagedConnectionEqualsSameDelegateNoUnderlyingAccess() throws Exception
{
         // Get a maximal set of connections from the pool
         Connection[] c = new Connection[getMaxTotal()];
@@ -164,6 +171,7 @@ public class TestManagedDataSource exten
         ds.setAccessToUnderlyingConnectionAllowed(true);
     }
 
+    @Test
     public void testManagedConnectionEqualsSameDelegate() throws Exception {
         // Get a maximal set of connections from the pool
         Connection[] c = new Connection[getMaxTotal()];
@@ -185,10 +193,10 @@ public class TestManagedDataSource exten
         }
     }
 
-
     /*
     * JIRA: DBCP-198
     */
+    @Test
     public void testManagedConnectionEqualsReflexive() throws Exception {
         Connection con = ds.getConnection();
         Connection con2 = con;
@@ -197,6 +205,7 @@ public class TestManagedDataSource exten
         con.close();
     }
 
+    @Test
     public void testManagedConnectionEqualsFail() throws Exception {
         Connection con1 = ds.getConnection();
         Connection con2 = ds.getConnection();
@@ -205,6 +214,7 @@ public class TestManagedDataSource exten
         con2.close();
     }
 
+    @Test
     public void testManagedConnectionEqualsNull() throws Exception {
         Connection con1 = ds.getConnection();
         Connection con2 = null;
@@ -212,6 +222,7 @@ public class TestManagedDataSource exten
         con1.close();
     }
 
+    @Test
     public void testManagedConnectionEqualsType() throws Exception {
         Connection con1 = ds.getConnection();
         Integer con2 = Integer.valueOf(0);
@@ -219,6 +230,7 @@ public class TestManagedDataSource exten
         con1.close();
     }
 
+    @Test
     public void testManagedConnectionEqualInnermost() throws Exception {
         ds.setAccessToUnderlyingConnectionAllowed(true);
         DelegatingConnection<?> con = (DelegatingConnection<?>) ds.getConnection();

Modified: commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSourceInTx.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSourceInTx.java?rev=1649422&r1=1649421&r2=1649422&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSourceInTx.java
(original)
+++ commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSourceInTx.java
Sun Jan  4 21:10:47 2015
@@ -17,8 +17,17 @@
  */
 package org.apache.commons.dbcp2.managed;
 
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 import org.apache.commons.dbcp2.DelegatingConnection;
+import org.junit.After;
 import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
 
 import java.sql.CallableStatement;
 import java.sql.Connection;
@@ -33,22 +42,17 @@ import javax.transaction.Transaction;
  * TestSuite for ManagedDataSource with an active transaction in progress.
  *
  * @author Dain Sundstrom
- * @version $Revision$
+ * @version $Id:$
  */
 public class TestManagedDataSourceInTx extends TestManagedDataSource {
 
-    public TestManagedDataSourceInTx(String testName) {
-        super(testName);
-    }
-
-    @Override
+    @Before
     public void setUp() throws Exception {
         super.setUp();
-
         transactionManager.begin();
     }
 
-    @Override
+    @After
     public void tearDown() throws Exception {
         if (transactionManager.getTransaction() != null) {
             transactionManager.commit();
@@ -60,6 +64,7 @@ public class TestManagedDataSourceInTx e
      * @see #testSharedConnection()
      */
     @Override
+    @Test
     public void testManagedConnectionEqualsFail() throws Exception {
         // this test is invalid for managed connections since because
         // two connections to the same datasource are supposed to share
@@ -67,6 +72,7 @@ public class TestManagedDataSourceInTx e
     }
 
     @Override
+    @Test
     public void testConnectionsAreDistinct() throws Exception {
         Connection[] conn = new Connection[getMaxTotal()];
         for(int i=0;i<conn.length;i++) {
@@ -88,6 +94,7 @@ public class TestManagedDataSourceInTx e
     }
 
     @Override
+    @Test
     public void testHashCode() throws Exception {
         Connection conn1 = newConnection();
         assertNotNull(conn1);
@@ -99,6 +106,7 @@ public class TestManagedDataSourceInTx e
     }
 
     @Override
+    @Test
     public void testMaxTotal() throws Exception {
         Transaction[] transactions = new Transaction[getMaxTotal()];
         Connection[] c = new Connection[getMaxTotal()];
@@ -130,6 +138,7 @@ public class TestManagedDataSourceInTx e
     }
 
     @Override
+    @Test
     public void testClearWarnings() throws Exception {
         // open a connection
         Connection connection = newConnection();
@@ -159,6 +168,7 @@ public class TestManagedDataSourceInTx e
     }
 
     @Override
+    @Test
     public void testSharedConnection() throws Exception {
         DelegatingConnection<?> connectionA = (DelegatingConnection<?>) newConnection();
         DelegatingConnection<?> connectionB = (DelegatingConnection<?>) newConnection();
@@ -172,6 +182,7 @@ public class TestManagedDataSourceInTx e
         connectionB.close();
     }
 
+    @Test
     public void testSharedTransactionConversion() throws Exception {
         DelegatingConnection<?> connectionA = (DelegatingConnection<?>) newConnection();
         DelegatingConnection<?> connectionB = (DelegatingConnection<?>) newConnection();
@@ -210,6 +221,7 @@ public class TestManagedDataSourceInTx e
         connectionB.close();
     }
 
+    @Test
     public void testCloseInTransaction() throws Exception {
         DelegatingConnection<?> connectionA = (DelegatingConnection<?>) newConnection();
         DelegatingConnection<?> connectionB = (DelegatingConnection<?>) newConnection();
@@ -232,6 +244,7 @@ public class TestManagedDataSourceInTx e
     }
 
     @Override
+    @Test
     public void testAutoCommitBehavior() throws Exception {
         Connection connection = newConnection();
 
@@ -253,6 +266,7 @@ public class TestManagedDataSourceInTx e
         connection.close();
     }
 
+    @Test
     public void testCommit() throws Exception {
         Connection connection = newConnection();
 
@@ -274,6 +288,7 @@ public class TestManagedDataSourceInTx e
         connection.close();
     }
 
+    @Test
     public void testReadOnly() throws Exception {
         Connection connection = newConnection();
 
@@ -346,6 +361,7 @@ public class TestManagedDataSourceInTx e
     }
 
     @Override
+    @Test
     public void testConnectionReturnOnCommit() throws Exception {
          // override with no-op test
          return;

Modified: commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestTransactionContext.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestTransactionContext.java?rev=1649422&r1=1649421&r2=1649422&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestTransactionContext.java
(original)
+++ commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestTransactionContext.java
Sun Jan  4 21:10:47 2015
@@ -60,9 +60,6 @@ public class TestTransactionContext {
             return false;
         }
     }
-    
-    
-    
 
 }
 



Mime
View raw message