use of com.alibaba.druid.mock.MockDriver in project druid by alibaba.
the class StatFilterBuildSlowParameterTest method setUp.
protected void setUp() throws Exception {
dataSource = new DruidDataSource();
dataSource.setUrl("jdbc:mock:xxx");
dataSource.setFilters("stat");
dataSource.setTestOnBorrow(false);
dataSource.setConnectionProperties("druid.stat.slowSqlMillis=1");
MockDriver driver = new MockDriver() {
public ResultSet executeQuery(MockStatementBase stmt, String sql) throws SQLException {
try {
Thread.sleep(2);
} catch (InterruptedException e) {
e.printStackTrace();
}
return super.executeQuery(stmt, sql);
}
};
dataSource.setDriver(driver);
dataSource.init();
}
use of com.alibaba.druid.mock.MockDriver in project druid by alibaba.
the class StatFilterExecuteTest 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();
}
use of com.alibaba.druid.mock.MockDriver in project druid by alibaba.
the class DruidDataSourceTest_exceptionSorter method setUp.
protected void setUp() throws Exception {
dataSource = new DruidDataSource();
dataSource.setUrl("jdbc:mock:xxx");
dataSource.setTestOnBorrow(false);
dataSource.setRemoveAbandoned(true);
dataSource.setDriver(new MockDriver() {
public ResultSet executeQuery(MockStatementBase stmt, String sql) throws SQLException {
throw new SQLException();
}
});
dataSource.setExceptionSorter(new ExceptionSorter() {
@Override
public boolean isExceptionFatal(SQLException e) {
return true;
}
@Override
public void configFromProperties(Properties properties) {
}
});
}
use of com.alibaba.druid.mock.MockDriver in project druid by alibaba.
the class DruidDataSourceTest_getPooledConnection method setUp.
protected void setUp() throws Exception {
dataSource = new DruidDataSource();
dataSource.setUrl("jdbc:mock:xxx");
dataSource.setTestOnBorrow(false);
dataSource.setRemoveAbandoned(true);
dataSource.setDriver(new MockDriver() {
public ResultSet executeQuery(MockStatementBase stmt, String sql) throws SQLException {
throw new SQLException();
}
});
}
use of com.alibaba.druid.mock.MockDriver in project druid by alibaba.
the class DruidDataSourceTest_oracle2 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.setPoolPreparedStatements(true);
dataSource.setDriver(new MockDriver() {
@Override
public int getMajorVersion() {
return 10;
}
});
}
Aggregations