Search in sources :

Example 26 with FilterAdapter

use of com.alibaba.druid.filter.FilterAdapter 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();
}
Also used : MockDriver(com.alibaba.druid.mock.MockDriver) SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) FilterAdapter(com.alibaba.druid.filter.FilterAdapter) MockStatement(com.alibaba.druid.mock.MockStatement) DruidDataSource(com.alibaba.druid.pool.DruidDataSource) MockConnection(com.alibaba.druid.mock.MockConnection) MockStatementBase(com.alibaba.druid.mock.MockStatementBase)

Example 27 with FilterAdapter

use of com.alibaba.druid.filter.FilterAdapter in project druid by alibaba.

the class StatFilterReadStringLengthTest 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 String resultSet_getString(FilterChain chain, ResultSetProxy result, int columnIndex) throws SQLException {
            return "123456";
        }

        @Override
        public String resultSet_getString(FilterChain chain, ResultSetProxy result, String columnIndex) throws SQLException {
            return "1234567";
        }
    });
    dataSource.init();
}
Also used : SQLException(java.sql.SQLException) FilterChain(com.alibaba.druid.filter.FilterChain) FilterAdapter(com.alibaba.druid.filter.FilterAdapter) ResultSetProxy(com.alibaba.druid.proxy.jdbc.ResultSetProxy) DruidDataSource(com.alibaba.druid.pool.DruidDataSource)

Example 28 with FilterAdapter

use of com.alibaba.druid.filter.FilterAdapter in project druid by alibaba.

the class FilterChainImplTest2 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.init();
}
Also used : FilterAdapter(com.alibaba.druid.filter.FilterAdapter) DruidDataSource(com.alibaba.druid.pool.DruidDataSource)

Example 29 with FilterAdapter

use of com.alibaba.druid.filter.FilterAdapter in project druid by alibaba.

the class DruidDataSourceTest8 method setUp.

protected void setUp() throws Exception {
    dataSource = new DruidDataSource();
    dataSource.setUrl("jdbc:mock:xxx");
    dataSource.setInitialSize(1);
    dataSource.getProxyFilters().add(new FilterAdapter() {

        @Override
        public ConnectionProxy connection_connect(FilterChain chain, Properties info) throws SQLException {
            throw new Error();
        }
    });
}
Also used : SQLException(java.sql.SQLException) FilterChain(com.alibaba.druid.filter.FilterChain) FilterAdapter(com.alibaba.druid.filter.FilterAdapter) Properties(java.util.Properties) DruidDataSource(com.alibaba.druid.pool.DruidDataSource) ConnectionProxy(com.alibaba.druid.proxy.jdbc.ConnectionProxy)

Example 30 with FilterAdapter

use of com.alibaba.druid.filter.FilterAdapter in project druid by alibaba.

the class DruidConnectionHolderTest2 method setUp.

protected void setUp() throws Exception {
    super.setUp();
    dataSource = new DruidDataSource();
    dataSource.setUrl("jdbc:mock:xxx");
    dataSource.setTestOnBorrow(false);
    dataSource.setPoolPreparedStatements(true);
    dataSource.getProxyFilters().add(new FilterAdapter() {

        public int connection_getTransactionIsolation(FilterChain chain, ConnectionProxy connection) throws SQLException {
            throw new SQLException();
        }
    });
}
Also used : SQLException(java.sql.SQLException) FilterChain(com.alibaba.druid.filter.FilterChain) FilterAdapter(com.alibaba.druid.filter.FilterAdapter) DruidDataSource(com.alibaba.druid.pool.DruidDataSource) ConnectionProxy(com.alibaba.druid.proxy.jdbc.ConnectionProxy)

Aggregations

FilterAdapter (com.alibaba.druid.filter.FilterAdapter)35 DruidDataSource (com.alibaba.druid.pool.DruidDataSource)35 FilterChain (com.alibaba.druid.filter.FilterChain)32 SQLException (java.sql.SQLException)32 ConnectionProxy (com.alibaba.druid.proxy.jdbc.ConnectionProxy)17 ResultSetProxy (com.alibaba.druid.proxy.jdbc.ResultSetProxy)12 Properties (java.util.Properties)9 StatementProxy (com.alibaba.druid.proxy.jdbc.StatementProxy)5 PreparedStatementProxy (com.alibaba.druid.proxy.jdbc.PreparedStatementProxy)3 MockBlob (com.alibaba.druid.mock.MockBlob)2 MockClob (com.alibaba.druid.mock.MockClob)2 CallableStatementProxy (com.alibaba.druid.proxy.jdbc.CallableStatementProxy)2 ClobProxyImpl (com.alibaba.druid.proxy.jdbc.ClobProxyImpl)2 Log (com.alibaba.druid.support.logging.Log)2 Log4jImpl (com.alibaba.druid.support.logging.Log4jImpl)2 NoLoggingImpl (com.alibaba.druid.support.logging.NoLoggingImpl)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 Field (java.lang.reflect.Field)2 Filter (com.alibaba.druid.filter.Filter)1 MockConnection (com.alibaba.druid.mock.MockConnection)1