List of usage examples for org.apache.ibatis.datasource.pooled PooledDataSource getPoolState
public PoolState getPoolState()
From source file:org.camunda.bpm.engine.test.api.cfg.ForceCloseMybatisConnectionPoolTest.java
License:Apache License
@Test public void testForceCloseMybatisConnectionPoolTrue() { // given// www . j a v a 2 s . com // 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); }
From source file:org.camunda.bpm.engine.test.api.cfg.ForceCloseMybatisConnectionPoolTest.java
License:Apache License
@Test public void testForceCloseMybatisConnectionPoolFalse() { // given//w w w .ja v a 2 s . c o m // 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); }
From source file:org.flowable.app.engine.test.cfg.ForceCloseMybatisConnectionPoolTest.java
License:Apache License
@Test public void testForceCloseMybatisConnectionPoolTrue() { // given/*www . ja v a 2 s . c om*/ // that the AbstractEngineConfiguration is configured with forceCloseMybatisConnectionPool = true StandaloneInMemAppEngineConfiguration appEngineConfiguration = new StandaloneInMemAppEngineConfiguration(); appEngineConfiguration.setJdbcUrl("jdbc:h2:mem:flowable-app-" + this.getClass().getName()); appEngineConfiguration.setForceCloseMybatisConnectionPool(true); AppEngine appEngine = appEngineConfiguration.buildAppEngine(); PooledDataSource pooledDataSource = (PooledDataSource) appEngineConfiguration.getDataSource(); PoolState state = pooledDataSource.getPoolState(); assertTrue(state.getIdleConnectionCount() > 0); // then // if the engine is closed appEngine.close(); // the idle connections are closed assertEquals(0, state.getIdleConnectionCount()); }
From source file:org.flowable.app.engine.test.cfg.ForceCloseMybatisConnectionPoolTest.java
License:Apache License
@Test public void testForceCloseMybatisConnectionPoolFalse() { // given/*from ww w . j av a 2 s. c om*/ // that the AbstractEngineConfiguration is configured with forceCloseMybatisConnectionPool = false StandaloneInMemAppEngineConfiguration appEngineConfiguration = new StandaloneInMemAppEngineConfiguration(); appEngineConfiguration.setJdbcUrl("jdbc:h2:mem:flowable-app-" + this.getClass().getName()); appEngineConfiguration.setForceCloseMybatisConnectionPool(false); AppEngine appEngine = appEngineConfiguration.buildAppEngine(); PooledDataSource pooledDataSource = (PooledDataSource) appEngineConfiguration.getDataSource(); PoolState state = pooledDataSource.getPoolState(); assertTrue(state.getIdleConnectionCount() > 0); // then // if the engine is closed appEngine.close(); // the idle connections are not closed assertTrue(state.getIdleConnectionCount() > 0); pooledDataSource.forceCloseAll(); assertEquals(0, state.getIdleConnectionCount()); }
From source file:org.flowable.cmmn.test.cfg.ForceCloseMybatisConnectionPoolTest.java
License:Apache License
@Test public void testForceCloseMybatisConnectionPoolTrue() { // given/* ww w. ja va 2 s . c o m*/ // that the AbstractEngineConfiguration is configured with forceCloseMybatisConnectionPool = true StandaloneInMemCmmnEngineConfiguration standaloneInMemCmmnEngineConfiguration = new StandaloneInMemCmmnEngineConfiguration(); standaloneInMemCmmnEngineConfiguration.setJdbcUrl("jdbc:h2:mem:flowable-cmmn-" + this.getClass().getName()); standaloneInMemCmmnEngineConfiguration.setForceCloseMybatisConnectionPool(true); CmmnEngine cmmnEngine = standaloneInMemCmmnEngineConfiguration.buildCmmnEngine(); PooledDataSource pooledDataSource = (PooledDataSource) standaloneInMemCmmnEngineConfiguration .getDataSource(); PoolState state = pooledDataSource.getPoolState(); assertTrue(state.getIdleConnectionCount() > 0); // then // if the engine is closed cmmnEngine.close(); // the idle connections are closed assertEquals(0, state.getIdleConnectionCount()); }
From source file:org.flowable.cmmn.test.cfg.ForceCloseMybatisConnectionPoolTest.java
License:Apache License
@Test public void testForceCloseMybatisConnectionPoolFalse() { // given//w w w .j a v a 2 s.co m // that the AbstractEngineConfiguration is configured with forceCloseMybatisConnectionPool = false StandaloneInMemCmmnEngineConfiguration standaloneInMemCmmnEngineConfiguration = new StandaloneInMemCmmnEngineConfiguration(); standaloneInMemCmmnEngineConfiguration.setJdbcUrl("jdbc:h2:mem:flowable-cmmn-" + this.getClass().getName()); standaloneInMemCmmnEngineConfiguration.setForceCloseMybatisConnectionPool(false); CmmnEngine cmmnEngine = standaloneInMemCmmnEngineConfiguration.buildCmmnEngine(); PooledDataSource pooledDataSource = (PooledDataSource) standaloneInMemCmmnEngineConfiguration .getDataSource(); PoolState state = pooledDataSource.getPoolState(); assertTrue(state.getIdleConnectionCount() > 0); // then // if the engine is closed standaloneInMemCmmnEngineConfiguration.close(); // the idle connections are not closed assertTrue(state.getIdleConnectionCount() > 0); pooledDataSource.forceCloseAll(); assertEquals(0, state.getIdleConnectionCount()); }
From source file:org.flowable.content.engine.test.ForceCloseMybatisConnectionPoolTest.java
License:Apache License
@Test public void testForceCloseMybatisConnectionPoolTrue() { // given/* w ww .j av a2 s. co m*/ // that the AbstractEngineConfiguration is configured with forceCloseMybatisConnectionPool = true StandaloneInMemContentEngineConfiguration standaloneInMemContentEngineConfiguration = new StandaloneInMemContentEngineConfiguration(); standaloneInMemContentEngineConfiguration .setJdbcUrl("jdbc:h2:mem:flowable-content-" + this.getClass().getName()); standaloneInMemContentEngineConfiguration.setForceCloseMybatisConnectionPool(true); ContentEngine contentEngine = standaloneInMemContentEngineConfiguration.buildContentEngine(); PooledDataSource pooledDataSource = (PooledDataSource) standaloneInMemContentEngineConfiguration .getDataSource(); PoolState state = pooledDataSource.getPoolState(); assertTrue(state.getIdleConnectionCount() > 0); // then // if the engine is closed contentEngine.close(); // the idle connections are closed assertEquals(0, state.getIdleConnectionCount()); }
From source file:org.flowable.content.engine.test.ForceCloseMybatisConnectionPoolTest.java
License:Apache License
@Test public void testForceCloseMybatisConnectionPoolFalse() { // given/*from w w w. ja v a 2 s .c om*/ // that the AbstractEngineConfiguration is configured with forceCloseMybatisConnectionPool = false StandaloneInMemContentEngineConfiguration standaloneInMemContentEngineConfiguration = new StandaloneInMemContentEngineConfiguration(); standaloneInMemContentEngineConfiguration .setJdbcUrl("jdbc:h2:mem:flowable-content-" + this.getClass().getName()); standaloneInMemContentEngineConfiguration.setForceCloseMybatisConnectionPool(false); ContentEngine contentEngine = standaloneInMemContentEngineConfiguration.buildContentEngine(); PooledDataSource pooledDataSource = (PooledDataSource) standaloneInMemContentEngineConfiguration .getDataSource(); PoolState state = pooledDataSource.getPoolState(); assertTrue(state.getIdleConnectionCount() > 0); // then // if the engine is closed contentEngine.close(); // the idle connections are not closed assertTrue(state.getIdleConnectionCount() > 0); pooledDataSource.forceCloseAll(); assertEquals(0, state.getIdleConnectionCount()); }
From source file:org.flowable.dmn.engine.test.cfg.ForceCloseMybatisConnectionPoolTest.java
License:Apache License
@Test public void testForceCloseMybatisConnectionPoolTrue() { // given/*from w ww .j av a 2 s. c o m*/ // that the AbstractEngineConfiguration is configured with forceCloseMybatisConnectionPool = true StandaloneInMemDmnEngineConfiguration standaloneInMemDmnEngineConfiguration = new StandaloneInMemDmnEngineConfiguration(); standaloneInMemDmnEngineConfiguration.setJdbcUrl("jdbc:h2:mem:flowable-dmn-" + this.getClass().getName()); standaloneInMemDmnEngineConfiguration.setForceCloseMybatisConnectionPool(true); DmnEngine dmnEngine = standaloneInMemDmnEngineConfiguration.buildDmnEngine(); PooledDataSource pooledDataSource = (PooledDataSource) standaloneInMemDmnEngineConfiguration .getDataSource(); PoolState state = pooledDataSource.getPoolState(); assertTrue(state.getIdleConnectionCount() > 0); // then // if the engine is closed dmnEngine.close(); // the idle connections are closed assertEquals(0, state.getIdleConnectionCount()); }
From source file:org.flowable.dmn.engine.test.cfg.ForceCloseMybatisConnectionPoolTest.java
License:Apache License
@Test public void testForceCloseMybatisConnectionPoolFalse() { // given/*from ww w .ja v a 2s . co m*/ // that the AbstractEngineConfiguration is configured with forceCloseMybatisConnectionPool = false StandaloneInMemDmnEngineConfiguration standaloneInMemDmnEngineConfiguration = new StandaloneInMemDmnEngineConfiguration(); standaloneInMemDmnEngineConfiguration.setJdbcUrl("jdbc:h2:mem:flowable-dmn-" + this.getClass().getName()); standaloneInMemDmnEngineConfiguration.setForceCloseMybatisConnectionPool(false); DmnEngine dmnEngine = standaloneInMemDmnEngineConfiguration.buildDmnEngine(); PooledDataSource pooledDataSource = (PooledDataSource) standaloneInMemDmnEngineConfiguration .getDataSource(); PoolState state = pooledDataSource.getPoolState(); assertTrue(state.getIdleConnectionCount() > 0); // then // if the engine is closed dmnEngine.close(); // the idle connections are not closed assertTrue(state.getIdleConnectionCount() > 0); pooledDataSource.forceCloseAll(); assertEquals(0, state.getIdleConnectionCount()); }