use of com.alibaba.druid.filter.FilterAdapter in project druid by alibaba.
the class DruidDataSourceTest_lastCreateError method setUp.
protected void setUp() throws Exception {
dataSource = new DruidDataSource();
dataSource.setUrl("jdbc:mock:xxx");
dataSource.setTestOnBorrow(false);
dataSource.getProxyFilters().add(new FilterAdapter() {
public ConnectionProxy connection_connect(FilterChain chain, Properties info) throws SQLException {
throw new SQLException();
}
});
}
use of com.alibaba.druid.filter.FilterAdapter in project druid by alibaba.
the class DruidDataSourceTest_autocommit3 method setUp.
protected void setUp() throws Exception {
dataSource = new DruidDataSource();
dataSource.setUrl("jdbc:mock:xxx");
dataSource.setTestOnBorrow(false);
dataSource.setDefaultAutoCommit(false);
dataSource.setInitialSize(1);
dataSource.getProxyFilters().add(new FilterAdapter() {
public ConnectionProxy connection_connect(FilterChain chain, Properties info) throws SQLException {
ConnectionProxy conn = chain.connection_connect(info);
conn.setAutoCommit(false);
return conn;
}
});
}
use of com.alibaba.druid.filter.FilterAdapter in project druid by alibaba.
the class AsyncCloseTest3 method setUp.
protected void setUp() throws Exception {
// m;
xmx = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getMax() / (1000 * 1000);
System.gc();
Field logField = DruidDataSource.class.getDeclaredField("LOG");
logField.setAccessible(true);
Log dataSourceLog = (Log) logField.get(null);
if (dataSourceLog instanceof Log4jImpl) {
this.log4jLog = ((Log4jImpl) dataSourceLog).getLog();
this.log4jOldLevel = this.log4jLog.getLevel();
this.log4jLog.setLevel(Level.FATAL);
} else if (dataSourceLog instanceof NoLoggingImpl) {
noLoggingImpl = (NoLoggingImpl) dataSourceLog;
noLoggingImpl.setErrorEnabled(false);
}
dataSource = new DruidDataSource();
dataSource.setUrl("jdbc:mock:");
// dataSource.setAsyncCloseConnectionEnable(true);
dataSource.setTestOnBorrow(false);
dataSource.setMaxActive(16);
dataSource.getProxyFilters().add(new FilterAdapter() {
@Override
public boolean statement_execute(FilterChain chain, StatementProxy statement, String sql) throws SQLException {
throw new SQLException();
}
});
dataSource.setExceptionSorter(new MyExceptionSorter());
dataSource.init();
connExecutor = Executors.newFixedThreadPool(2);
closeExecutor = Executors.newFixedThreadPool(2);
}
use of com.alibaba.druid.filter.FilterAdapter in project druid by alibaba.
the class AsyncCloseTest2 method setUp.
protected void setUp() throws Exception {
Field logField = DruidDataSource.class.getDeclaredField("LOG");
logField.setAccessible(true);
Log dataSourceLog = (Log) logField.get(null);
if (dataSourceLog instanceof Log4jImpl) {
this.log4jLog = ((Log4jImpl) dataSourceLog).getLog();
this.log4jOldLevel = this.log4jLog.getLevel();
this.log4jLog.setLevel(Level.FATAL);
} else if (dataSourceLog instanceof NoLoggingImpl) {
noLoggingImpl = (NoLoggingImpl) dataSourceLog;
noLoggingImpl.setErrorEnabled(false);
}
dataSource = new DruidDataSource();
dataSource.setUrl("jdbc:mock:");
dataSource.setAsyncCloseConnectionEnable(true);
dataSource.setTestOnBorrow(false);
dataSource.setMaxActive(16);
dataSource.getProxyFilters().add(new FilterAdapter() {
@Override
public boolean statement_execute(FilterChain chain, StatementProxy statement, String sql) throws SQLException {
throw new SQLException();
}
});
dataSource.setExceptionSorter(new MyExceptionSorter());
dataSource.init();
connExecutor = Executors.newFixedThreadPool(128);
closeExecutor = Executors.newFixedThreadPool(128);
}
use of com.alibaba.druid.filter.FilterAdapter in project druid by alibaba.
the class StatFilterOpenClobCountTest 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 Clob resultSet_getClob(FilterChain chain, ResultSetProxy result, int columnIndex) throws SQLException {
return new ClobProxyImpl(result.getStatementProxy().getConnectionProxy().getDirectDataSource(), result.getStatementProxy().getConnectionProxy(), new MockClob());
}
@Override
public Clob resultSet_getClob(FilterChain chain, ResultSetProxy result, String columnLabel) throws SQLException {
return new ClobProxyImpl(result.getStatementProxy().getConnectionProxy().getDirectDataSource(), result.getStatementProxy().getConnectionProxy(), new MockClob());
}
});
dataSource.init();
}
Aggregations