Java Code Examples for org.apache.ibatis.datasource.pooled.PooledDataSource#getPoolState()

The following examples show how to use org.apache.ibatis.datasource.pooled.PooledDataSource#getPoolState() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ForceCloseMybatisConnectionPoolTest.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Test
public void testForceCloseMybatisConnectionPoolTrue() {

    // given
    // 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();
    assertThat(state.getIdleConnectionCount()).isPositive();

    // then
    // if the  engine is closed
    dmnEngine.close();

    // the idle connections are closed
    assertThat(state.getIdleConnectionCount()).isZero();

}
 
Example 2
Source File: ForceCloseMybatisConnectionPoolTest.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Test
public void testForceCloseMybatisConnectionPoolFalse() {

    // given
    // 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();
    assertThat(state.getIdleConnectionCount()).isPositive();

    // then
    // if the  engine is closed
    dmnEngine.close();

    // the idle connections are not closed
    assertThat(state.getIdleConnectionCount()).isPositive();

    pooledDataSource.forceCloseAll();
    assertThat(state.getIdleConnectionCount()).isZero();
}
 
Example 3
Source File: ForceCloseMybatisConnectionPoolTest.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Test
public void testForceCloseMybatisConnectionPoolTrue() {

    // given
    // that the AbstractEngineConfiguration is configured with forceCloseMybatisConnectionPool = true
    StandaloneInMemIdmEngineConfiguration standaloneInMemIdmEngineConfiguration = new StandaloneInMemIdmEngineConfiguration();
    standaloneInMemIdmEngineConfiguration.setJdbcUrl("jdbc:h2:mem:flowable-idm-" + this.getClass().getName());
    standaloneInMemIdmEngineConfiguration.setForceCloseMybatisConnectionPool(true);
    standaloneInMemIdmEngineConfiguration.setDatabaseSchemaUpdate("drop-create");

    IdmEngine idmEngine = standaloneInMemIdmEngineConfiguration.buildIdmEngine();

    PooledDataSource pooledDataSource = (PooledDataSource) standaloneInMemIdmEngineConfiguration.getDataSource();
    PoolState state = pooledDataSource.getPoolState();
    assertThat(state.getIdleConnectionCount()).isPositive();

    // then
    // if the  engine is closed
    idmEngine.close();

    // the idle connections are closed
    assertThat(state.getIdleConnectionCount()).isZero();
}
 
Example 4
Source File: ForceCloseMybatisConnectionPoolTest.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Test
public void testForceCloseMybatisConnectionPoolFalse() {

    // given
    // that the AbstractEngineConfiguration is configured with forceCloseMybatisConnectionPool = false
    StandaloneInMemIdmEngineConfiguration standaloneInMemIdmEngineConfiguration = new StandaloneInMemIdmEngineConfiguration();
    standaloneInMemIdmEngineConfiguration.setJdbcUrl("jdbc:h2:mem:flowable-idm-" + this.getClass().getName());
    standaloneInMemIdmEngineConfiguration.setForceCloseMybatisConnectionPool(false);
    standaloneInMemIdmEngineConfiguration.setDatabaseSchemaUpdate("drop-create");

    IdmEngine idmEngine = standaloneInMemIdmEngineConfiguration.buildIdmEngine();

    PooledDataSource pooledDataSource = (PooledDataSource) standaloneInMemIdmEngineConfiguration.getDataSource();
    PoolState state = pooledDataSource.getPoolState();
    assertThat(state.getIdleConnectionCount()).isPositive();

    // then
    // if the  engine is closed
    idmEngine.close();

    // the idle connections are not closed
    assertThat(state.getIdleConnectionCount()).isPositive();

    pooledDataSource.forceCloseAll();
    assertThat(state.getIdleConnectionCount()).isZero();
}
 
Example 5
Source File: ForceCloseMybatisConnectionPoolTest.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Test
public void testForceCloseMybatisConnectionPoolTrue() {

    // given
    // 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();
    assertThat(state.getIdleConnectionCount()).isPositive();

    // then
    // if the  engine is closed
    cmmnEngine.close();

    // the idle connections are closed
    assertThat(state.getIdleConnectionCount()).isZero();
}
 
Example 6
Source File: ForceCloseMybatisConnectionPoolTest.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Test
public void testForceCloseMybatisConnectionPoolFalse() {

    // given
    // 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);

    standaloneInMemCmmnEngineConfiguration.buildCmmnEngine();

    PooledDataSource pooledDataSource = (PooledDataSource) standaloneInMemCmmnEngineConfiguration.getDataSource();
    PoolState state = pooledDataSource.getPoolState();
    assertThat(state.getIdleConnectionCount()).isPositive();

    // then
    // if the  engine is closed
    standaloneInMemCmmnEngineConfiguration.close();

    // the idle connections are not closed
    assertThat(state.getIdleConnectionCount()).isPositive();

    pooledDataSource.forceCloseAll();
    assertThat(state.getIdleConnectionCount()).isZero();
}
 
Example 7
Source File: ForceCloseMybatisConnectionPoolTest.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Test
public void testForceCloseMybatisConnectionPoolTrue() {

    // given
    // that the process engine is configured with forceCloseMybatisConnectionPool = true
    StandaloneInMemProcessEngineConfiguration standaloneInMemProcessEngineConfiguration =  new StandaloneInMemProcessEngineConfiguration();
    standaloneInMemProcessEngineConfiguration.setJdbcUrl("jdbc:h2:mem:flowable-bpmn-" + this.getClass().getName());
    standaloneInMemProcessEngineConfiguration.setForceCloseMybatisConnectionPool(true);

    ProcessEngine processEngine = standaloneInMemProcessEngineConfiguration.buildProcessEngine();

    PooledDataSource pooledDataSource = (PooledDataSource) standaloneInMemProcessEngineConfiguration.getDataSource();
    PoolState state = pooledDataSource.getPoolState();
    assertThat(state.getIdleConnectionCount()).isGreaterThan(0);

    // then
    // if the process engine is closed
    processEngine.close();

    // the idle connections are closed
    assertThat(state.getIdleConnectionCount()).isZero();
}
 
Example 8
Source File: ForceCloseMybatisConnectionPoolTest.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Test
public void testForceCloseMybatisConnectionPoolFalse() {

    // given
    // that the process engine is configured with forceCloseMybatisConnectionPool = false
    StandaloneInMemProcessEngineConfiguration standaloneInMemProcessEngineConfiguration =  new StandaloneInMemProcessEngineConfiguration();
    standaloneInMemProcessEngineConfiguration.setJdbcUrl("jdbc:h2:mem:flowable-bpmn-" + this.getClass().getName());
    standaloneInMemProcessEngineConfiguration.setForceCloseMybatisConnectionPool(false);
    ProcessEngine processEngine = standaloneInMemProcessEngineConfiguration.buildProcessEngine();

    PooledDataSource pooledDataSource = (PooledDataSource) standaloneInMemProcessEngineConfiguration.getDataSource();
    PoolState state = pooledDataSource.getPoolState();
    assertThat(state.getIdleConnectionCount()).isGreaterThan(0);

    // then
    // if the process engine is closed
    processEngine.close();

    // the idle connections are not closed
    assertThat(state.getIdleConnectionCount()).isGreaterThan(0);

    pooledDataSource.forceCloseAll();
    assertThat(state.getIdleConnectionCount()).isZero();
}
 
Example 9
Source File: ForceCloseMybatisConnectionPoolTest.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Test
public void testForceCloseMybatisConnectionPoolTrue() {

    // given
    // 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();
    assertThat(state.getIdleConnectionCount()).isPositive();

    // then
    // if the  engine is closed
    appEngine.close();

    // the idle connections are closed
    assertThat(state.getIdleConnectionCount()).isZero();
}
 
Example 10
Source File: ForceCloseMybatisConnectionPoolTest.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Test
public void testForceCloseMybatisConnectionPoolFalse() {

    // given
    // 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();
    assertThat(state.getIdleConnectionCount()).isPositive();

    // then
    // if the  engine is closed
    appEngine.close();

    // the idle connections are not closed
    assertThat(state.getIdleConnectionCount()).isPositive();

    pooledDataSource.forceCloseAll();
    assertThat(state.getIdleConnectionCount()).isZero();
}
 
Example 11
Source File: ForceCloseMybatisConnectionPoolTest.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Test
public void testForceCloseMybatisConnectionPoolTrue() {

    // given
    // that the AbstractEngineConfiguration is configured with forceCloseMybatisConnectionPool = true
    StandaloneInMemFormEngineConfiguration standaloneInMemFormEngineConfiguration =  new StandaloneInMemFormEngineConfiguration();
    standaloneInMemFormEngineConfiguration.setJdbcUrl("jdbc:h2:mem:flowable-form-" + this.getClass().getName());
    standaloneInMemFormEngineConfiguration.setForceCloseMybatisConnectionPool(true);

    FormEngine formEngine = standaloneInMemFormEngineConfiguration.buildFormEngine();


    PooledDataSource pooledDataSource = (PooledDataSource) standaloneInMemFormEngineConfiguration.getDataSource();
    PoolState state = pooledDataSource.getPoolState();
    assertThat(state.getIdleConnectionCount()).isPositive();

    // then
    // if the  engine is closed
    formEngine.close();

    // the idle connections are closed
    assertThat(state.getIdleConnectionCount()).isZero();

}
 
Example 12
Source File: ForceCloseMybatisConnectionPoolTest.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Test
public void testForceCloseMybatisConnectionPoolFalse() {

    // given
    // that the AbstractEngineConfiguration is configured with forceCloseMybatisConnectionPool = false
    StandaloneInMemFormEngineConfiguration standaloneInMemFormEngineConfiguration =  new StandaloneInMemFormEngineConfiguration();
    standaloneInMemFormEngineConfiguration.setJdbcUrl("jdbc:h2:mem:flowable-form-" + this.getClass().getName());
    standaloneInMemFormEngineConfiguration.setForceCloseMybatisConnectionPool(false);

    FormEngine formEngine = standaloneInMemFormEngineConfiguration.buildFormEngine();

    PooledDataSource pooledDataSource = (PooledDataSource) standaloneInMemFormEngineConfiguration.getDataSource();
    PoolState state = pooledDataSource.getPoolState();
    assertThat(state.getIdleConnectionCount()).isPositive();

    // then
    // if the  engine is closed
    formEngine.close();

    // the idle connections are not closed
    assertThat(state.getIdleConnectionCount()).isPositive();

    pooledDataSource.forceCloseAll();
    assertThat(state.getIdleConnectionCount()).isZero();
}
 
Example 13
Source File: ForceCloseMybatisConnectionPoolTest.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Test
public void testForceCloseMybatisConnectionPoolTrue() {

    // given
    // 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();
    assertThat(state.getIdleConnectionCount()).isPositive();

    // then
    // if the  engine is closed
    contentEngine.close();

    // the idle connections are closed
    assertThat(state.getIdleConnectionCount()).isEqualTo(0);

}
 
Example 14
Source File: ForceCloseMybatisConnectionPoolTest.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Test
public void testForceCloseMybatisConnectionPoolFalse() {

    // given
    // 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();
    assertThat(state.getIdleConnectionCount()).isPositive();

    // then
    // if the  engine is closed
    contentEngine.close();

    // the idle connections are not closed
    assertThat(state.getIdleConnectionCount()).isPositive();
    pooledDataSource.forceCloseAll();
    assertThat(state.getIdleConnectionCount()).isEqualTo(0);
}
 
Example 15
Source File: ForceCloseMybatisConnectionPoolTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@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);

}
 
Example 16
Source File: ForceCloseMybatisConnectionPoolTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@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);
}