Search in sources :

Example 6 with ResultSetProxyImpl

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

the class FilterChainTest_Clob method test_resultSet_getObject.

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

Example 7 with ResultSetProxyImpl

use of com.alibaba.druid.proxy.jdbc.ResultSetProxyImpl 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 ResultSetProxyImpl

use of com.alibaba.druid.proxy.jdbc.ResultSetProxyImpl 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 ResultSetProxyImpl

use of com.alibaba.druid.proxy.jdbc.ResultSetProxyImpl 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);
        }
    });
}
Also used : SQLException(java.sql.SQLException) FilterChain(com.alibaba.druid.filter.FilterChain) FilterAdapter(com.alibaba.druid.filter.FilterAdapter) MockResultSet(com.alibaba.druid.mock.MockResultSet) ResultSetProxyImpl(com.alibaba.druid.proxy.jdbc.ResultSetProxyImpl) DruidDataSource(com.alibaba.druid.pool.DruidDataSource) NameCallback(javax.security.auth.callback.NameCallback) StatementProxy(com.alibaba.druid.proxy.jdbc.StatementProxy) DruidPasswordCallback(com.alibaba.druid.util.DruidPasswordCallback) ResultSetProxy(com.alibaba.druid.proxy.jdbc.ResultSetProxy)

Example 10 with ResultSetProxyImpl

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

the class FilterChainTest_Clob method test_resultSet_getObject_2.

public void test_resultSet_getObject_2() throws Exception {
    FilterChainImpl chain = new FilterChainImpl(dataSource);
    Clob clob = (Clob) chain.resultSet_getObject(new ResultSetProxyImpl(statement, mockResultSet, 1, null), 1, Collections.<String, Class<?>>emptyMap());
    Assert.assertTrue(clob instanceof ClobProxy);
    Assert.assertEquals(1, invokeCount);
}
Also used : FilterChainImpl(com.alibaba.druid.filter.FilterChainImpl) ClobProxy(com.alibaba.druid.proxy.jdbc.ClobProxy) MockClob(com.alibaba.druid.mock.MockClob) Clob(java.sql.Clob) ResultSetProxyImpl(com.alibaba.druid.proxy.jdbc.ResultSetProxyImpl)

Aggregations

ResultSetProxyImpl (com.alibaba.druid.proxy.jdbc.ResultSetProxyImpl)19 FilterChainImpl (com.alibaba.druid.filter.FilterChainImpl)18 Clob (java.sql.Clob)12 MockClob (com.alibaba.druid.mock.MockClob)6 MockNClob (com.alibaba.druid.mock.MockNClob)6 MockResultSet (com.alibaba.druid.mock.MockResultSet)6 ClobProxy (com.alibaba.druid.proxy.jdbc.ClobProxy)6 NClobProxy (com.alibaba.druid.proxy.jdbc.NClobProxy)6 ResultSetProxy (com.alibaba.druid.proxy.jdbc.ResultSetProxy)6 ResultSet (java.sql.ResultSet)4 StatementProxy (com.alibaba.druid.proxy.jdbc.StatementProxy)3 SQLException (java.sql.SQLException)3 FilterChain (com.alibaba.druid.filter.FilterChain)2 DruidDataSource (com.alibaba.druid.pool.DruidDataSource)2 ConnectionProxy (com.alibaba.druid.proxy.jdbc.ConnectionProxy)2 DataSourceProxyConfig (com.alibaba.druid.proxy.jdbc.DataSourceProxyConfig)2 DataSourceProxyImpl (com.alibaba.druid.proxy.jdbc.DataSourceProxyImpl)2 Properties (java.util.Properties)2 FilterAdapter (com.alibaba.druid.filter.FilterAdapter)1 FilterEventAdapter (com.alibaba.druid.filter.FilterEventAdapter)1