Search in sources :

Example 6 with ResultSetProxy

use of com.alibaba.druid.proxy.jdbc.ResultSetProxy 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();
}
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) DruidDataSource(com.alibaba.druid.pool.DruidDataSource) ResultSetProxy(com.alibaba.druid.proxy.jdbc.ResultSetProxy)

Example 7 with ResultSetProxy

use of com.alibaba.druid.proxy.jdbc.ResultSetProxy in project druid by alibaba.

the class FilterChainTest_ResultSet method test_resultSet_getObject.

public void test_resultSet_getObject() throws Exception {
    FilterChainImpl chain = new FilterChainImpl(dataSource);
    ResultSet clob = (ResultSet) chain.resultSet_getObject(new ResultSetProxyImpl(statement, mockResultSet, 1, null), 1);
    Assert.assertTrue(clob instanceof ResultSetProxy);
    Assert.assertEquals(1, invokeCount);
}
Also used : FilterChainImpl(com.alibaba.druid.filter.FilterChainImpl) MockResultSet(com.alibaba.druid.mock.MockResultSet) ResultSet(java.sql.ResultSet) ResultSetProxy(com.alibaba.druid.proxy.jdbc.ResultSetProxy) ResultSetProxyImpl(com.alibaba.druid.proxy.jdbc.ResultSetProxyImpl)

Example 8 with ResultSetProxy

use of com.alibaba.druid.proxy.jdbc.ResultSetProxy in project druid by alibaba.

the class FilterChainTest_ResultSet method test_resultSet_getObject_1.

public void test_resultSet_getObject_1() throws Exception {
    FilterChainImpl chain = new FilterChainImpl(dataSource);
    ResultSet clob = (ResultSet) chain.resultSet_getObject(new ResultSetProxyImpl(statement, mockResultSet, 1, null), "1");
    Assert.assertTrue(clob instanceof ResultSetProxy);
    Assert.assertEquals(1, invokeCount);
}
Also used : FilterChainImpl(com.alibaba.druid.filter.FilterChainImpl) MockResultSet(com.alibaba.druid.mock.MockResultSet) ResultSet(java.sql.ResultSet) ResultSetProxy(com.alibaba.druid.proxy.jdbc.ResultSetProxy) ResultSetProxyImpl(com.alibaba.druid.proxy.jdbc.ResultSetProxyImpl)

Example 9 with ResultSetProxy

use of com.alibaba.druid.proxy.jdbc.ResultSetProxy in project druid by alibaba.

the class FilterChainTest_ResultSet_2 method test_getObject_1.

public void test_getObject_1() throws Exception {
    FilterChainImpl chain = new FilterChainImpl(dataSource);
    ResultSet clob = (ResultSet) chain.callableStatement_getObject(statement, "1");
    Assert.assertTrue(clob instanceof ResultSetProxy);
    Assert.assertEquals(1, invokeCount);
}
Also used : FilterChainImpl(com.alibaba.druid.filter.FilterChainImpl) MockResultSet(com.alibaba.druid.mock.MockResultSet) ResultSet(java.sql.ResultSet) ResultSetProxy(com.alibaba.druid.proxy.jdbc.ResultSetProxy)

Example 10 with ResultSetProxy

use of com.alibaba.druid.proxy.jdbc.ResultSetProxy in project druid by alibaba.

the class FilterChainTest_ResultSet_2 method test_getObject_3.

public void test_getObject_3() throws Exception {
    FilterChainImpl chain = new FilterChainImpl(dataSource);
    ResultSet clob = (ResultSet) chain.callableStatement_getObject(statement, "1", Collections.<String, Class<?>>emptyMap());
    Assert.assertTrue(clob instanceof ResultSetProxy);
    Assert.assertEquals(1, invokeCount);
}
Also used : FilterChainImpl(com.alibaba.druid.filter.FilterChainImpl) MockResultSet(com.alibaba.druid.mock.MockResultSet) ResultSet(java.sql.ResultSet) ResultSetProxy(com.alibaba.druid.proxy.jdbc.ResultSetProxy)

Aggregations

ResultSetProxy (com.alibaba.druid.proxy.jdbc.ResultSetProxy)29 SQLException (java.sql.SQLException)17 FilterChain (com.alibaba.druid.filter.FilterChain)13 DruidDataSource (com.alibaba.druid.pool.DruidDataSource)13 FilterAdapter (com.alibaba.druid.filter.FilterAdapter)12 FilterChainImpl (com.alibaba.druid.filter.FilterChainImpl)9 MockResultSet (com.alibaba.druid.mock.MockResultSet)9 ResultSet (java.sql.ResultSet)8 ResultSetProxyImpl (com.alibaba.druid.proxy.jdbc.ResultSetProxyImpl)6 StatementProxy (com.alibaba.druid.proxy.jdbc.StatementProxy)4 DataSourceProxyConfig (com.alibaba.druid.proxy.jdbc.DataSourceProxyConfig)3 DataSourceProxyImpl (com.alibaba.druid.proxy.jdbc.DataSourceProxyImpl)3 PreparedStatementProxy (com.alibaba.druid.proxy.jdbc.PreparedStatementProxy)3 StatFilter (com.alibaba.druid.filter.stat.StatFilter)2 MockBlob (com.alibaba.druid.mock.MockBlob)2 MockClob (com.alibaba.druid.mock.MockClob)2 MockDriver (com.alibaba.druid.mock.MockDriver)2 ClobProxyImpl (com.alibaba.druid.proxy.jdbc.ClobProxyImpl)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 Connection (java.sql.Connection)2