use of org.apache.ibatis.datasource.pooled.PoolState in project camunda-bpm-platform by camunda.
the class ForceCloseMybatisConnectionPoolTest method testForceCloseMybatisConnectionPoolFalse.
@Test
public void testForceCloseMybatisConnectionPoolFalse() {
// given
// that the process engine is configured with forceCloseMybatisConnectionPool = false
ProcessEngineConfigurationImpl configurationImpl = new StandaloneInMemProcessEngineConfiguration().setJdbcUrl("jdbc:h2:mem:camunda-forceclose").setProcessEngineName("engine-forceclose").setForceCloseMybatisConnectionPool(false);
ProcessEngine processEngine = configurationImpl.buildProcessEngine();
PooledDataSource pooledDataSource = (PooledDataSource) configurationImpl.getDataSource();
PoolState state = pooledDataSource.getPoolState();
int idleConnections = state.getIdleConnectionCount();
// then
// if the process engine is closed
processEngine.close();
// the idle connections are not closed
Assert.assertEquals(state.getIdleConnectionCount(), idleConnections);
pooledDataSource.forceCloseAll();
Assert.assertTrue(state.getIdleConnectionCount() == 0);
}
use of org.apache.ibatis.datasource.pooled.PoolState in project camunda-bpm-platform by camunda.
the class ForceCloseMybatisConnectionPoolTest method testForceCloseMybatisConnectionPoolTrue.
@Test
public void testForceCloseMybatisConnectionPoolTrue() {
// given
// that the process engine is configured with forceCloseMybatisConnectionPool = true
ProcessEngineConfigurationImpl configurationImpl = new StandaloneInMemProcessEngineConfiguration().setJdbcUrl("jdbc:h2:mem:camunda-forceclose").setProcessEngineName("engine-forceclose").setForceCloseMybatisConnectionPool(true);
ProcessEngine processEngine = configurationImpl.buildProcessEngine();
PooledDataSource pooledDataSource = (PooledDataSource) configurationImpl.getDataSource();
PoolState state = pooledDataSource.getPoolState();
// then
// if the process engine is closed
processEngine.close();
// the idle connections are closed
Assert.assertTrue(state.getIdleConnectionCount() == 0);
}
Aggregations