use of org.infinispan.persistence.jdbc.common.impl.connectionfactory.PooledConnectionFactory in project infinispan by infinispan.
the class UnitTestDatabaseManager method verifyConnectionLeaks.
public static void verifyConnectionLeaks(ConnectionFactory connectionFactory) {
if (connectionFactory instanceof PooledConnectionFactory) {
PooledConnectionFactory pcf = (PooledConnectionFactory) connectionFactory;
try {
// C3P0 needs a little delay before reporting the correct number of connections. Bah!
Thread.sleep(500);
assertEquals(pcf.getActiveConnections(), 0);
} catch (Exception e) {
throw new RuntimeException(e);
}
} else if (connectionFactory instanceof SimpleConnectionFactory) {
SimpleConnectionFactory scf = (SimpleConnectionFactory) connectionFactory;
assertEquals(scf.getConnectionCount(), 0);
}
}
use of org.infinispan.persistence.jdbc.common.impl.connectionfactory.PooledConnectionFactory in project infinispan by infinispan.
the class TableManagerTest method testConnectionLeakGuessDialect.
public void testConnectionLeakGuessDialect() {
JdbcStringBasedStoreConfigurationBuilder storeBuilder = TestCacheManagerFactory.getDefaultCacheConfiguration(false).persistence().addStore(JdbcStringBasedStoreConfigurationBuilder.class);
UnitTestDatabaseManager.buildTableManipulation(storeBuilder.table());
PooledConnectionFactory connectionFactory = new PooledConnectionFactory();
ConnectionFactoryConfiguration config = UnitTestDatabaseManager.configureUniqueConnectionFactory(storeBuilder).create();
connectionFactory.start(config, Thread.currentThread().getContextClassLoader());
// JdbcStringBasedStoreConfiguration defaults to null dialect, so dialect and versions must be guessed
TableManager tableManager = TableManagerFactory.getManager(ctx, connectionFactory, storeBuilder.create(), "GuessDialect");
tableManager.start();
UnitTestDatabaseManager.verifyConnectionLeaks(connectionFactory);
tableManager.stop();
connectionFactory.stop();
}
Aggregations