org.apache.commons.dbcp
Class TestConnectionPool
java.lang.Object
junit.framework.Assert
junit.framework.TestCase
org.apache.commons.dbcp.TestConnectionPool
- All Implemented Interfaces:
- junit.framework.Test
- Direct Known Subclasses:
- TestBasicDataSource, TestJOCLed, TestManagedDataSource, TestManual, TestPerUserPoolDataSource, TestPoolingDataSource, TestSharedPoolDataSource
public abstract class TestConnectionPool
- extends junit.framework.TestCase
Base test suite for DBCP pools.
- Version:
- $Revision: 1023401 $ $Date: 2010-10-16 21:54:24 -0400 (Sat, 16 Oct 2010) $
- Author:
- Rodney Waldhoff, Sean C. Sullivan, John McNally, Dirk Verbeeck
|
Field Summary |
protected Stack |
connections
Connections opened during the course of a test |
| Methods inherited from class junit.framework.TestCase |
countTestCases, createResult, getName, run, run, runBare, runTest, setName, setUp, toString |
| Methods inherited from class junit.framework.Assert |
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame |
connections
protected Stack connections
- Connections opened during the course of a test
TestConnectionPool
public TestConnectionPool(String testName)
tearDown
public void tearDown()
throws Exception
- Overrides:
tearDown in class junit.framework.TestCase
- Throws:
Exception
getConnection
protected abstract Connection getConnection()
throws Exception
- Throws:
Exception
getMaxActive
protected int getMaxActive()
getMaxWait
protected long getMaxWait()
newConnection
protected Connection newConnection()
throws Exception
- Acquire a connection and push it onto the connections stack
- Throws:
Exception
getUsername
protected String getUsername(Connection conn)
throws SQLException
- Throws:
SQLException
testClearWarnings
public void testClearWarnings()
throws Exception
- Throws:
Exception
testIsClosed
public void testIsClosed()
throws Exception
- Throws:
Exception
testCanCloseConnectionTwice
public void testCanCloseConnectionTwice()
throws Exception
- Verify the close method can be called multiple times on a single connection without
an exception being thrown.
- Throws:
Exception
testCanCloseStatementTwice
public void testCanCloseStatementTwice()
throws Exception
- Throws:
Exception
testCanClosePreparedStatementTwice
public void testCanClosePreparedStatementTwice()
throws Exception
- Throws:
Exception
testCanCloseCallableStatementTwice
public void testCanCloseCallableStatementTwice()
throws Exception
- Throws:
Exception
testCanCloseResultSetTwice
public void testCanCloseResultSetTwice()
throws Exception
- Throws:
Exception
testBackPointers
public void testBackPointers()
throws Exception
- Throws:
Exception
assertBackPointers
protected void assertBackPointers(Connection conn,
Statement statement)
throws SQLException
- Throws:
SQLException
testSimple
public void testSimple()
throws Exception
- Throws:
Exception
testRepeatedBorrowAndReturn
public void testRepeatedBorrowAndReturn()
throws Exception
- Throws:
Exception
testSimple2
public void testSimple2()
throws Exception
- Throws:
Exception
testPooling
public void testPooling()
throws Exception
- Throws:
Exception
testAutoCommitBehavior
public void testAutoCommitBehavior()
throws Exception
- Throws:
Exception
testConnectionsAreDistinct
public void testConnectionsAreDistinct()
throws Exception
- Throws:
Exception- See Also:
- "http://issues.apache.org/bugzilla/show_bug.cgi?id=12400"
testOpening
public void testOpening()
throws Exception
- Throws:
Exception
testClosing
public void testClosing()
throws Exception
- Throws:
Exception
testMaxActive
public void testMaxActive()
throws Exception
- Throws:
Exception
testHashing
public void testHashing()
throws Exception
- DBCP-128: BasicDataSource.getConnection()
Connections don't work as hashtable keys
- Throws:
Exception
testThreaded
public void testThreaded()
testPrepareStatementOptions
public void testPrepareStatementOptions()
throws Exception
- Throws:
Exception
testNoRsetClose
public void testNoRsetClose()
throws Exception
- Throws:
Exception
testHashCode
public void testHashCode()
throws Exception
- Throws:
Exception
isClosed
protected boolean isClosed(Statement statement)
isClosed
protected boolean isClosed(ResultSet resultSet)
multipleThreads
protected void multipleThreads(int holdTime,
boolean expectError,
boolean loopOnce,
long maxWait)
throws Exception
- Launches a group of 2 * getMaxActive() threads, each of which will attempt to obtain a connection
from the pool, hold it for ms, and then return it to the pool. If is false,
threads will continue this process indefinitely. If is true, exactly 1/2 of the
threads are expected to either throw exceptions or fail to complete. If is false,
all threads are expected to complete successfully.
- Parameters:
holdTime - time in ms that a thread holds a connection before returning it to the poolexpectError - whether or not an error is expectedloopOnce - whether threads should complete the borrow - hold - return cycle only once, or loop indefinitelymaxWait - passed in by client - has no impact on the test itself, but does get reported
- Throws:
Exception
Copyright © 2001-2010 The Apache Software Foundation. All Rights Reserved.