1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-11 00:12:06 +03:00

Aaron's patch for Pooled Connections

This commit is contained in:
Dave Cramer
2002-12-11 11:42:14 +00:00
parent 0046d80b97
commit a905eaacf0
2 changed files with 168 additions and 6 deletions

View File

@@ -11,7 +11,7 @@ import java.sql.*;
* interface to the PooledConnection is through the CPDS.
*
* @author Aaron Mulder (ammulder@chariotsolutions.com)
* @version $Revision: 1.3 $
* @version $Revision: 1.4 $
*/
public class ConnectionPoolTest extends BaseDataSourceTest
{
@@ -341,7 +341,63 @@ public class ConnectionPoolTest extends BaseDataSourceTest
}
}
/**
/**
* Ensures that a statement generated by a proxied connection returns the
* proxied connection from getConnection() [not the physical connection].
*/
public void testStatementConnection() {
try {
PooledConnection pc = getPooledConnection();
Connection con = pc.getConnection();
Statement s = con.createStatement();
Connection conRetrieved = s.getConnection();
assertTrue(con.getClass().equals(conRetrieved.getClass()));
assertTrue(con.equals(conRetrieved));
} catch (SQLException e) {
fail(e.getMessage());
}
}
/**
* Ensures that a prepared statement generated by a proxied connection
* returns the proxied connection from getConnection() [not the physical
* connection].
*/
public void testPreparedStatementConnection() {
try {
PooledConnection pc = getPooledConnection();
Connection con = pc.getConnection();
PreparedStatement s = con.prepareStatement("select 'x'");
Connection conRetrieved = s.getConnection();
assertTrue(con.getClass().equals(conRetrieved.getClass()));
assertTrue(con.equals(conRetrieved));
} catch (SQLException e) {
fail(e.getMessage());
}
}
/**
* Ensures that a callable statement generated by a proxied connection
* returns the proxied connection from getConnection() [not the physical
* connection].
*/
public void testCallableStatementConnection() {
try {
PooledConnection pc = getPooledConnection();
Connection con = pc.getConnection();
CallableStatement s = con.prepareCall("select 'x'");
Connection conRetrieved = s.getConnection();
assertTrue(con.getClass().equals(conRetrieved.getClass()));
assertTrue(con.equals(conRetrieved));
} catch (SQLException e) {
fail(e.getMessage());
}
}
/**
* Helper class to remove a listener during event dispatching.
*/
private class RemoveClose implements ConnectionEventListener