public void testAbandonedCloseWithExceptions() throws Exception {
// force abandoned
ds.setRemoveAbandonedTimeout(0);
ds.setMaxActive(1);
ds.setAccessToUnderlyingConnectionAllowed(true);
Connection conn1 = getConnection();
assertNotNull(conn1);
assertEquals(1, ds.getNumActive());
Connection conn2 = getConnection();
assertNotNull(conn2);
assertEquals(1, ds.getNumActive());
// set an IO failure causing the isClosed mathod to fail
TesterConnection tconn1 = (TesterConnection) ((DelegatingConnection)conn1).getInnermostDelegate();
tconn1.setFailure(new IOException("network error"));
TesterConnection tconn2 = (TesterConnection) ((DelegatingConnection)conn2).getInnermostDelegate();
tconn2.setFailure(new IOException("network error"));
try { conn2.close(); } catch (SQLException ex) { }
assertEquals(0, ds.getNumActive());
try { conn1.close(); } catch (SQLException ex) { }
assertEquals(0, ds.getNumActive());
}
|