use of com.alibaba.druid.mock.MockDriver in project druid by alibaba.
the class Case1 method test_f.
public void test_f() throws Exception {
final DruidDataSource dataSource = new DruidDataSource();
dataSource.setTimeBetweenConnectErrorMillis(100);
final long startTime = System.currentTimeMillis();
final long okTime = startTime + 1000 * 1;
dataSource.setDriver(new MockDriver() {
@Override
public Connection connect(String url, Properties info) throws SQLException {
if (System.currentTimeMillis() < okTime) {
throw new SQLException();
}
return super.connect(url, info);
}
});
dataSource.setUrl("jdbc:mock:");
dataSource.setMinIdle(0);
dataSource.setMaxActive(2);
dataSource.setMaxIdle(2);
Connection conn = dataSource.getConnection();
conn.close();
dataSource.close();
}
use of com.alibaba.druid.mock.MockDriver in project druid by alibaba.
the class ValidationQueryLogDB2Test method setUp.
protected void setUp() throws Exception {
super.setUp();
dataSource = new DruidDataSource();
dataSource.setUrl("jdbc:mock:xxx");
dataSource.setDbType(JdbcConstants.DB2);
dataSource.setDriver(new MockDriver() {
public int getMajorVersion() {
return 10;
}
});
dataSource.setValidationQuery("SELECT 'x'");
}
use of com.alibaba.druid.mock.MockDriver in project druid by alibaba.
the class ValidationQueryLogTest method setUp.
protected void setUp() throws Exception {
super.setUp();
dataSource = new DruidDataSource();
dataSource.setUrl("jdbc:mock:xxx");
dataSource.setDbType(JdbcConstants.ORACLE);
dataSource.setDriver(new MockDriver() {
public int getMajorVersion() {
return 10;
}
});
dataSource.setValidationQuery("SELECT 'x'");
}
use of com.alibaba.druid.mock.MockDriver in project druid by alibaba.
the class TestCommit 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");
dataSource.setRemoveAbandoned(true);
}
use of com.alibaba.druid.mock.MockDriver in project druid by alibaba.
the class DruidDataSourceC3P0AdapterTest method setUp.
protected void setUp() throws Exception {
super.setUp();
Assert.assertEquals(0, DruidDataSourceStatManager.getInstance().getDataSourceList().size());
driver = new MockDriver();
dataSource = new DruidDataSourceC3P0Adapter();
dataSource.setJdbcUrl("jdbc:mock:xxx");
dataSource.setDriver(driver);
dataSource.setInitialPoolSize(1);
dataSource.setMaxPoolSize(2);
dataSource.setMinPoolSize(1);
// 300 / 10
dataSource.setMaxIdleTime(300);
// 180 / 10
dataSource.setIdleConnectionTestPeriod(180);
dataSource.setTestConnectionOnCheckout(false);
dataSource.setPreferredTestQuery("SELECT 1");
dataSource.setFilters("stat");
}
Aggregations