Search in sources :

Example 1 with NullExceptionSorter

use of com.alibaba.druid.pool.vendor.NullExceptionSorter in project druid by alibaba.

the class PoolableStatementTest2 method setUp.

protected void setUp() throws Exception {
    DruidDataSourceStatManager.clear();
    driver = new MockDriver();
    dataSource = new DruidDataSource();
    dataSource.setUrl("jdbc:mock:xxx");
    dataSource.setDriver(driver);
    dataSource.setInitialSize(1);
    dataSource.setMaxActive(2);
    dataSource.setMaxIdle(2);
    dataSource.setMinIdle(1);
    // 300 / 10
    dataSource.setMinEvictableIdleTimeMillis(300 * 1000);
    // 180 / 10
    dataSource.setTimeBetweenEvictionRunsMillis(180 * 1000);
    dataSource.setTestWhileIdle(true);
    dataSource.setTestOnBorrow(false);
    dataSource.setValidationQuery("SELECT 1");
    dataSource.setFilters("stat,trace");
    dataSource.setRemoveAbandoned(true);
    dataSource.setExceptionSorterClassName(null);
    Assert.assertTrue(dataSource.getExceptionSorter() instanceof NullExceptionSorter);
    dataSource.setExceptionSorterClassName("");
    Assert.assertTrue(dataSource.getExceptionSorter() instanceof NullExceptionSorter);
    JdbcStatContext context = new JdbcStatContext();
    context.setTraceEnable(true);
    JdbcStatManager.getInstance().setStatContext(context);
}
Also used : MockDriver(com.alibaba.druid.mock.MockDriver) NullExceptionSorter(com.alibaba.druid.pool.vendor.NullExceptionSorter) DruidDataSource(com.alibaba.druid.pool.DruidDataSource) JdbcStatContext(com.alibaba.druid.stat.JdbcStatContext)

Example 2 with NullExceptionSorter

use of com.alibaba.druid.pool.vendor.NullExceptionSorter in project druid by alibaba.

the class TestDataSourceBasic method setUp.

protected void setUp() throws Exception {
    super.setUp();
    driver = new MockDriver();
    dataSource = new DruidDataSource();
    dataSource.setUrl("jdbc:mock:xxx");
    dataSource.setDriver(driver);
    dataSource.setInitialSize(1);
    dataSource.setMaxActive(2);
    dataSource.setMaxIdle(2);
    dataSource.setMinIdle(1);
    // 300 / 10
    dataSource.setMinEvictableIdleTimeMillis(300 * 1000);
    // 180 / 10
    dataSource.setTimeBetweenEvictionRunsMillis(180 * 1000);
    dataSource.setTestWhileIdle(true);
    dataSource.setTestOnBorrow(false);
    dataSource.setValidationQuery("SELECT 1");
    dataSource.setFilters("stat,trace");
    dataSource.setRemoveAbandoned(true);
    dataSource.setExceptionSorterClassName(null);
    Assert.assertTrue(dataSource.getExceptionSorter() instanceof NullExceptionSorter);
    dataSource.setExceptionSorterClassName("");
    Assert.assertTrue(dataSource.getExceptionSorter() instanceof NullExceptionSorter);
}
Also used : MockDriver(com.alibaba.druid.mock.MockDriver) NullExceptionSorter(com.alibaba.druid.pool.vendor.NullExceptionSorter) DruidDataSource(com.alibaba.druid.pool.DruidDataSource)

Aggregations

MockDriver (com.alibaba.druid.mock.MockDriver)2 DruidDataSource (com.alibaba.druid.pool.DruidDataSource)2 NullExceptionSorter (com.alibaba.druid.pool.vendor.NullExceptionSorter)2 JdbcStatContext (com.alibaba.druid.stat.JdbcStatContext)1