Author: tn
Date: Sun Jan 4 21:10:47 2015
New Revision: 1649422
URL: http://svn.apache.org/r1649422
Log:
Use junit annotations, replace Revision and Date tags with Id.
Modified:
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestAbandonedBasicDataSource.java
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestBasicDataSource.java
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestBasicDataSourceFactory.java
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestConnectionPool.java
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestDelegatingCallableStatement.java
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestDelegatingConnection.java
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestDelegatingDatabaseMetaData.java
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestDelegatingPreparedStatement.java
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestDelegatingStatement.java
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestDriverManagerConnectionFactory.java
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestJndi.java
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPStmtPooling.java
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPStmtPoolingBasicDataSource.java
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPoolableConnection.java
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPoolingDataSource.java
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPoolingDriver.java
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestUtils.java
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TesterCallableStatement.java
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TesterConnection.java
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TesterDatabaseMetaData.java
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TesterPreparedStatement.java
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TesterResultSet.java
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TesterStatement.java
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/cpdsadapter/TestDriverAdapterCPDS.java
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/ConnectionPoolDataSourceProxy.java
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/PooledConnectionProxy.java
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestCPDSConnectionFactory.java
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestFactory.java
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestInstanceKeyDataSource.java
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestKeyedCPDSConnectionFactory.java
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestPerUserPoolDataSource.java
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestSharedPoolDataSource.java
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestBasicManagedDataSource.java
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestDataSourceXAConnectionFactory.java
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSource.java
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSourceInTx.java
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestTransactionContext.java
Modified:
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestAbandonedBasicDataSource.java
URL:
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestAbandonedBasicDataSource.java?rev=1649422&r1=1649421&r2=1649422&view=diff
==============================================================================
---
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestAbandonedBasicDataSource.java
(original)
+++
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestAbandonedBasicDataSource.java
Sun Jan 4 21:10:47 2015
@@ -17,6 +17,10 @@
package org.apache.commons.dbcp2;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
import java.io.IOException;
import java.sql.Connection;
import java.sql.CallableStatement;
@@ -26,22 +30,20 @@ import java.sql.Statement;
import org.apache.commons.pool2.impl.GenericKeyedObjectPool;
import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
/**
* TestSuite for BasicDataSource with abandoned connection trace enabled
*
* @author Dirk Verbeeck
- * @version $Revision$ $Date$
+ * @version $Id$
*/
public class TestAbandonedBasicDataSource extends TestBasicDataSource {
- public TestAbandonedBasicDataSource(String testName) {
- super(testName);
- }
- @Override
+ @Before
public void setUp() throws Exception {
super.setUp();
-
// abandoned enabled but should not affect the basic tests
// (very high timeout)
ds.setLogAbandoned(true);
@@ -50,14 +52,9 @@ public class TestAbandonedBasicDataSourc
ds.setRemoveAbandonedTimeout(10000);
}
- @Override
- public void tearDown() throws Exception {
- super.tearDown();
- // nothing to do here
- }
-
// ---------- Abandoned Test -----------
+ @Test
public void testAbandoned() throws Exception {
// force abandoned
ds.setRemoveAbandonedTimeout(0);
@@ -68,6 +65,7 @@ public class TestAbandonedBasicDataSourc
}
}
+ @Test
public void testAbandonedClose() throws Exception {
// force abandoned
ds.setRemoveAbandonedTimeout(0);
@@ -94,6 +92,7 @@ public class TestAbandonedBasicDataSourc
assertEquals(0, ds.getNumActive());
}
+ @Test
public void testAbandonedCloseWithExceptions() throws Exception {
// force abandoned
ds.setRemoveAbandonedTimeout(0);
@@ -129,7 +128,8 @@ public class TestAbandonedBasicDataSourc
* Verify that lastUsed property is updated when a connection
* creates or prepares a statement
*/
- public void testlastUsed() throws Exception {
+ @Test
+ public void testLastUsed() throws Exception {
ds.setRemoveAbandonedTimeout(1);
ds.setMaxTotal(2);
try (Connection conn1 = ds.getConnection()) {
@@ -151,7 +151,8 @@ public class TestAbandonedBasicDataSourc
* Verify that lastUsed property is updated when a connection
* prepares a callable statement.
*/
- public void testlastUsedPrepareCall() throws Exception {
+ @Test
+ public void testLastUsedPrepareCall() throws Exception {
ds.setRemoveAbandonedTimeout(1);
ds.setMaxTotal(2);
try (Connection conn1 = ds.getConnection()) {
@@ -173,6 +174,7 @@ public class TestAbandonedBasicDataSourc
* DBCP-343 - verify that using a DelegatingStatement updates
* the lastUsed on the parent connection
*/
+ @Test
public void testLastUsedPreparedStatementUse() throws Exception {
ds.setRemoveAbandonedTimeout(1);
ds.setMaxTotal(2);
@@ -197,6 +199,7 @@ public class TestAbandonedBasicDataSourc
* DBCP-343 - verify additional operations reset lastUsed on
* the parent connection
*/
+ @Test
public void testLastUsedUpdate() throws Exception {
DelegatingConnection<?> conn = (DelegatingConnection<?>)
ds.getConnection();
PreparedStatement ps = conn.prepareStatement("");
@@ -214,6 +217,7 @@ public class TestAbandonedBasicDataSourc
* no longer referenced even when it is tracked via the AbandonedTrace
* mechanism.
*/
+ @Test
public void testGarbageCollectorCleanUp01() throws Exception {
DelegatingConnection<?> conn = (DelegatingConnection<?>)
ds.getConnection();
Assert.assertEquals(0, conn.getTrace().size());
@@ -226,6 +230,7 @@ public class TestAbandonedBasicDataSourc
/**
* DBCP-180 - things get more interesting with statement pooling.
*/
+ @Test
public void testGarbageCollectorCleanUp02() throws Exception {
ds.setPoolPreparedStatements(true);
ds.setAccessToUnderlyingConnectionAllowed(true);
Modified:
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestBasicDataSource.java
URL:
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestBasicDataSource.java?rev=1649422&r1=1649421&r2=1649422&view=diff
==============================================================================
---
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestBasicDataSource.java
(original)
+++
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestBasicDataSource.java
Sun Jan 4 21:10:47 2015
@@ -17,6 +17,13 @@
package org.apache.commons.dbcp2;
+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 static org.junit.Assert.fail;
+
import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
@@ -26,16 +33,17 @@ import java.util.concurrent.atomic.Atomi
import javax.sql.DataSource;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
/**
* TestSuite for BasicDataSource
*
* @author Dirk Verbeeck
- * @version $Revision$ $Date$
+ * @version $Id$
*/
public class TestBasicDataSource extends TestConnectionPool {
- public TestBasicDataSource(String testName) {
- super(testName);
- }
@Override
protected Connection getConnection() throws Exception {
@@ -45,9 +53,8 @@ public class TestBasicDataSource extends
protected BasicDataSource ds = null;
private static final String CATALOG = "test catalog";
- @Override
+ @Before
public void setUp() throws Exception {
- super.setUp();
ds = createDataSource();
ds.setDriverClassName("org.apache.commons.dbcp2.TesterDriver");
ds.setUrl("jdbc:apache:commons:testdriver");
@@ -69,13 +76,14 @@ public class TestBasicDataSource extends
return new BasicDataSource();
}
- @Override
+ @After
public void tearDown() throws Exception {
super.tearDown();
ds.close();
ds = null;
}
+ @Test
public void testClose() throws Exception {
ds.setAccessToUnderlyingConnectionAllowed(true);
@@ -125,6 +133,7 @@ public class TestBasicDataSource extends
}
+ @Test
public void testSetProperties() throws Exception {
// normal
ds.setConnectionProperties("name1=value1;name2=value2;name3=value3");
@@ -176,6 +185,7 @@ public class TestBasicDataSource extends
}
}
+ @Test
public void testTransactionIsolationBehavior() throws Exception {
Connection conn = getConnection();
assertNotNull(conn);
@@ -195,12 +205,14 @@ public class TestBasicDataSource extends
}
@Override
+ @Test
public void testPooling() throws Exception {
// this also needs access to the underlying connection
ds.setAccessToUnderlyingConnectionAllowed(true);
super.testPooling();
}
+ @Test
public void testNoAccessToUnderlyingConnectionAllowed() throws Exception {
// default: false
assertEquals(false, ds.isAccessToUnderlyingConnectionAllowed());
@@ -213,6 +225,7 @@ public class TestBasicDataSource extends
assertNull(dconn);
}
+ @Test
public void testAccessToUnderlyingConnectionAllowed() throws Exception {
ds.setAccessToUnderlyingConnectionAllowed(true);
assertEquals(true, ds.isAccessToUnderlyingConnectionAllowed());
@@ -227,6 +240,7 @@ public class TestBasicDataSource extends
assertTrue(dconn instanceof TesterConnection);
}
+ @Test
public void testEmptyValidationQuery() throws Exception {
assertNotNull(ds.getValidationQuery());
@@ -237,6 +251,7 @@ public class TestBasicDataSource extends
assertNull(ds.getValidationQuery());
}
+ @Test
public void testInvalidValidationQuery() {
ds.setValidationQuery("invalid");
try (Connection c = ds.getConnection()) {
@@ -248,6 +263,7 @@ public class TestBasicDataSource extends
}
}
+ @Test
public void testValidationQueryTimoutFail() {
ds.setTestOnBorrow(true);
ds.setValidationQueryTimeout(3); // Too fast for TesterStatement
@@ -260,6 +276,7 @@ public class TestBasicDataSource extends
}
}
+ @Test
public void testValidationQueryTimeoutZero() throws Exception {
ds.setTestOnBorrow(true);
ds.setTestOnReturn(true);
@@ -268,6 +285,7 @@ public class TestBasicDataSource extends
con.close();
}
+ @Test
public void testValidationQueryTimeoutNegative() throws Exception {
ds.setTestOnBorrow(true);
ds.setTestOnReturn(true);
@@ -276,6 +294,7 @@ public class TestBasicDataSource extends
con.close();
}
+ @Test
public void testValidationQueryTimeoutSucceed() throws Exception {
ds.setTestOnBorrow(true);
ds.setTestOnReturn(true);
@@ -284,6 +303,7 @@ public class TestBasicDataSource extends
con.close();
}
+ @Test
public void testEmptyInitConnectionSql() throws Exception {
ds.setConnectionInitSqls(Arrays.asList(new String[]{"", " "}));
assertNotNull(ds.getConnectionInitSqls());
@@ -294,6 +314,7 @@ public class TestBasicDataSource extends
assertEquals(0, ds.getConnectionInitSqls().size());
}
+ @Test
public void testInvalidConnectionInitSql() {
try {
ds.setConnectionInitSqls(Arrays.asList(new String[]{"SELECT
1","invalid"}));
@@ -307,6 +328,7 @@ public class TestBasicDataSource extends
}
}
+ @Test
public void testSetValidationTestProperties() {
// defaults
assertEquals(true, ds.getTestOnBorrow());
@@ -328,6 +350,7 @@ public class TestBasicDataSource extends
assertEquals(false, ds.getTestWhileIdle());
}
+ @Test
public void testDefaultCatalog() throws Exception {
Connection[] c = new Connection[getMaxTotal()];
for (int i = 0; i < c.length; i++) {
@@ -352,6 +375,7 @@ public class TestBasicDataSource extends
}
}
+ @Test
public void testSetAutoCommitTrueOnClose() throws Exception {
ds.setAccessToUnderlyingConnectionAllowed(true);
ds.setDefaultAutoCommit(Boolean.FALSE);
@@ -369,6 +393,7 @@ public class TestBasicDataSource extends
assertEquals(true, dconn.getAutoCommit());
}
+ @Test
public void testInitialSize() throws Exception {
ds.setMaxTotal(20);
ds.setMaxIdle(20);
@@ -384,6 +409,7 @@ public class TestBasicDataSource extends
// Bugzilla Bug 28251: Returning dead database connections to
BasicDataSource
// isClosed() failure blocks returning a connection to the pool
+ @Test
public void testIsClosedFailure() throws SQLException {
ds.setAccessToUnderlyingConnectionAllowed(true);
Connection conn = ds.getConnection();
@@ -408,6 +434,7 @@ public class TestBasicDataSource extends
* The BasicDataSource.setTestOnReturn(boolean) is not carried through to
* the GenericObjectPool variable _testOnReturn.
*/
+ @Test
public void testPropertyTestOnReturn() throws Exception {
ds.setValidationQuery("select 1 from dual");
ds.setTestOnBorrow(false);
@@ -427,6 +454,7 @@ public class TestBasicDataSource extends
* The DaffodilDB driver throws an SQLException if
* trying to commit or rollback a readOnly connection.
*/
+ @Test
public void testRollbackReadOnly() throws Exception {
ds.setDefaultReadOnly(Boolean.TRUE);
ds.setDefaultAutoCommit(Boolean.FALSE);
@@ -441,6 +469,7 @@ public class TestBasicDataSource extends
* MaxTotal == 0 should throw SQLException on getConnection.
* Results from Bug 29863 in commons-pool.
*/
+ @Test
public void testMaxTotalZero() throws Exception {
ds.setMaxTotal(0);
@@ -454,6 +483,7 @@ public class TestBasicDataSource extends
}
}
+ @Test
public void testInvalidateConnection() throws Exception {
ds.setMaxTotal(2);
Connection conn1 = ds.getConnection();
@@ -471,6 +501,7 @@ public class TestBasicDataSource extends
* JIRA DBCP-93: If an SQLException occurs after the GenericObjectPool is
* initialized in createDataSource, the evictor task is not cleaned up.
*/
+ @Test
public void testCreateDataSourceCleanupThreads() throws Exception {
ds.close();
ds = null;
@@ -504,6 +535,7 @@ public class TestBasicDataSource extends
* JIRA DBCP-333: Check that a custom class loader is used.
* @throws Exception
*/
+ @Test
public void testDriverClassLoader() throws Exception {
getConnection();
ClassLoader cl = ds.getDriverClassLoader();
@@ -517,6 +549,7 @@ public class TestBasicDataSource extends
* Verify that when errors occur during BasicDataSource initialization,
GenericObjectPool
* Evictors are cleaned up.
*/
+ @Test
public void testCreateDataSourceCleanupEvictor() throws Exception {
ds.close();
ds = null;
Modified:
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestBasicDataSourceFactory.java
URL:
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestBasicDataSourceFactory.java?rev=1649422&r1=1649421&r2=1649422&view=diff
==============================================================================
---
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestBasicDataSourceFactory.java
(original)
+++
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestBasicDataSourceFactory.java
Sun Jan 4 21:10:47 2015
@@ -17,22 +17,23 @@
package org.apache.commons.dbcp2;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
import java.sql.Connection;
import java.util.Properties;
-import junit.framework.TestCase;
+import org.junit.Test;
/**
* TestSuite for BasicDataSourceFactory
*
* @author Dirk Verbeeck
- * @version $Revision$ $Date$
+ * @version $Id$
*/
-public class TestBasicDataSourceFactory extends TestCase {
- public TestBasicDataSourceFactory(String testName) {
- super(testName);
- }
+public class TestBasicDataSourceFactory {
+ @Test
public void testNoProperties() throws Exception {
Properties properties = new Properties();
BasicDataSource ds =
BasicDataSourceFactory.createDataSource(properties);
@@ -40,6 +41,7 @@ public class TestBasicDataSourceFactory
assertNotNull(ds);
}
+ @Test
public void testProperties() throws Exception {
Properties properties = new Properties();
properties.setProperty("driverClassName",
"org.apache.commons.dbcp2.TesterDriver");
Modified:
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestConnectionPool.java
URL:
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestConnectionPool.java?rev=1649422&r1=1649421&r2=1649422&view=diff
==============================================================================
---
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestConnectionPool.java
(original)
+++
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestConnectionPool.java
Sun Jan 4 21:10:47 2015
@@ -27,7 +27,16 @@ import java.util.Hashtable;
import java.util.Random;
import java.util.Stack;
-import junit.framework.TestCase;
+import org.junit.After;
+import org.junit.Test;
+
+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.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
// XXX FIX ME XXX
// this class still needs some cleanup, but at least
@@ -42,16 +51,12 @@ import junit.framework.TestCase;
* @author Sean C. Sullivan
* @author John McNally
* @author Dirk Verbeeck
- * @version $Revision$ $Date$
+ * @version $Id$
*/
-public abstract class TestConnectionPool extends TestCase {
- public TestConnectionPool(String testName) {
- super(testName);
- }
+public abstract class TestConnectionPool {
- @Override
+ @After
public void tearDown() throws Exception {
- super.tearDown();
// Close any connections opened by the test
while (!connections.isEmpty()) {
Connection conn = connections.pop();
@@ -98,6 +103,7 @@ public abstract class TestConnectionPool
// ----------- tests ---------------------------------
+ @Test
public void testClearWarnings() throws Exception {
Connection[] c = new Connection[getMaxTotal()];
for (int i = 0; i < c.length; i++) {
@@ -131,6 +137,7 @@ public abstract class TestConnectionPool
}
}
+ @Test
public void testIsClosed() throws Exception {
for(int i=0;i<getMaxTotal();i++) {
Connection conn = newConnection();
@@ -152,6 +159,7 @@ public abstract class TestConnectionPool
* Verify the close method can be called multiple times on a single
connection without
* an exception being thrown.
*/
+ @Test
public void testCanCloseConnectionTwice() throws Exception {
for (int i = 0; i < getMaxTotal(); i++) { // loop to show we *can*
close again once we've borrowed it from the pool again
Connection conn = newConnection();
@@ -164,6 +172,7 @@ public abstract class TestConnectionPool
}
}
+ @Test
public void testCanCloseStatementTwice() throws Exception {
Connection conn = newConnection();
assertNotNull(conn);
@@ -182,6 +191,7 @@ public abstract class TestConnectionPool
conn.close();
}
+ @Test
public void testCanClosePreparedStatementTwice() throws Exception {
Connection conn = newConnection();
assertNotNull(conn);
@@ -200,6 +210,7 @@ public abstract class TestConnectionPool
conn.close();
}
+ @Test
public void testCanCloseCallableStatementTwice() throws Exception {
Connection conn = newConnection();
assertNotNull(conn);
@@ -218,6 +229,7 @@ public abstract class TestConnectionPool
conn.close();
}
+ @Test
public void testCanCloseResultSetTwice() throws Exception {
Connection conn = newConnection();
assertNotNull(conn);
@@ -238,6 +250,7 @@ public abstract class TestConnectionPool
conn.close();
}
+ @Test
public void testBackPointers() throws Exception {
// normal statement
Connection conn = newConnection();
@@ -313,6 +326,7 @@ public abstract class TestConnectionPool
}
}
+ @Test
public void testSimple() throws Exception {
Connection conn = newConnection();
assertNotNull(conn);
@@ -326,6 +340,7 @@ public abstract class TestConnectionPool
conn.close();
}
+ @Test
public void testRepeatedBorrowAndReturn() throws Exception {
for(int i=0;i<100;i++) {
Connection conn = newConnection();
@@ -341,6 +356,7 @@ public abstract class TestConnectionPool
}
}
+ @Test
public void testSimple2() throws Exception {
Connection conn = newConnection();
assertNotNull(conn);
@@ -393,6 +409,7 @@ public abstract class TestConnectionPool
conn = null;
}
+ @Test
public void testPooling() throws Exception {
// Grab a maximal set of open connections from the pool
Connection[] c = new Connection[getMaxTotal()];
@@ -428,6 +445,7 @@ public abstract class TestConnectionPool
}
}
+ @Test
public void testAutoCommitBehavior() throws Exception {
Connection conn0 = newConnection();
assertNotNull("connection should not be null", conn0);
@@ -454,6 +472,7 @@ public abstract class TestConnectionPool
}
/** @see "http://issues.apache.org/bugzilla/show_bug.cgi?id=12400" */
+ @Test
public void testConnectionsAreDistinct() throws Exception {
Connection[] conn = new Connection[getMaxTotal()];
for(int i=0;i<conn.length;i++) {
@@ -468,7 +487,7 @@ public abstract class TestConnectionPool
}
}
-
+ @Test
public void testOpening() throws Exception {
Connection[] c = new Connection[getMaxTotal()];
// test that opening new connections is not closing previous
@@ -485,6 +504,7 @@ public abstract class TestConnectionPool
}
}
+ @Test
public void testClosing() throws Exception {
Connection[] c = new Connection[getMaxTotal()];
// open the maximum connections
@@ -504,6 +524,7 @@ public abstract class TestConnectionPool
}
}
+ @Test
public void testMaxTotal() throws Exception {
Connection[] c = new Connection[getMaxTotal()];
for (int i = 0; i < c.length; i++) {
@@ -528,6 +549,7 @@ public abstract class TestConnectionPool
* DBCP-128: BasicDataSource.getConnection()
* Connections don't work as hashtable keys
*/
+ @Test
public void testHashing() throws Exception {
Connection con = getConnection();
Hashtable<Connection, String> hash = new Hashtable<>();
@@ -539,6 +561,7 @@ public abstract class TestConnectionPool
con.close();
}
+ @Test
public void testThreaded() {
TestThread[] threads = new TestThread[getMaxTotal()];
for(int i=0;i<threads.length;i++) {
@@ -618,6 +641,7 @@ public abstract class TestConnectionPool
// Bugzilla Bug 24328: PooledConnectionImpl ignores resultsetType
// and Concurrency if statement pooling is not enabled
// http://issues.apache.org/bugzilla/show_bug.cgi?id=24328
+ @Test
public void testPrepareStatementOptions() throws Exception
{
Connection conn = newConnection();
@@ -639,6 +663,7 @@ public abstract class TestConnectionPool
// Bugzilla Bug 24966: NullPointer with Oracle 9 driver
// wrong order of passivate/close when a rset isn't closed
+ @Test
public void testNoRsetClose() throws Exception {
Connection conn = newConnection();
assertNotNull(conn);
@@ -652,6 +677,7 @@ public abstract class TestConnectionPool
}
// Bugzilla Bug 26966: Connectionpool's connections always returns same
+ @Test
public void testHashCode() throws Exception {
Connection conn1 = newConnection();
assertNotNull(conn1);
Modified:
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestDelegatingCallableStatement.java
URL:
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestDelegatingCallableStatement.java?rev=1649422&r1=1649421&r2=1649422&view=diff
==============================================================================
---
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestDelegatingCallableStatement.java
(original)
+++
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestDelegatingCallableStatement.java
Sun Jan 4 21:10:47 2015
@@ -17,42 +17,47 @@
package org.apache.commons.dbcp2;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
import java.sql.CallableStatement;
import java.sql.Connection;
-import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
/**
- * @version $Revision$ $Date$
+ * @version $Id$
*/
-public class TestDelegatingCallableStatement extends TestCase {
- public TestDelegatingCallableStatement(String testName) {
- super(testName);
- }
+public class TestDelegatingCallableStatement {
private DelegatingConnection<Connection> conn = null;
private Connection delegateConn = null;
private DelegatingCallableStatement stmt = null;
private CallableStatement delegateStmt = null;
- @Override
+ @Before
public void setUp() throws Exception {
delegateConn = new TesterConnection("test", "test");
conn = new DelegatingConnection<>(delegateConn);
}
+ @Test
public void testExecuteQueryReturnsNull() throws Exception {
delegateStmt = new TesterCallableStatement(delegateConn,"null");
stmt = new DelegatingCallableStatement(conn,delegateStmt);
assertNull(stmt.executeQuery());
}
+ @Test
public void testExecuteQueryReturnsNotNull() throws Exception {
delegateStmt = new TesterCallableStatement(delegateConn,"select * from
foo");
stmt = new DelegatingCallableStatement(conn,delegateStmt);
assertTrue(null != stmt.executeQuery());
}
+ @Test
public void testGetDelegate() throws Exception {
delegateStmt = new TesterCallableStatement(delegateConn,"select * from
foo");
stmt = new DelegatingCallableStatement(conn,delegateStmt);
Modified:
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestDelegatingConnection.java
URL:
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestDelegatingConnection.java?rev=1649422&r1=1649421&r2=1649422&view=diff
==============================================================================
---
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestDelegatingConnection.java
(original)
+++
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestDelegatingConnection.java
Sun Jan 4 21:10:47 2015
@@ -17,44 +17,49 @@
package org.apache.commons.dbcp2;
+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.SQLException;
-import junit.framework.TestCase;
import org.apache.commons.pool2.impl.GenericKeyedObjectPool;
+import org.junit.Before;
+import org.junit.Test;
/**
* @author Dirk Verbeeck
- * @version $Revision$ $Date$
+ * @version $Id$
*/
-public class TestDelegatingConnection extends TestCase {
- public TestDelegatingConnection(String testName) {
- super(testName);
- }
+public class TestDelegatingConnection {
private DelegatingConnection<? extends Connection> conn = null;
private Connection delegateConn = null;
private Connection delegateConn2 = null;
- @Override
+ @Before
public void setUp() throws Exception {
delegateConn = new TesterConnection("test", "test");
delegateConn2 = new TesterConnection("test", "test");
conn = new DelegatingConnection<>(delegateConn);
}
-
+ @Test
public void testGetDelegate() throws Exception {
assertEquals(delegateConn,conn.getDelegate());
}
+ @Test
public void testConnectionToString() throws Exception {
String s = conn.toString();
assertNotNull(s);
assertTrue(s.length() > 0);
}
+ @Test
public void testCheckOpen() throws Exception {
conn.checkOpen();
conn.close();
@@ -69,6 +74,7 @@ public class TestDelegatingConnection ex
/**
* Verify fix for DBCP-241
*/
+ @Test
public void testCheckOpenNull() throws Exception {
try {
conn.close();
Modified:
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestDelegatingDatabaseMetaData.java
URL:
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestDelegatingDatabaseMetaData.java?rev=1649422&r1=1649421&r2=1649422&view=diff
==============================================================================
---
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestDelegatingDatabaseMetaData.java
(original)
+++
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestDelegatingDatabaseMetaData.java
Sun Jan 4 21:10:47 2015
@@ -17,25 +17,27 @@
package org.apache.commons.dbcp2;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
-import junit.framework.TestCase;
+
+import org.junit.Before;
+import org.junit.Test;
/**
* Test suite for {@link DelegatingDatabaseMetaData}.
*/
-public class TestDelegatingDatabaseMetaData extends TestCase {
- public TestDelegatingDatabaseMetaData(String testName) {
- super(testName);
- }
+public class TestDelegatingDatabaseMetaData {
private DelegatingConnection<Connection> conn = null;
private Connection delegateConn = null;
private DelegatingDatabaseMetaData meta = null;
private DatabaseMetaData delegateMeta = null;
- @Override
+ @Before
public void setUp() throws Exception {
delegateConn = new TesterConnection("test", "test");
delegateMeta = delegateConn.getMetaData();
@@ -43,10 +45,12 @@ public class TestDelegatingDatabaseMetaD
meta = new DelegatingDatabaseMetaData(conn,delegateMeta);
}
+ @Test
public void testGetDelegate() throws Exception {
assertEquals(delegateMeta,meta.getDelegate());
}
+ @Test
/* JDBC_4_ANT_KEY_BEGIN */
public void testCheckOpen() throws Exception {
ResultSet rst = meta.getSchemas();
Modified:
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestDelegatingPreparedStatement.java
URL:
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestDelegatingPreparedStatement.java?rev=1649422&r1=1649421&r2=1649422&view=diff
==============================================================================
---
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestDelegatingPreparedStatement.java
(original)
+++
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestDelegatingPreparedStatement.java
Sun Jan 4 21:10:47 2015
@@ -17,44 +17,49 @@
package org.apache.commons.dbcp2;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
import java.sql.Connection;
import java.sql.PreparedStatement;
-import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
/**
* @author Rodney Waldhoff
* @author Dirk Verbeeck
- * @version $Revision$ $Date$
+ * @version $Id$
*/
-public class TestDelegatingPreparedStatement extends TestCase {
- public TestDelegatingPreparedStatement(String testName) {
- super(testName);
- }
+public class TestDelegatingPreparedStatement {
private DelegatingConnection<Connection> conn = null;
private Connection delegateConn = null;
private DelegatingPreparedStatement stmt = null;
private PreparedStatement delegateStmt = null;
- @Override
+ @Before
public void setUp() throws Exception {
delegateConn = new TesterConnection("test", "test");
conn = new DelegatingConnection<>(delegateConn);
}
+ @Test
public void testExecuteQueryReturnsNull() throws Exception {
delegateStmt = new TesterPreparedStatement(delegateConn,"null");
stmt = new DelegatingPreparedStatement(conn,delegateStmt);
assertNull(stmt.executeQuery());
}
+ @Test
public void testExecuteQueryReturnsNotNull() throws Exception {
delegateStmt = new TesterPreparedStatement(delegateConn,"select * from
foo");
stmt = new DelegatingPreparedStatement(conn,delegateStmt);
assertTrue(null != stmt.executeQuery());
}
+ @Test
public void testGetDelegate() throws Exception {
delegateStmt = new TesterPreparedStatement(delegateConn,"select * from
foo");
stmt = new DelegatingPreparedStatement(conn,delegateStmt);
Modified:
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestDelegatingStatement.java
URL:
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestDelegatingStatement.java?rev=1649422&r1=1649421&r2=1649422&view=diff
==============================================================================
---
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestDelegatingStatement.java
(original)
+++
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestDelegatingStatement.java
Sun Jan 4 21:10:47 2015
@@ -17,29 +17,33 @@
package org.apache.commons.dbcp2;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.lang.reflect.Proxy;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
-import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
/**
* @author Rodney Waldhoff
* @author Dirk Verbeeck
- * @version $Revision$ $Date$
+ * @version $Id$
*/
-public class TestDelegatingStatement extends TestCase {
- public TestDelegatingStatement(String testName) {
- super(testName);
- }
+public class TestDelegatingStatement {
private DelegatingConnection<Connection> conn = null;
private Connection delegateConn = null;
private DelegatingStatement stmt = null;
private Statement delegateStmt = null;
- @Override
+ @Before
public void setUp() throws Exception {
delegateConn = new TesterConnection("test", "test");
delegateStmt = new TesterStatement(delegateConn);
@@ -47,14 +51,17 @@ public class TestDelegatingStatement ext
stmt = new DelegatingStatement(conn,delegateStmt);
}
+ @Test
public void testExecuteQueryReturnsNull() throws Exception {
assertNull(stmt.executeQuery("null"));
}
+ @Test
public void testGetDelegate() throws Exception {
assertEquals(delegateStmt,stmt.getDelegate());
}
+ @Test
public void testCheckOpen() throws Exception {
stmt.checkOpen();
stmt.close();
@@ -66,6 +73,7 @@ public class TestDelegatingStatement ext
}
}
+ @Test
public void testIsWrapperFor() throws Exception {
TesterConnection tstConn = new TesterConnection("test", "test");
TesterStatement tstStmt = new TesterStatementNonWrapping(tstConn);
Modified:
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestDriverManagerConnectionFactory.java
URL:
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestDriverManagerConnectionFactory.java?rev=1649422&r1=1649421&r2=1649422&view=diff
==============================================================================
---
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestDriverManagerConnectionFactory.java
(original)
+++
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestDriverManagerConnectionFactory.java
Sun Jan 4 21:10:47 2015
@@ -17,28 +17,26 @@
package org.apache.commons.dbcp2;
+import static org.junit.Assert.fail;
+
import java.sql.Connection;
import javax.sql.DataSource;
import org.apache.commons.pool2.impl.GenericObjectPool;
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
-
-import junit.framework.TestCase;
+import org.junit.Test;
/**
* This test *must* execute before all other tests to be effective as it tests
* the initialisation of DriverManager.
* Based on the test case for DBCP-212 written by Marcos Sanz
*
- * @version $Revision$ $Date$
+ * @version $Id$
*/
-public class TestDriverManagerConnectionFactory extends TestCase {
-
- public TestDriverManagerConnectionFactory(String testName) {
- super(testName);
- }
+public class TestDriverManagerConnectionFactory {
+ @Test
public void testDriverManagerInit() throws Exception {
System.setProperty("jdbc.drivers",
"org.apache.commons.dbcp2.TesterDriver");
Modified:
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestJndi.java
URL:
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestJndi.java?rev=1649422&r1=1649421&r2=1649422&view=diff
==============================================================================
---
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestJndi.java
(original)
+++
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestJndi.java
Sun Jan 4 21:10:47 2015
@@ -17,6 +17,8 @@
package org.apache.commons.dbcp2;
+import static org.junit.Assert.fail;
+
import java.util.Hashtable;
import javax.naming.Context;
@@ -24,17 +26,17 @@ import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
-import junit.framework.TestCase;
import org.apache.commons.dbcp2.datasources.SharedPoolDataSource;
import org.apache.commons.dbcp2.datasources.PerUserPoolDataSource;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
/**
* Tests JNID bind and lookup for DataSource implementations.
* Demonstrates problem indicated in BZ #38073.
- *
*/
-
-public class TestJndi extends TestCase {
+public class TestJndi {
/**
* The subcontext where the data source is bound.
*/
@@ -50,17 +52,11 @@ public class TestJndi extends TestCase {
protected Context context = null;
/**
- * Creates a new instance.
- */
- public TestJndi(String name) {
- super(name);
- }
-
- /**
* Test BasicDatsource bind and lookup
*
* @throws Exception
*/
+ @Test
public void testBasicDataSourceBind() throws Exception {
BasicDataSource dataSource = new BasicDataSource();
checkBind(dataSource);
@@ -71,6 +67,7 @@ public class TestJndi extends TestCase {
*
* @throws Exception
*/
+ @Test
public void testSharedPoolDataSourceBind() throws Exception {
SharedPoolDataSource dataSource = new SharedPoolDataSource();
checkBind(dataSource);
@@ -81,18 +78,19 @@ public class TestJndi extends TestCase {
*
* @throws Exception
*/
+ @Test
public void testPerUserPoolDataSourceBind() throws Exception {
PerUserPoolDataSource dataSource = new PerUserPoolDataSource();
checkBind(dataSource);
}
- @Override
+ @Before
public void setUp() throws Exception {
context = getInitialContext();
context.createSubcontext(JNDI_SUBCONTEXT);
}
- @Override
+ @After
public void tearDown() throws Exception {
context.unbind(JNDI_PATH);
context.destroySubcontext(JNDI_SUBCONTEXT);
Modified:
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPStmtPooling.java
URL:
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPStmtPooling.java?rev=1649422&r1=1649421&r2=1649422&view=diff
==============================================================================
---
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPStmtPooling.java
(original)
+++
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPStmtPooling.java
Sun Jan 4 21:10:47 2015
@@ -17,6 +17,11 @@
package org.apache.commons.dbcp2;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
@@ -26,24 +31,21 @@ import java.sql.SQLException;
import javax.management.ObjectName;
import javax.sql.DataSource;
-import junit.framework.TestCase;
-
import org.apache.commons.pool2.ObjectPool;
import org.apache.commons.pool2.impl.GenericObjectPool;
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import org.junit.Assert;
+import org.junit.Test;
/**
* TestSuite for BasicDataSource with prepared statement pooling enabled
*
* @author Dirk Verbeeck
- * @version $Revision$ $Date$
+ * @version $Id$
*/
-public class TestPStmtPooling extends TestCase {
- public TestPStmtPooling(String testName) {
- super(testName);
- }
+public class TestPStmtPooling {
+ @Test
public void testStmtPool() throws Exception {
DataSource ds = createPDS();
try (Connection conn = ds.getConnection()) {
@@ -62,6 +64,7 @@ public class TestPStmtPooling extends Te
* that wraps a PoolablePreparedStatement does not "re-close" the PPS
* (which could be in use by another client - see DBCP-414).
*/
+ @Test
public void testMultipleClose() throws Exception {
DataSource ds = createPDS();
PreparedStatement stmt1 = null;
@@ -118,6 +121,7 @@ public class TestPStmtPooling extends Te
}
+ @Test
public void testCallableStatementPooling() throws Exception {
DriverManager.registerDriver(new TesterDriver());
ConnectionFactory connFactory = new DriverManagerConnectionFactory(
@@ -163,6 +167,7 @@ public class TestPStmtPooling extends Te
}
}
+ @Test
public void testClosePool() throws Exception {
DriverManager.registerDriver(new TesterDriver());
ConnectionFactory connFactory = new DriverManagerConnectionFactory(
@@ -194,6 +199,7 @@ public class TestPStmtPooling extends Te
}
}
+ @Test
public void testBatchUpdate() throws Exception {
DriverManager.registerDriver(new TesterDriver());
ConnectionFactory connFactory = new DriverManagerConnectionFactory(
Modified:
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPStmtPoolingBasicDataSource.java
URL:
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPStmtPoolingBasicDataSource.java?rev=1649422&r1=1649421&r2=1649422&view=diff
==============================================================================
---
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPStmtPoolingBasicDataSource.java
(original)
+++
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPStmtPoolingBasicDataSource.java
Sun Jan 4 21:10:47 2015
@@ -17,37 +17,38 @@
package org.apache.commons.dbcp2;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;
+import org.junit.Before;
+import org.junit.Test;
+
/**
* TestSuite for BasicDataSource with prepared statement pooling enabled
*
* @author Dirk Verbeeck
- * @version $Revision$ $Date$
+ * @version $Id$
*/
public class TestPStmtPoolingBasicDataSource extends TestBasicDataSource {
- public TestPStmtPoolingBasicDataSource(String testName) {
- super(testName);
- }
- @Override
+ @Before
public void setUp() throws Exception {
super.setUp();
-
// PoolPreparedStatements enabled, should not affect the basic tests
ds.setPoolPreparedStatements(true);
ds.setMaxOpenPreparedStatements(2);
}
- @Override
- public void tearDown() throws Exception {
- super.tearDown();
- // nothing to do here
- }
-
+ @Test
public void testPreparedStatementPooling() throws Exception {
Connection conn = getConnection();
assertNotNull(conn);
@@ -87,6 +88,7 @@ public class TestPStmtPoolingBasicDataSo
* closing least-recently-used statements idle in the pool to make room
* for new ones if necessary.
*/
+ @Test
public void testLRUBehavior() throws Exception {
ds.setMaxOpenPreparedStatements(3);
@@ -139,6 +141,7 @@ public class TestPStmtPoolingBasicDataSo
// Bugzilla Bug 27246
// PreparedStatement cache should be different depending on the Catalog
+ @Test
public void testPStmtCatalog() throws Exception {
Connection conn = getConnection();
conn.setCatalog("catalog1");
@@ -163,6 +166,7 @@ public class TestPStmtPoolingBasicDataSo
assertSame(inner1, inner3);
}
+ @Test
public void testPStmtPoolingWithNoClose() throws Exception {
ds.setMaxTotal(1); // only one connection in pool needed
ds.setMaxIdle(1);
@@ -194,6 +198,7 @@ public class TestPStmtPoolingBasicDataSo
assertSame(inner1, inner2);
}
+ @Test
public void testPStmtPoolingAccrossClose() throws Exception {
ds.setMaxTotal(1); // only one connection in pool needed
ds.setMaxIdle(1);
@@ -233,6 +238,7 @@ public class TestPStmtPoolingBasicDataSo
* Tests high-concurrency contention for connections and pooled prepared
statements.
* DBCP-414
*/
+ @Test
public void testMultipleThreads1() throws Exception {
ds.setMaxWaitMillis(-1);
ds.setMaxTotal(5);
Modified:
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPoolableConnection.java
URL:
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPoolableConnection.java?rev=1649422&r1=1649421&r2=1649422&view=diff
==============================================================================
---
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPoolableConnection.java
(original)
+++
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPoolableConnection.java
Sun Jan 4 21:10:47 2015
@@ -16,26 +16,27 @@
*/
package org.apache.commons.dbcp2;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
import java.sql.Connection;
import java.sql.SQLException;
-import junit.framework.TestCase;
import org.apache.commons.pool2.ObjectPool;
import org.apache.commons.pool2.impl.GenericObjectPool;
import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
/**
* @author James Ring
- * @version $Revision$ $Date$
+ * @version $Id:$
*/
-public class TestPoolableConnection extends TestCase {
- public TestPoolableConnection(String testName) {
- super(testName);
- }
+public class TestPoolableConnection {
private ObjectPool<PoolableConnection> pool = null;
- @Override
+ @Before
public void setUp() throws Exception {
PoolableConnectionFactory factory = new PoolableConnectionFactory(
new DriverConnectionFactory(
@@ -48,6 +49,7 @@ public class TestPoolableConnection exte
factory.setPool(pool);
}
+ @Test
public void testConnectionPool() throws Exception {
// Grab a new connection from the pool
Connection c = pool.borrowObject();
@@ -63,6 +65,7 @@ public class TestPoolableConnection exte
// Bugzilla Bug 33591: PoolableConnection leaks connections if the
// delegated connection closes itself.
+ @Test
public void testPoolableConnectionLeak() throws Exception {
// 'Borrow' a connection from the pool
Connection conn = pool.borrowObject();
@@ -87,6 +90,7 @@ public class TestPoolableConnection exte
0, pool.getNumActive());
}
+ @Test
public void testClosingWrappedInDelegate() throws Exception {
Assert.assertEquals(0, pool.getNumActive());
Modified:
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPoolingDataSource.java
URL:
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPoolingDataSource.java?rev=1649422&r1=1649421&r2=1649422&view=diff
==============================================================================
---
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPoolingDataSource.java
(original)
+++
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPoolingDataSource.java
Sun Jan 4 21:10:47 2015
@@ -17,21 +17,24 @@
package org.apache.commons.dbcp2;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import java.sql.Connection;
import java.util.Properties;
import org.apache.commons.pool2.impl.GenericObjectPool;
+import org.junit.After;
import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
/**
* TestSuite for PoolingDataSource
*
- * @version $Revision: 392677 $ $Date: 2006-04-08 21:42:24 -0700 (Sat, 08 Apr
2006) $
+ * @version $Id:$
*/
public class TestPoolingDataSource extends TestConnectionPool {
- public TestPoolingDataSource(String testName) {
- super(testName);
- }
@Override
protected Connection getConnection() throws Exception {
@@ -41,9 +44,8 @@ public class TestPoolingDataSource exten
protected PoolingDataSource<PoolableConnection> ds = null;
private GenericObjectPool<PoolableConnection> pool = null;
- @Override
+ @Before
public void setUp() throws Exception {
- super.setUp();
Properties props = new Properties();
props.setProperty("user", "username");
props.setProperty("password", "password");
@@ -63,12 +65,13 @@ public class TestPoolingDataSource exten
ds.setAccessToUnderlyingConnectionAllowed(true);
}
- @Override
+ @After
public void tearDown() throws Exception {
pool.close();
super.tearDown();
}
+ @Test
public void testPoolGuardConnectionWrapperEqualsSameDelegate() throws
Exception {
// Get a maximal set of connections from the pool
Connection[] c = new Connection[getMaxTotal()];
@@ -93,6 +96,7 @@ public class TestPoolingDataSource exten
/*
* JIRA: DBCP-198
*/
+ @Test
public void testPoolGuardConnectionWrapperEqualsReflexive()
throws Exception {
Connection con = ds.getConnection();
@@ -102,6 +106,7 @@ public class TestPoolingDataSource exten
con.close();
}
+ @Test
public void testPoolGuardConnectionWrapperEqualsFail() throws Exception {
Connection con1 = ds.getConnection();
Connection con2 = ds.getConnection();
@@ -110,6 +115,7 @@ public class TestPoolingDataSource exten
con2.close();
}
+ @Test
public void testPoolGuardConnectionWrapperEqualsNull() throws Exception {
Connection con1 = ds.getConnection();
Connection con2 = null;
@@ -117,6 +123,7 @@ public class TestPoolingDataSource exten
con1.close();
}
+ @Test
public void testPoolGuardConnectionWrapperEqualsType() throws Exception {
Connection con1 = ds.getConnection();
Integer con2 = Integer.valueOf(0);
@@ -124,7 +131,8 @@ public class TestPoolingDataSource exten
con1.close();
}
- public void testestPoolGuardConnectionWrapperEqualInnermost() throws
Exception {
+ @Test
+ public void testPoolGuardConnectionWrapperEqualInnermost() throws
Exception {
ds.setAccessToUnderlyingConnectionAllowed(true);
DelegatingConnection<?> con = (DelegatingConnection<?>)
ds.getConnection();
Connection inner = con.getInnermostDelegate();
@@ -141,6 +149,7 @@ public class TestPoolingDataSource exten
* Verify that omitting factory.setPool(pool) when setting up PDS does not
* result in NPE.
*/
+ @Test
public void testFixFactoryConfig() throws Exception {
Properties props = new Properties();
props.setProperty("user", "username");
Modified:
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPoolingDriver.java
URL:
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPoolingDriver.java?rev=1649422&r1=1649421&r2=1649422&view=diff
==============================================================================
---
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPoolingDriver.java
(original)
+++
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestPoolingDriver.java
Sun Jan 4 21:10:47 2015
@@ -17,6 +17,12 @@
package org.apache.commons.dbcp2;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.io.ByteArrayOutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintStream;
@@ -30,18 +36,18 @@ import javax.sql.DataSource;
import org.apache.commons.pool2.ObjectPool;
import org.apache.commons.pool2.impl.GenericObjectPool;
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
+import org.junit.After;
import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
/**
* Tests for a {@link GenericObjectPool} based {@link PoolingDriver}.
* @author Rodney Waldhoff
* @author Sean C. Sullivan
- * @version $Revision$ $Date$
+ * @version $Id$
*/
public class TestPoolingDriver extends TestConnectionPool {
- public TestPoolingDriver(String testName) {
- super(testName);
- }
@Override
protected Connection getConnection() throws Exception {
@@ -50,9 +56,8 @@ public class TestPoolingDriver extends T
private PoolingDriver driver = null;
- @Override
+ @Before
public void setUp() throws Exception {
- super.setUp();
DriverConnectionFactory cf = new DriverConnectionFactory(new
TesterDriver(),"jdbc:apache:commons:testdriver",null);
PoolableConnectionFactory pcf = new PoolableConnectionFactory(cf,
null);
@@ -81,12 +86,13 @@ public class TestPoolingDriver extends T
driver.registerPool("test",pool);
}
- @Override
+ @After
public void tearDown() throws Exception {
driver.closePool("test");
super.tearDown();
}
+ @Test
public void test1() {
ConnectionFactory connectionFactory = new
DriverManagerConnectionFactory("jdbc:some:connect:string","username","password");
PoolableConnectionFactory pcf =
@@ -100,6 +106,7 @@ public class TestPoolingDriver extends T
Assert.assertNotNull(ds);
}
+ @Test
public void test2() {
ConnectionFactory connectionFactory = new
DriverManagerConnectionFactory("jdbc:some:connect:string","username","password");
PoolableConnectionFactory pcf =
@@ -111,8 +118,8 @@ public class TestPoolingDriver extends T
driver2.registerPool("example",connectionPool);
}
-
/** @see "http://issues.apache.org/bugzilla/show_bug.cgi?id=28912" */
+ @Test
public void testReportedBug28912() throws Exception {
Connection conn1 = getConnection();
assertNotNull(conn1);
@@ -133,6 +140,7 @@ public class TestPoolingDriver extends T
}
/** @see "http://issues.apache.org/bugzilla/show_bug.cgi?id=12400" */
+ @Test
public void testReportedBug12400() throws Exception {
GenericObjectPoolConfig config = new GenericObjectPoolConfig();
config.setMaxTotal(70);
@@ -165,6 +173,7 @@ public class TestPoolingDriver extends T
}
}
+ @Test
public void testClosePool() throws Exception {
Connection conn =
DriverManager.getConnection("jdbc:apache:commons:dbcp:test");
assertNotNull(conn);
@@ -181,6 +190,7 @@ public class TestPoolingDriver extends T
}
}
+ @Test
public void testInvalidateConnection() throws Exception {
Connection conn =
DriverManager.getConnection("jdbc:apache:commons:dbcp:test");
assertNotNull(conn);
@@ -197,6 +207,7 @@ public class TestPoolingDriver extends T
assertTrue(conn.isClosed());
}
+ @Test
public void testLogWriter() throws Exception {
PrintStream ps = new PrintStream(new ByteArrayOutputStream(), false,
"UTF-8");
PrintWriter pw = new PrintWriter(new OutputStreamWriter(new
ByteArrayOutputStream(), "UTF-8"));
Modified:
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestUtils.java
URL:
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestUtils.java?rev=1649422&r1=1649421&r2=1649422&view=diff
==============================================================================
---
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestUtils.java
(original)
+++
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestUtils.java
Sun Jan 4 21:10:47 2015
@@ -19,13 +19,11 @@ package org.apache.commons.dbcp2;
import java.sql.Connection;
-import junit.framework.TestCase;
+import org.junit.Test;
-public class TestUtils extends TestCase {
- public TestUtils(String testName) {
- super(testName);
- }
+public class TestUtils {
+ @Test
public void testClassLoads() {
Utils.closeQuietly((Connection) null);
}
Modified:
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TesterCallableStatement.java
URL:
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TesterCallableStatement.java?rev=1649422&r1=1649421&r2=1649422&view=diff
==============================================================================
---
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TesterCallableStatement.java
(original)
+++
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TesterCallableStatement.java
Sun Jan 4 21:10:47 2015
@@ -41,7 +41,7 @@ import java.sql.SQLXML;
* Trivial implementation of a CallableStatement to avoid null pointer
exceptions in tests.
*
* @author Dain Sundstrom
- * @version $Revision$
+ * @version $Id:$
*/
public class TesterCallableStatement extends TesterPreparedStatement
implements CallableStatement {
Modified:
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TesterConnection.java
URL:
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TesterConnection.java?rev=1649422&r1=1649421&r2=1649422&view=diff
==============================================================================
---
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TesterConnection.java
(original)
+++
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TesterConnection.java
Sun Jan 4 21:10:47 2015
@@ -40,7 +40,7 @@ import java.util.concurrent.Executor;
*
* @author Rodney Waldhoff
* @author Dirk Verbeeck
- * @version $Revision$ $Date$
+ * @version $Id$
*/
public class TesterConnection implements Connection {
protected boolean _open = true;
Modified:
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TesterDatabaseMetaData.java
URL:
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TesterDatabaseMetaData.java?rev=1649422&r1=1649421&r2=1649422&view=diff
==============================================================================
---
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TesterDatabaseMetaData.java
(original)
+++
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TesterDatabaseMetaData.java
Sun Jan 4 21:10:47 2015
@@ -24,7 +24,7 @@ import java.sql.RowIdLifetime;
import java.sql.SQLException;
/**
- * Dummy {@link DatabaseMetaData} for tetsing purposes. Implements only those
+ * Dummy {@link DatabaseMetaData} for testing purposes. Implements only those
* methods required by the test cases.
*/
public class TesterDatabaseMetaData implements DatabaseMetaData {
Modified:
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TesterPreparedStatement.java
URL:
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TesterPreparedStatement.java?rev=1649422&r1=1649421&r2=1649422&view=diff
==============================================================================
---
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TesterPreparedStatement.java
(original)
+++
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TesterPreparedStatement.java
Sun Jan 4 21:10:47 2015
@@ -39,7 +39,7 @@ import java.sql.SQLXML;
*
* @author Rodney Waldhoff
* @author Dirk Verbeeck
- * @version $Revision$ $Date$
+ * @version $Id$
*/
public class TesterPreparedStatement extends TesterStatement implements
PreparedStatement {
private final ResultSetMetaData _resultSetMetaData = null;
Modified:
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TesterResultSet.java
URL:
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TesterResultSet.java?rev=1649422&r1=1649421&r2=1649422&view=diff
==============================================================================
---
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TesterResultSet.java
(original)
+++
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TesterResultSet.java
Sun Jan 4 21:10:47 2015
@@ -41,7 +41,7 @@ import java.sql.SQLXML;
*
* @author Rodney Waldhoff
* @author Dirk Verbeeck
- * @version $Revision$ $Date$
+ * @version $Id$
*/
public class TesterResultSet implements ResultSet {
public TesterResultSet(Statement stmt) {
Modified:
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TesterStatement.java
URL:
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TesterStatement.java?rev=1649422&r1=1649421&r2=1649422&view=diff
==============================================================================
---
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TesterStatement.java
(original)
+++
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TesterStatement.java
Sun Jan 4 21:10:47 2015
@@ -28,7 +28,7 @@ import java.sql.Statement;
*
* @author Rodney Waldhoff
* @author Dirk Verbeeck
- * @version $Revision$ $Date$
+ * @version $Id$
*/
public class TesterStatement implements Statement {
public TesterStatement(Connection conn) {
Modified:
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/cpdsadapter/TestDriverAdapterCPDS.java
URL:
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/cpdsadapter/TestDriverAdapterCPDS.java?rev=1649422&r1=1649421&r2=1649422&view=diff
==============================================================================
---
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/cpdsadapter/TestDriverAdapterCPDS.java
(original)
+++
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/cpdsadapter/TestDriverAdapterCPDS.java
Sun Jan 4 21:10:47 2015
@@ -17,6 +17,11 @@
package org.apache.commons.dbcp2.cpdsadapter;
+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.util.Properties;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -27,22 +32,19 @@ import javax.sql.DataSource;
import org.apache.commons.dbcp2.datasources.SharedPoolDataSource;
import org.junit.Assert;
-
-import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
/**
* Tests for DriverAdapterCPDS
*
- * @version $Revision:$ $Date:$
+ * @version $Id:$
*/
-public class TestDriverAdapterCPDS extends TestCase {
- public TestDriverAdapterCPDS(String testName) {
- super(testName);
- }
+public class TestDriverAdapterCPDS {
private DriverAdapterCPDS pcds;
- @Override
+ @Before
public void setUp() throws Exception {
pcds = new DriverAdapterCPDS();
pcds.setDriver("org.apache.commons.dbcp2.TesterDriver");
@@ -55,6 +57,7 @@ public class TestDriverAdapterCPDS exten
/**
* JIRA: DBCP-245
*/
+ @Test
public void testIncorrectPassword() throws Exception
{
pcds.getPooledConnection("u2", "p2").close();
@@ -84,7 +87,7 @@ public class TestDriverAdapterCPDS exten
pcds.getPooledConnection("u1", "p1").close();
}
-
+ @Test
public void testSimple() throws Exception {
Connection conn = pcds.getPooledConnection().getConnection();
assertNotNull(conn);
@@ -98,6 +101,7 @@ public class TestDriverAdapterCPDS exten
conn.close();
}
+ @Test
public void testSimpleWithUsername() throws Exception {
Connection conn = pcds.getPooledConnection("u1", "p1").getConnection();
assertNotNull(conn);
@@ -111,6 +115,7 @@ public class TestDriverAdapterCPDS exten
conn.close();
}
+ @Test
public void testClosingWithUserName()
throws Exception {
Connection[] c = new Connection[10];
@@ -137,6 +142,7 @@ public class TestDriverAdapterCPDS exten
}
}
+ @Test
public void testSetProperties() throws Exception {
// Set user property to bad value
pcds.setUser("bad");
@@ -158,6 +164,7 @@ public class TestDriverAdapterCPDS exten
}
// https://issues.apache.org/jira/browse/DBCP-376
+ @Test
public void testDbcp367() throws Exception {
ThreadDbcp367[] threads = new ThreadDbcp367[200];
Modified:
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/ConnectionPoolDataSourceProxy.java
URL:
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/ConnectionPoolDataSourceProxy.java?rev=1649422&r1=1649421&r2=1649422&view=diff
==============================================================================
---
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/ConnectionPoolDataSourceProxy.java
(original)
+++
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/ConnectionPoolDataSourceProxy.java
Sun Jan 4 21:10:47 2015
@@ -29,7 +29,7 @@ import javax.sql.PooledConnection;
* ConnectionPoolDataSource implementation that proxies another
* ConnectionPoolDataSource.
*
- * @version $Revision$ $Date$
+ * @version $Id:$
*/
public class ConnectionPoolDataSourceProxy implements ConnectionPoolDataSource
{
Modified:
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/PooledConnectionProxy.java
URL:
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/PooledConnectionProxy.java?rev=1649422&r1=1649421&r2=1649422&view=diff
==============================================================================
---
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/PooledConnectionProxy.java
(original)
+++
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/PooledConnectionProxy.java
Sun Jan 4 21:10:47 2015
@@ -33,7 +33,7 @@ import javax.sql.StatementEventListener;
* PooledConnection and proxies events, allowing behavior to be
* modified to simulate behavior of different implementations.
*
- * @version $Revision$ $Date$
+ * @version $Id:$
*/
public class PooledConnectionProxy implements PooledConnection,
ConnectionEventListener {
Modified:
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestCPDSConnectionFactory.java
URL:
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestCPDSConnectionFactory.java?rev=1649422&r1=1649421&r2=1649422&view=diff
==============================================================================
---
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestCPDSConnectionFactory.java
(original)
+++
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestCPDSConnectionFactory.java
Sun Jan 4 21:10:47 2015
@@ -17,28 +17,28 @@
package org.apache.commons.dbcp2.datasources;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.sql.Connection;
import java.sql.SQLException;
import javax.sql.PooledConnection;
-import junit.framework.TestCase;
import org.apache.commons.dbcp2.cpdsadapter.DriverAdapterCPDS;
-
import org.apache.commons.pool2.impl.GenericObjectPool;
+import org.junit.Before;
+import org.junit.Test;
/**
- * @version $Revision$ $Date$
+ * @version $Id:$
*/
-public class TestCPDSConnectionFactory extends TestCase {
+public class TestCPDSConnectionFactory {
protected ConnectionPoolDataSourceProxy cpds = null;
- public TestCPDSConnectionFactory(String testName) {
- super(testName);
- }
-
- @Override
+ @Before
public void setUp() throws Exception {
cpds = new ConnectionPoolDataSourceProxy(new DriverAdapterCPDS());
DriverAdapterCPDS delegate = (DriverAdapterCPDS) cpds.getDelegate();
@@ -55,6 +55,7 @@ public class TestCPDSConnectionFactory e
* properly. PooledConnectionProxy (dubiously) fires connectionClosed
* when PooledConnection itself is closed.
*/
+ @Test
public void testSharedPoolDSDestroyOnReturn() throws Exception {
PerUserPoolDataSource ds = new PerUserPoolDataSource();
ds.setConnectionPoolDataSource(cpds);
@@ -79,6 +80,7 @@ public class TestCPDSConnectionFactory e
* Verify that pool counters are maintained properly and listeners are
* cleaned up when a PooledConnection throws a connectionError event.
*/
+ @Test
public void testConnectionErrorCleanup() throws Exception {
// Setup factory
CPDSConnectionFactory factory = new CPDSConnectionFactory(
Modified:
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestFactory.java
URL:
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestFactory.java?rev=1649422&r1=1649421&r2=1649422&view=diff
==============================================================================
---
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestFactory.java
(original)
+++
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestFactory.java
Sun Jan 4 21:10:47 2015
@@ -17,6 +17,8 @@
package org.apache.commons.dbcp2.datasources;
+import static org.junit.Assert.assertNotNull;
+
import java.util.Hashtable;
import javax.naming.CompositeName;
@@ -27,21 +29,19 @@ import javax.naming.Reference;
import javax.naming.StringRefAddr;
import javax.naming.spi.ObjectFactory;
-import junit.framework.TestCase;
+import org.junit.Test;
/**
* @author Dirk Verbeeck
- * @version $Revision$ $Date$
+ * @version $Id$
*/
-public class TestFactory extends TestCase {
- public TestFactory(String testName) {
- super(testName);
- }
+public class TestFactory {
// Bugzilla Bug 24082: bug in InstanceKeyDataSourceFactory
// There's a fatal bug in InstanceKeyDataSourceFactory that means you can't
// instantiate more than one factory.
// http://issues.apache.org/bugzilla/show_bug.cgi?id=24082
+ @Test
public void testJNDI2Pools() throws Exception {
Reference refObj = new Reference(SharedPoolDataSource.class.getName());
refObj.add(new
StringRefAddr("dataSourceName","java:comp/env/jdbc/bookstoreCPDS"));
Modified:
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestInstanceKeyDataSource.java
URL:
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestInstanceKeyDataSource.java?rev=1649422&r1=1649421&r2=1649422&view=diff
==============================================================================
---
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestInstanceKeyDataSource.java
(original)
+++
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestInstanceKeyDataSource.java
Sun Jan 4 21:10:47 2015
@@ -17,29 +17,26 @@
package org.apache.commons.dbcp2.datasources;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
import java.sql.Connection;
import java.sql.SQLException;
-import junit.framework.TestCase;
import org.apache.commons.dbcp2.cpdsadapter.DriverAdapterCPDS;
+import org.junit.Test;
/**
- * @version $Revision$ $Date$
+ * @version $Id:$
*/
-public class TestInstanceKeyDataSource extends TestCase {
- public TestInstanceKeyDataSource(String testName) {
- super(testName);
- }
-
- @Override
- public void setUp() throws Exception {
- }
-
+public class TestInstanceKeyDataSource {
+
/**
* Verify that exception on setupDefaults does not leak PooledConnection
*
* JIRA: DBCP-237
*/
+ @Test
public void testExceptionOnSetupDefaults() throws Exception {
DriverAdapterCPDS pcds;
pcds = new DriverAdapterCPDS();
Modified:
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestKeyedCPDSConnectionFactory.java
URL:
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestKeyedCPDSConnectionFactory.java?rev=1649422&r1=1649421&r2=1649422&view=diff
==============================================================================
---
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestKeyedCPDSConnectionFactory.java
(original)
+++
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestKeyedCPDSConnectionFactory.java
Sun Jan 4 21:10:47 2015
@@ -17,29 +17,29 @@
package org.apache.commons.dbcp2.datasources;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.sql.Connection;
import java.sql.SQLException;
import javax.sql.PooledConnection;
-import junit.framework.TestCase;
import org.apache.commons.dbcp2.cpdsadapter.DriverAdapterCPDS;
-
import org.apache.commons.pool2.KeyedObjectPool;
import org.apache.commons.pool2.impl.GenericKeyedObjectPool;
+import org.junit.Before;
+import org.junit.Test;
/**
- * @version $Revision$ $Date$
+ * @version $Id:$
*/
-public class TestKeyedCPDSConnectionFactory extends TestCase {
+public class TestKeyedCPDSConnectionFactory {
protected ConnectionPoolDataSourceProxy cpds = null;
- public TestKeyedCPDSConnectionFactory(String testName) {
- super(testName);
- }
-
- @Override
+ @Before
public void setUp() throws Exception {
cpds = new ConnectionPoolDataSourceProxy(new DriverAdapterCPDS());
DriverAdapterCPDS delegate = (DriverAdapterCPDS) cpds.getDelegate();
@@ -56,6 +56,7 @@ public class TestKeyedCPDSConnectionFact
* properly. PooledConnectionProxy (dubiously) fires connectionClosed
* when PooledConnection itself is closed.
*/
+ @Test
public void testSharedPoolDSDestroyOnReturn() throws Exception {
SharedPoolDataSource ds = new SharedPoolDataSource();
ds.setConnectionPoolDataSource(cpds);
@@ -80,6 +81,7 @@ public class TestKeyedCPDSConnectionFact
* Verify that pool counters are maintained properly and listeners are
* cleaned up when a PooledConnection throws a connectionError event.
*/
+ @Test
public void testConnectionErrorCleanup() throws Exception {
// Setup factory
UserPassKey key = new UserPassKey("username", "password");
Modified:
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestPerUserPoolDataSource.java
URL:
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestPerUserPoolDataSource.java?rev=1649422&r1=1649421&r2=1649422&view=diff
==============================================================================
---
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestPerUserPoolDataSource.java
(original)
+++
commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestPerUserPoolDataSource.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.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
@@ -32,16 +37,15 @@ import javax.sql.DataSource;
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 TestPerUserPoolDataSource extends TestConnectionPool {
- public TestPerUserPoolDataSource(String testName) {
- super(testName);
- }
@Override
protected Connection getConnection() throws SQLException {
@@ -50,9 +54,8 @@ public class TestPerUserPoolDataSource e
private DataSource ds;
- @Override
+ @Before
public void setUp() throws Exception {
- super.setUp();
DriverAdapterCPDS pcds = new DriverAdapterCPDS();
pcds.setDriver("org.apache.commons.dbcp2.TesterDriver");
pcds.setUrl("jdbc:apache:commons:testdriver");
@@ -72,12 +75,12 @@ public class TestPerUserPoolDataSource e
ds = tds;
}
-
/**
* Switching 'u1 -> 'u2' and 'p1' -> 'p2' will
* exhibit the bug detailed in
* http://issues.apache.org/bugzilla/show_bug.cgi?id=18905
*/
+ @Test
public void testIncorrectPassword() throws Exception {
// Use bad password
try (Connection c = ds.getConnection("u1", "zlsafjk");){
@@ -113,8 +116,8 @@ public class TestPerUserPoolDataSource e
}
}
-
@Override
+ @Test
public void testSimple() throws Exception
{
Connection conn = ds.getConnection();
@@ -129,6 +132,7 @@ public class TestPerUserPoolDataSource e
conn.close();
}
+ @Test
public void testSimpleWithUsername() throws Exception
{
Connection conn = ds.getConnection("u1", "p1");
@@ -143,6 +147,7 @@ public class TestPerUserPoolDataSource e
conn.close();
}
+ @Test
public void testClosingWithUserName()
throws Exception
{
@@ -174,6 +179,7 @@ public class TestPerUserPoolDataSource e
}
@Override
+ @Test
public void testSimple2()
throws Exception
{
@@ -228,6 +234,7 @@ public class TestPerUserPoolDataSource e
}
@Override
+ @Test
public void testOpening()
throws Exception
{
@@ -249,6 +256,7 @@ public class TestPerUserPoolDataSource e
}
@Override
+ @Test
public void testClosing()
throws Exception
{
@@ -272,6 +280,7 @@ public class TestPerUserPoolDataSource e
}
@Override
+ @Test
public void testMaxTotal() throws Exception {
Connection[] c = new Connection[getMaxTotal()];
for (int i=0; i<c.length; i++) {
@@ -295,6 +304,7 @@ public class TestPerUserPoolDataSource e
* Verify that defaultMaxWaitMillis = 0 means immediate failure when
* pool is exhausted.
*/
+ @Test
public void testMaxWaitMillisZero() throws Exception {
PerUserPoolDataSource tds = (PerUserPoolDataSource) ds;
tds.setDefaultMaxWaitMillis(0);
@@ -308,6 +318,7 @@ public class TestPerUserPoolDataSource e
conn.close();
}
+ @Test
public void testPerUserMethods() throws Exception {
PerUserPoolDataSource tds = (PerUserPoolDataSource) ds;
@@ -357,6 +368,7 @@ public class TestPerUserPoolDataSource e
assertEquals(0, tds.getNumIdle("u2"));
}
+ @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.
@@ -366,6 +378,7 @@ public class TestPerUserPoolDataSource e
multipleThreads(1, false, false, defaultMaxWaitMillis);
}
+ @Test
public void testMultipleThreads2() throws Exception {
final int defaultMaxWaitMillis = 500;
((PerUserPoolDataSource)
ds).setDefaultMaxWaitMillis(defaultMaxWaitMillis);
@@ -373,6 +386,7 @@ public class TestPerUserPoolDataSource e
multipleThreads(2 * defaultMaxWaitMillis, true, true,
defaultMaxWaitMillis);
}
+ @Test
public void testTransactionIsolationBehavior() throws Exception {
Connection conn = getConnection();
assertNotNull(conn);
@@ -392,6 +406,7 @@ public class TestPerUserPoolDataSource e
conn3.close();
}
+ @Test
public void testSerialization() throws Exception {
// make sure the pool has initialized
Connection conn = ds.getConnection();
@@ -414,6 +429,7 @@ public class TestPerUserPoolDataSource e
// see issue http://issues.apache.org/bugzilla/show_bug.cgi?id=23843
// unregistered user is in the same pool as without username
+ @Test
public void testUnregisteredUser() throws Exception {
PerUserPoolDataSource tds = (PerUserPoolDataSource) ds;
@@ -444,6 +460,7 @@ public class TestPerUserPoolDataSource e
}
// see issue http://issues.apache.org/bugzilla/show_bug.cgi?id=23843
+ @Test
public void testDefaultUser1() throws Exception {
TesterDriver.addUser("mkh", "password");
TesterDriver.addUser("hanafey", "password");
@@ -464,6 +481,7 @@ public class TestPerUserPoolDataSource e
}
// see issue http://issues.apache.org/bugzilla/show_bug.cgi?id=23843
+ @Test
public void testDefaultUser2() throws Exception {
TesterDriver.addUser("mkh", "password");
TesterDriver.addUser("hanafey", "password");
@@ -484,6 +502,7 @@ public class TestPerUserPoolDataSource e
}
// See DBCP-8
+ @Test
public void testChangePassword() throws Exception {
try (Connection c = ds.getConnection("foo", "bay")){
fail("Should have generated SQLException");