use of com.alibaba.druid.mock.MockStatementBase in project druid by alibaba.
the class DiscardTest method setUp.
protected void setUp() throws Exception {
driver = new MockDriver() {
public ResultSet executeQuery(MockStatementBase stmt, String sql) throws SQLException {
if (failed) {
throw new SQLException("", "", 1040);
}
return super.executeQuery(stmt, sql);
}
public Connection connect(String url, Properties info) throws SQLException {
while (failed) {
try {
Thread.sleep(1);
} catch (InterruptedException e) {
throw new SQLException(e.getMessage(), e);
}
}
return super.connect(url, info);
}
};
dataSource = new DruidDataSource();
dataSource.setUrl("jdbc:mock:xxx");
dataSource.setTestOnBorrow(false);
dataSource.setDriver(driver);
dataSource.setDbType("mysql");
dataSource.setMinIdle(1);
dataSource.setMaxActive(1);
dataSource.setFilters("log4j");
dataSource.setExceptionSorter(new MySqlExceptionSorter());
}
use of com.alibaba.druid.mock.MockStatementBase in project druid by alibaba.
the class EncodingConvertFilterTest2 method setUp.
protected void setUp() throws Exception {
dataSource = new DruidDataSource();
dataSource.setUrl("jdbc:mock:xxx");
dataSource.setFilters("encoding");
dataSource.setDriver(new MockDriver() {
public ResultSet createResultSet(MockPreparedStatement stmt) {
return new MyResultSet(stmt);
}
public ResultSet executeQuery(MockStatementBase stmt, String sql) throws SQLException {
return new MyResultSet(stmt);
}
});
dataSource.getConnectProperties().put("clientEncoding", CLIENT_ENCODING);
dataSource.getConnectProperties().put("serverEncoding", SERVER_ENCODING);
dataSource.init();
}
use of com.alibaba.druid.mock.MockStatementBase 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.MockStatementBase in project druid by alibaba.
the class EncodingConvertFilterTest method setUp.
protected void setUp() throws Exception {
dataSource = new DruidDataSource();
dataSource.setUrl("jdbc:mock:xxx");
dataSource.setFilters("encoding");
dataSource.setDriver(new MockDriver() {
public ResultSet createResultSet(MockPreparedStatement stmt) {
return new MyResultSet(stmt);
}
public ResultSet executeQuery(MockStatementBase stmt, String sql) throws SQLException {
return new MyResultSet(stmt);
}
});
dataSource.getConnectProperties().put("clientEncoding", CLIENT_ENCODING);
dataSource.getConnectProperties().put("serverEncoding", SERVER_ENCODING);
dataSource.init();
}
use of com.alibaba.druid.mock.MockStatementBase in project druid by alibaba.
the class FilterChainImplTest3 method setUp.
protected void setUp() throws Exception {
dataSource = new DruidDataSource();
dataSource.setUrl("jdbc:mock:xxx");
dataSource.setFilters("stat,log4j,wall,encoding");
dataSource.getProxyFilters().add(new FilterAdapter() {
});
dataSource.setDbType("mysql");
dataSource.setDriver(new MockDriver() {
public ResultSet executeQuery(MockStatementBase stmt, String sql) throws SQLException {
return null;
}
public MockStatement createMockStatement(MockConnection conn) {
return new MockStatement(conn) {
public ResultSet getResultSet() throws SQLException {
return null;
}
};
}
});
dataSource.init();
}
Aggregations