Search in sources :

Example 26 with FilterChain

use of com.alibaba.druid.filter.FilterChain 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();
}
Also used : ClobProxyImpl(com.alibaba.druid.proxy.jdbc.ClobProxyImpl) SQLException(java.sql.SQLException) FilterChain(com.alibaba.druid.filter.FilterChain) MockClob(com.alibaba.druid.mock.MockClob) FilterAdapter(com.alibaba.druid.filter.FilterAdapter) ResultSetProxy(com.alibaba.druid.proxy.jdbc.ResultSetProxy) MockClob(com.alibaba.druid.mock.MockClob) Clob(java.sql.Clob) DruidDataSource(com.alibaba.druid.pool.DruidDataSource)

Example 27 with FilterChain

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

the class StatFilterOpenInputStreamCountTest 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 java.io.InputStream resultSet_getBinaryStream(FilterChain chain, ResultSetProxy result, int columnIndex) throws SQLException {
            return new ByteArrayInputStream(new byte[0]);
        }

        @Override
        public java.io.InputStream resultSet_getBinaryStream(FilterChain chain, ResultSetProxy result, String columnLabel) throws SQLException {
            return new ByteArrayInputStream(new byte[0]);
        }
    });
    dataSource.init();
}
Also used : SQLException(java.sql.SQLException) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) 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 FilterChain

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

the class StatFilterOpenInputStreamCountTest2 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 java.io.InputStream resultSet_getAsciiStream(FilterChain chain, ResultSetProxy result, int columnIndex) throws SQLException {
            return new ByteArrayInputStream(new byte[0]);
        }

        @Override
        public java.io.InputStream resultSet_getAsciiStream(FilterChain chain, ResultSetProxy result, String columnLabel) throws SQLException {
            return new ByteArrayInputStream(new byte[0]);
        }
    });
    dataSource.init();
}
Also used : SQLException(java.sql.SQLException) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) 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 29 with FilterChain

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

the class StatFilterOpenReaderCountTest 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 java.io.Reader resultSet_getCharacterStream(FilterChain chain, ResultSetProxy result, int columnIndex) throws SQLException {
            return new StringReader("");
        }

        @Override
        public java.io.Reader resultSet_getCharacterStream(FilterChain chain, ResultSetProxy result, String columnLabel) throws SQLException {
            return new StringReader("");
        }
    });
    dataSource.init();
}
Also used : SQLException(java.sql.SQLException) FilterChain(com.alibaba.druid.filter.FilterChain) StringReader(org.nutz.lang.stream.StringReader) FilterAdapter(com.alibaba.druid.filter.FilterAdapter) StringReader(org.nutz.lang.stream.StringReader) ResultSetProxy(com.alibaba.druid.proxy.jdbc.ResultSetProxy) DruidDataSource(com.alibaba.druid.pool.DruidDataSource)

Example 30 with FilterChain

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

the class StatFilterReadBytesLengthTest 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 byte[] resultSet_getBytes(FilterChain chain, ResultSetProxy result, int columnIndex) throws SQLException {
            return new byte[6];
        }

        @Override
        public byte[] resultSet_getBytes(FilterChain chain, ResultSetProxy result, String columnIndex) throws SQLException {
            return new byte[7];
        }
    });
    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)

Aggregations

FilterChain (com.alibaba.druid.filter.FilterChain)36 DruidDataSource (com.alibaba.druid.pool.DruidDataSource)33 SQLException (java.sql.SQLException)33 FilterAdapter (com.alibaba.druid.filter.FilterAdapter)32 ConnectionProxy (com.alibaba.druid.proxy.jdbc.ConnectionProxy)18 ResultSetProxy (com.alibaba.druid.proxy.jdbc.ResultSetProxy)13 Properties (java.util.Properties)12 StatementProxy (com.alibaba.druid.proxy.jdbc.StatementProxy)6 PreparedStatementProxy (com.alibaba.druid.proxy.jdbc.PreparedStatementProxy)4 FilterChainImpl (com.alibaba.druid.filter.FilterChainImpl)3 DataSourceProxyImpl (com.alibaba.druid.proxy.jdbc.DataSourceProxyImpl)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 ConnectionProxyImpl (com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl)2 DataSourceProxyConfig (com.alibaba.druid.proxy.jdbc.DataSourceProxyConfig)2 ResultSetProxyImpl (com.alibaba.druid.proxy.jdbc.ResultSetProxyImpl)2 Log (com.alibaba.druid.support.logging.Log)2 Log4jImpl (com.alibaba.druid.support.logging.Log4jImpl)2