public void testDuplicateClose() throws Exception {
Field poolField = poolingDataSource1.getClass().getDeclaredField("pool");
poolField.setAccessible(true);
XAPool pool = (XAPool) poolField.get(poolingDataSource1);
assertEquals(POOL_SIZE, pool.inPoolSize());
if (log.isDebugEnabled()) log.debug(" *** getting connection");
Connection c = poolingDataSource1.getConnection();
assertEquals(POOL_SIZE -1, pool.inPoolSize());
if (log.isDebugEnabled()) log.debug(" *** closing once");
c.close();
assertEquals(POOL_SIZE, pool.inPoolSize());
if (log.isDebugEnabled()) log.debug(" *** closing twice");
c.close();
assertEquals(POOL_SIZE, pool.inPoolSize());
if (log.isDebugEnabled()) log.debug(" *** checking pool size");
Connection c1 = poolingDataSource1.getConnection();
Connection c2 = poolingDataSource1.getConnection();
Connection c3 = poolingDataSource1.getConnection();
Connection c4 = poolingDataSource1.getConnection();
Connection c5 = poolingDataSource1.getConnection();
assertEquals(POOL_SIZE -5, pool.inPoolSize());
c1.close();
c2.close();
c3.close();
c4.close();
c5.close();
assertEquals(POOL_SIZE, pool.inPoolSize());
if (log.isDebugEnabled()) log.debug(" *** done");
}