use of com.alibaba.druid.filter.FilterAdapter in project druid by alibaba.
the class StatFilterOpenBlobCountTest2 method setUp.
protected void setUp() throws Exception {
dataSource = new DruidDataSource();
dataSource.setUrl("jdbc:mock:xxx");
dataSource.setFilters("stat");
dataSource.setTestOnBorrow(false);
dataSource.getProxyFilters().add(new FilterAdapter() {
@Override
public Object resultSet_getObject(FilterChain chain, ResultSetProxy result, int columnIndex) throws SQLException {
return new MockBlob();
}
@Override
public Object resultSet_getObject(FilterChain chain, ResultSetProxy result, String columnLabel) throws SQLException {
return new MockBlob();
}
@Override
public Object resultSet_getObject(FilterChain chain, ResultSetProxy result, int columnIndex, java.util.Map<String, Class<?>> map) throws SQLException {
return new MockBlob();
}
@Override
public Object resultSet_getObject(FilterChain chain, ResultSetProxy result, String columnIndex, java.util.Map<String, Class<?>> map) throws SQLException {
return new MockBlob();
}
});
dataSource.init();
}
use of com.alibaba.druid.filter.FilterAdapter in project druid by alibaba.
the class StatFilterOpenClobCountTest2 method setUp.
protected void setUp() throws Exception {
dataSource = new DruidDataSource();
dataSource.setUrl("jdbc:mock:xxx");
dataSource.setFilters("stat");
dataSource.setTestOnBorrow(false);
dataSource.getProxyFilters().add(new FilterAdapter() {
@Override
public Object resultSet_getObject(FilterChain chain, ResultSetProxy result, int columnIndex) throws SQLException {
return new ClobProxyImpl(result.getStatementProxy().getConnectionProxy().getDirectDataSource(), result.getStatementProxy().getConnectionProxy(), new MockClob());
}
@Override
public Object resultSet_getObject(FilterChain chain, ResultSetProxy result, String columnLabel) throws SQLException {
return new ClobProxyImpl(result.getStatementProxy().getConnectionProxy().getDirectDataSource(), result.getStatementProxy().getConnectionProxy(), new MockClob());
}
@Override
public Object resultSet_getObject(FilterChain chain, ResultSetProxy result, int columnIndex, java.util.Map<String, Class<?>> map) throws SQLException {
return new ClobProxyImpl(result.getStatementProxy().getConnectionProxy().getDirectDataSource(), result.getStatementProxy().getConnectionProxy(), new MockClob());
}
@Override
public Object resultSet_getObject(FilterChain chain, ResultSetProxy result, String columnIndex, java.util.Map<String, Class<?>> map) throws SQLException {
return new ClobProxyImpl(result.getStatementProxy().getConnectionProxy().getDirectDataSource(), result.getStatementProxy().getConnectionProxy(), new MockClob());
}
});
dataSource.init();
}
use of com.alibaba.druid.filter.FilterAdapter in project druid by alibaba.
the class StatFilterOpenBlobCountTest method setUp.
protected void setUp() throws Exception {
dataSource = new DruidDataSource();
dataSource.setUrl("jdbc:mock:xxx");
dataSource.setFilters("stat");
dataSource.setTestOnBorrow(false);
dataSource.getProxyFilters().add(new FilterAdapter() {
@Override
public Blob resultSet_getBlob(FilterChain chain, ResultSetProxy result, int columnIndex) throws SQLException {
return new MockBlob();
}
@Override
public Blob resultSet_getBlob(FilterChain chain, ResultSetProxy result, String columnLabel) throws SQLException {
return new MockBlob();
}
});
dataSource.init();
}
use of com.alibaba.druid.filter.FilterAdapter in project druid by alibaba.
the class DruidDataSourceTest6 method setUp.
protected void setUp() throws Exception {
returnEmptyCount.set(0);
dataSource = new DruidDataSource();
dataSource.setUrl("jdbc:mock:xxx");
dataSource.setTestOnBorrow(true);
dataSource.setInitialSize(1);
dataSource.setValidationQuery("select 1");
dataSource.setValidationQueryTimeout(10);
dataSource.setQueryTimeout(100);
dataSource.setUserCallback(new NameCallback("xx") {
});
dataSource.setPasswordCallback(new DruidPasswordCallback() {
@Override
public char[] getPassword() {
return "xx".toCharArray();
}
});
dataSource.getProxyFilters().add(new FilterAdapter() {
public ResultSetProxy statement_executeQuery(FilterChain chain, StatementProxy statement, String sql) throws SQLException {
if (errorCount.get() > 0) {
errorCount.decrementAndGet();
throw new RuntimeException();
}
if (returnEmptyCount.get() > 0) {
returnEmptyCount.decrementAndGet();
return new ResultSetProxyImpl(statement, new MockResultSet(statement), 0, sql);
}
return chain.statement_executeQuery(statement, sql);
}
});
}
use of com.alibaba.druid.filter.FilterAdapter in project druid by alibaba.
the class DruidDataSourceTest_closeError method setUp.
protected void setUp() throws Exception {
dataSource = new DruidDataSource();
dataSource.setUrl("jdbc:mock:xxx");
dataSource.setTestOnBorrow(false);
dataSource.setInitialSize(1);
dataSource.getProxyFilters().add(new FilterAdapter() {
public void connection_close(FilterChain chain, ConnectionProxy connection) throws SQLException {
throw new SQLException();
}
});
dataSource.init();
}
Aggregations