Search in sources :

Example 1 with PoolState

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);
}
Also used : PoolState(org.apache.ibatis.datasource.pooled.PoolState) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) StandaloneInMemProcessEngineConfiguration(org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration) ProcessEngine(org.camunda.bpm.engine.ProcessEngine) PooledDataSource(org.apache.ibatis.datasource.pooled.PooledDataSource) Test(org.junit.Test)

Example 2 with PoolState

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);
}
Also used : PoolState(org.apache.ibatis.datasource.pooled.PoolState) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) StandaloneInMemProcessEngineConfiguration(org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration) ProcessEngine(org.camunda.bpm.engine.ProcessEngine) PooledDataSource(org.apache.ibatis.datasource.pooled.PooledDataSource) Test(org.junit.Test)

Aggregations

PoolState (org.apache.ibatis.datasource.pooled.PoolState)2 PooledDataSource (org.apache.ibatis.datasource.pooled.PooledDataSource)2 ProcessEngine (org.camunda.bpm.engine.ProcessEngine)2 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)2 StandaloneInMemProcessEngineConfiguration (org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration)2 Test (org.junit.Test)2