Example usage for org.apache.commons.dbcp.cpdsadapter DriverAdapterCPDS getMinEvictableIdleTimeMillis

List of usage examples for org.apache.commons.dbcp.cpdsadapter DriverAdapterCPDS getMinEvictableIdleTimeMillis

Introduction

In this page you can find the example usage for org.apache.commons.dbcp.cpdsadapter DriverAdapterCPDS getMinEvictableIdleTimeMillis.

Prototype

public int getMinEvictableIdleTimeMillis() 

Source Link

Document

Returns the minimum amount of time a statement may sit idle in the pool before it is eligible for eviction by the idle object evictor (if any).

Usage

From source file:org.mybatis.guice.datasource.dbcp.DriverAdapterCPDSProviderTest.java

@Test
public void get() throws Throwable {
    final String driver = TestDriver.class.getName();
    final String url = "jdbc:h2:mem:testdb";
    final String username = "test_user";
    final String password = "test_password";
    final int loginTimeout = 10;
    final String description = "test_description";
    final int maxActive = 20;
    final int maxIdle = 30;
    final int maxOpenPreparedStatements = 40;
    final int minEvictableIdleTimeMillis = 50;
    final int numTestsPerEvictionRun = 60;
    final boolean poolPreparedStatements = true;
    final int timeBetweenEvictionRunsMillis = 70;
    Injector injector = Guice.createInjector(new AbstractModule() {
        @Override// w w w .  j  a va 2s.  c o  m
        protected void configure() {
            bindConstant().annotatedWith(Names.named("JDBC.driver")).to(driver);
            bindConstant().annotatedWith(Names.named("JDBC.url")).to(url);
            bindConstant().annotatedWith(Names.named("JDBC.username")).to(username);
            bindConstant().annotatedWith(Names.named("JDBC.password")).to(password);
            bindConstant().annotatedWith(Names.named("JDBC.loginTimeout")).to(loginTimeout);
            bindConstant().annotatedWith(Names.named("DBCP.description")).to(description);
            bindConstant().annotatedWith(Names.named("DBCP.maxActive")).to(maxActive);
            bindConstant().annotatedWith(Names.named("DBCP.maxIdle")).to(maxIdle);
            bindConstant().annotatedWith(Names.named("DBCP.maxOpenPreparedStatements"))
                    .to(maxOpenPreparedStatements);
            bindConstant().annotatedWith(Names.named("DBCP.minEvictableIdleTimeMillis"))
                    .to(minEvictableIdleTimeMillis);
            bindConstant().annotatedWith(Names.named("DBCP.numTestsPerEvictionRun")).to(numTestsPerEvictionRun);
            bindConstant().annotatedWith(Names.named("DBCP.poolPreparedStatements")).to(poolPreparedStatements);
            bindConstant().annotatedWith(Names.named("DBCP.timeBetweenEvictionRunsMillis"))
                    .to(timeBetweenEvictionRunsMillis);
        }
    });
    DriverAdapterCPDSProvider provider = injector.getInstance(DriverAdapterCPDSProvider.class);

    DriverAdapterCPDS adapter = (DriverAdapterCPDS) provider.get();

    assertEquals(driver, adapter.getDriver());
    assertEquals(url, adapter.getUrl());
    assertEquals(username, adapter.getUser());
    assertEquals(password, adapter.getPassword());
    assertEquals(loginTimeout, adapter.getLoginTimeout());
    assertEquals(description, adapter.getDescription());
    assertEquals(maxActive, adapter.getMaxActive());
    assertEquals(maxIdle, adapter.getMaxIdle());
    assertEquals(maxOpenPreparedStatements, adapter.getMaxPreparedStatements());
    assertEquals(minEvictableIdleTimeMillis, adapter.getMinEvictableIdleTimeMillis());
    assertEquals(numTestsPerEvictionRun, adapter.getNumTestsPerEvictionRun());
    assertEquals(poolPreparedStatements, adapter.isPoolPreparedStatements());
    assertEquals(timeBetweenEvictionRunsMillis, adapter.getTimeBetweenEvictionRunsMillis());
}

From source file:org.mybatis.guice.datasource.dbcp.DriverAdapterCPDSProviderTest.java

@Test
public void getOtherValues() throws Throwable {
    final String driver = TestDriver2.class.getName();
    final String url = "jdbc:h2:mem:testdb2";
    final String username = "test_user2";
    final String password = "test_password2";
    final int loginTimeout = 11;
    final String description = "test_description2";
    final int maxActive = 21;
    final int maxIdle = 31;
    final int maxOpenPreparedStatements = 41;
    final int minEvictableIdleTimeMillis = 51;
    final int numTestsPerEvictionRun = 61;
    final boolean poolPreparedStatements = false;
    final int timeBetweenEvictionRunsMillis = 71;
    Injector injector = Guice.createInjector(new AbstractModule() {
        @Override/*  w  w  w .j  a  v  a 2 s .  c  o m*/
        protected void configure() {
            bindConstant().annotatedWith(Names.named("JDBC.driver")).to(driver);
            bindConstant().annotatedWith(Names.named("JDBC.url")).to(url);
            bindConstant().annotatedWith(Names.named("JDBC.username")).to(username);
            bindConstant().annotatedWith(Names.named("JDBC.password")).to(password);
            bindConstant().annotatedWith(Names.named("JDBC.loginTimeout")).to(loginTimeout);
            bindConstant().annotatedWith(Names.named("DBCP.description")).to(description);
            bindConstant().annotatedWith(Names.named("DBCP.maxActive")).to(maxActive);
            bindConstant().annotatedWith(Names.named("DBCP.maxIdle")).to(maxIdle);
            bindConstant().annotatedWith(Names.named("DBCP.maxOpenPreparedStatements"))
                    .to(maxOpenPreparedStatements);
            bindConstant().annotatedWith(Names.named("DBCP.minEvictableIdleTimeMillis"))
                    .to(minEvictableIdleTimeMillis);
            bindConstant().annotatedWith(Names.named("DBCP.numTestsPerEvictionRun")).to(numTestsPerEvictionRun);
            bindConstant().annotatedWith(Names.named("DBCP.poolPreparedStatements")).to(poolPreparedStatements);
            bindConstant().annotatedWith(Names.named("DBCP.timeBetweenEvictionRunsMillis"))
                    .to(timeBetweenEvictionRunsMillis);
        }
    });
    DriverAdapterCPDSProvider provider = injector.getInstance(DriverAdapterCPDSProvider.class);

    DriverAdapterCPDS adapter = (DriverAdapterCPDS) provider.get();

    assertEquals(driver, adapter.getDriver());
    assertEquals(url, adapter.getUrl());
    assertEquals(username, adapter.getUser());
    assertEquals(password, adapter.getPassword());
    assertEquals(loginTimeout, adapter.getLoginTimeout());
    assertEquals(description, adapter.getDescription());
    assertEquals(maxActive, adapter.getMaxActive());
    assertEquals(maxIdle, adapter.getMaxIdle());
    assertEquals(maxOpenPreparedStatements, adapter.getMaxPreparedStatements());
    assertEquals(minEvictableIdleTimeMillis, adapter.getMinEvictableIdleTimeMillis());
    assertEquals(numTestsPerEvictionRun, adapter.getNumTestsPerEvictionRun());
    assertEquals(poolPreparedStatements, adapter.isPoolPreparedStatements());
    assertEquals(timeBetweenEvictionRunsMillis, adapter.getTimeBetweenEvictionRunsMillis());
}