MockConnectionPoolDataSource mockConnectionPoolDataSource = new MockConnectionPoolDataSource();
ManagedDataSource dataSource = new MockManagedDataSource(1, new Duration(10, MILLISECONDS));
mockConnectionPoolDataSource.closeException = new SQLException();
assertEquals(dataSource.getConnectionsActive(), 0);
MockConnection connection = (MockConnection) dataSource.getConnection();
assertNotNull(connection);
assertEquals(dataSource.getConnectionsActive(), 1);
connection.close();
assertEquals(dataSource.getConnectionsActive(), 0);
connection = (MockConnection) dataSource.getConnection();
assertNotNull(connection);
assertEquals(dataSource.getConnectionsActive(), 1);
connection.close();
assertEquals(dataSource.getConnectionsActive(), 0);
connection.errorOccurred();
assertEquals(dataSource.getConnectionsActive(), 0);
}