Search in sources :

Example 26 with MockDriver

use of com.alibaba.druid.mock.MockDriver in project druid by alibaba.

the class TestConcurrent method setUp.

protected void setUp() throws Exception {
    DruidDataSourceStatManager.clear();
    driver = new MockDriver();
    driver.setLogExecuteQueryEnable(false);
    dataSource = new DruidDataSource();
    dataSource.setUrl("jdbc:mock:xxx");
    dataSource.setDriver(driver);
    dataSource.setInitialSize(1);
    dataSource.setMaxActive(100);
    dataSource.setMaxIdle(100);
    dataSource.setMinIdle(1);
    dataSource.setMinEvictableIdleTimeMillis(10 * 1000);
    dataSource.setTimeBetweenEvictionRunsMillis(1 * 10);
    dataSource.setTestWhileIdle(true);
    dataSource.setTestOnBorrow(false);
    dataSource.setValidationQuery("SELECT 1");
    dataSource.setFilters("stat");
    Assert.assertEquals(0, dataSource.getActiveCount());
    Assert.assertEquals(0, dataSource.getPoolingCount());
    Assert.assertEquals(true, dataSource.isEnable());
}
Also used : MockDriver(com.alibaba.druid.mock.MockDriver) DruidDataSource(com.alibaba.druid.pool.DruidDataSource)

Example 27 with MockDriver

use of com.alibaba.druid.mock.MockDriver in project druid by alibaba.

the class TestIdle3_Concurrent_MaxActive 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(14);
    dataSource.setMaxIdle(14);
    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");
}
Also used : MockDriver(com.alibaba.druid.mock.MockDriver) DruidDataSource(com.alibaba.druid.pool.DruidDataSource)

Example 28 with MockDriver

use of com.alibaba.druid.mock.MockDriver in project druid by alibaba.

the class TestIdle3_Concurrent_Starvation 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(100);
    dataSource.setMaxIdle(100);
    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");
}
Also used : MockDriver(com.alibaba.druid.mock.MockDriver) DruidDataSource(com.alibaba.druid.pool.DruidDataSource)

Example 29 with MockDriver

use of com.alibaba.druid.mock.MockDriver in project druid by alibaba.

the class StatFilterExecuteFirstResultSetTest method setUp.

protected void setUp() throws Exception {
    dataSource = new DruidDataSource();
    dataSource.setUrl("jdbc:mock:xxx");
    dataSource.setFilters("stat");
    dataSource.setTestOnBorrow(false);
    MockDriver driver = new MockDriver() {

        public MockPreparedStatement createMockPreparedStatement(MockConnection conn, String sql) {
            return new MyMockPreparedStatement(conn, sql);
        }
    };
    dataSource.setDriver(driver);
    dataSource.init();
}
Also used : MockDriver(com.alibaba.druid.mock.MockDriver) DruidDataSource(com.alibaba.druid.pool.DruidDataSource) MockConnection(com.alibaba.druid.mock.MockConnection)

Example 30 with MockDriver

use of com.alibaba.druid.mock.MockDriver in project druid by alibaba.

the class DruidDataSourceTest_oracle method setUp.

protected void setUp() throws Exception {
    dataSource = new DruidDataSource();
    dataSource.setUrl("jdbc:mock:xxx");
    dataSource.setTestOnBorrow(false);
    dataSource.setFilters("stat");
    dataSource.setDbType("oracle");
    dataSource.setDriver(new MockDriver() {

        @Override
        public int getMajorVersion() {
            return 11;
        }
    });
}
Also used : MockDriver(com.alibaba.druid.mock.MockDriver) DruidDataSource(com.alibaba.druid.pool.DruidDataSource)

Aggregations

MockDriver (com.alibaba.druid.mock.MockDriver)60 DruidDataSource (com.alibaba.druid.pool.DruidDataSource)49 Connection (java.sql.Connection)17 SQLException (java.sql.SQLException)13 ResultSet (java.sql.ResultSet)10 Properties (java.util.Properties)9 MockConnection (com.alibaba.druid.mock.MockConnection)8 MockStatementBase (com.alibaba.druid.mock.MockStatementBase)7 MockPreparedStatement (com.alibaba.druid.mock.MockPreparedStatement)5 DataSourceProxyConfig (com.alibaba.druid.proxy.jdbc.DataSourceProxyConfig)5 DataSourceProxyImpl (com.alibaba.druid.proxy.jdbc.DataSourceProxyImpl)5 JdbcStatContext (com.alibaba.druid.stat.JdbcStatContext)5 Log4jFilter (com.alibaba.druid.filter.logging.Log4jFilter)4 CommonsLogFilter (com.alibaba.druid.filter.logging.CommonsLogFilter)3 MockResultSet (com.alibaba.druid.mock.MockResultSet)3 MockStatement (com.alibaba.druid.mock.MockStatement)3 Statement (java.sql.Statement)3 ObjectName (javax.management.ObjectName)3 StatFilter (com.alibaba.druid.filter.stat.StatFilter)2 DruidPooledConnection (com.alibaba.druid.pool.DruidPooledConnection)2