Search in sources :

Example 1 with FilterEventAdapter

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

the class CallableStatementProxyImplTest method test_call.

public void test_call() throws Exception {
    DataSourceProxyConfig config = new DataSourceProxyConfig();
    DataSourceProxy dataSource = new DataSourceProxyImpl(null, config);
    FilterEventAdapter filter = new FilterEventAdapter() {
    };
    filter.init(dataSource);
    config.getFilters().add(filter);
    String sql = "CALL P_0(?, ?)";
    CallableStatementProxyImpl rawCallStatement = new FakeCallableStatement(new ConnectionProxyImpl(null, null, null, 0), null, sql, 1001);
    ConnectionProxy connection = new ConnectionProxyImpl(dataSource, null, new Properties(), 1001);
    CallableStatementProxyImpl cstmt = new CallableStatementProxyImpl(connection, rawCallStatement, sql, 2001);
    cstmt.registerOutParameter(1, Types.VARCHAR);
    cstmt.registerOutParameter(1, Types.VARCHAR, "VARCHAR");
    cstmt.registerOutParameter(1, Types.VARCHAR, 3);
    cstmt.registerOutParameter("1", Types.VARCHAR);
    cstmt.registerOutParameter("1", Types.VARCHAR, "VARCHAR");
    cstmt.registerOutParameter("1", Types.VARCHAR, 3);
    cstmt.setBoolean("1", true);
    cstmt.setByte("1", (byte) 0);
    cstmt.setShort("1", (short) 0);
    cstmt.setInt("1", 0);
    cstmt.setLong("1", 0);
    cstmt.setFloat("1", 0);
    cstmt.setDouble("1", 0);
    cstmt.setBigDecimal("1", new BigDecimal("111"));
    cstmt.setString("1", "X");
    cstmt.setURL("1", null);
    cstmt.setSQLXML("1", null);
    cstmt.setBytes("1", null);
    cstmt.setDate("1", null);
    cstmt.setDate("1", null, Calendar.getInstance());
    cstmt.setTime("1", null);
    cstmt.setTime("1", null, Calendar.getInstance());
    cstmt.setTimestamp("1", null);
    cstmt.setTimestamp("1", null, Calendar.getInstance());
    cstmt.setAsciiStream("1", null);
    cstmt.setAsciiStream("1", null, 0);
    cstmt.setAsciiStream("1", null, 0L);
    cstmt.setBinaryStream("1", null);
    cstmt.setBinaryStream("1", null, 0);
    cstmt.setBinaryStream("1", null, 0L);
    cstmt.setObject("1", null);
    cstmt.setObject("1", null, Types.VARCHAR);
    cstmt.setObject("1", null, Types.VARCHAR, 3);
    cstmt.setCharacterStream("1", null);
    cstmt.setCharacterStream("1", null, 0);
    cstmt.setCharacterStream("1", null, 0L);
    cstmt.setNull("1", Types.VARCHAR);
    cstmt.setNull("1", Types.VARCHAR, "VARCHAR");
    cstmt.setRowId("1", null);
    cstmt.setNString("1", null);
    cstmt.setNCharacterStream("1", null);
    cstmt.setNCharacterStream("1", null, 0);
    cstmt.setNClob("1", (NClob) null);
    cstmt.setNClob("1", (Reader) null);
    cstmt.setNClob("1", (Reader) null, 0);
    cstmt.setClob("1", (Clob) null);
    cstmt.setClob("1", (Reader) null);
    cstmt.setClob("1", (Reader) null, 0);
    cstmt.setBlob("1", (Blob) null);
    cstmt.setBlob("1", (InputStream) null);
    cstmt.setBlob("1", (InputStream) null, 0);
    cstmt.setURL(1, null);
    cstmt.setSQLXML(1, null);
    cstmt.setArray(1, null);
    cstmt.setNCharacterStream(1, null);
    cstmt.setNCharacterStream(1, null, 0);
    cstmt.setNClob(1, (NClob) null);
    cstmt.setNClob(1, (Reader) null);
    cstmt.setNClob(1, (Reader) null, 0);
    cstmt.setNString(1, null);
    cstmt.setObject(1, null);
    cstmt.setRef(1, null);
    cstmt.setRowId(1, null);
    cstmt.setUnicodeStream(1, null, 0);
    cstmt.getClob(1);
    cstmt.getClob("1");
    cstmt.cancel();
    cstmt.getResultSet();
}
Also used : DataSourceProxyConfig(com.alibaba.druid.proxy.jdbc.DataSourceProxyConfig) DataSourceProxy(com.alibaba.druid.proxy.jdbc.DataSourceProxy) DataSourceProxyImpl(com.alibaba.druid.proxy.jdbc.DataSourceProxyImpl) FilterEventAdapter(com.alibaba.druid.filter.FilterEventAdapter) ConnectionProxyImpl(com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl) CallableStatementProxyImpl(com.alibaba.druid.proxy.jdbc.CallableStatementProxyImpl) Properties(java.util.Properties) ConnectionProxy(com.alibaba.druid.proxy.jdbc.ConnectionProxy) BigDecimal(java.math.BigDecimal)

Example 2 with FilterEventAdapter

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

the class ConnectionProxyImplTest method test_connection.

public void test_connection() throws Exception {
    DataSourceProxyConfig config = new DataSourceProxyConfig();
    DataSourceProxy dataSource = new DataSourceProxyImpl(null, config);
    FilterEventAdapter filter = new FilterEventAdapter() {
    };
    filter.init(dataSource);
    ConnectionProxyImpl rawConnection = new ConnectionProxyImpl(null, null, new Properties(), 0) {

        public void setClientInfo(String name, String value) throws SQLClientInfoException {
        }
    };
    ConnectionProxyImpl connection = new ConnectionProxyImpl(dataSource, rawConnection, new Properties(), 1001);
    connection.setClientInfo("name", null);
}
Also used : DataSourceProxyConfig(com.alibaba.druid.proxy.jdbc.DataSourceProxyConfig) DataSourceProxy(com.alibaba.druid.proxy.jdbc.DataSourceProxy) DataSourceProxyImpl(com.alibaba.druid.proxy.jdbc.DataSourceProxyImpl) FilterEventAdapter(com.alibaba.druid.filter.FilterEventAdapter) ConnectionProxyImpl(com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl) Properties(java.util.Properties)

Example 3 with FilterEventAdapter

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

the class JdbcFilterEventAdapterTest method test_filterEventAdapter.

public void test_filterEventAdapter() throws Exception {
    DataSourceProxyConfig config = new DataSourceProxyConfig();
    DataSourceProxy dataSource = new DataSourceProxyImpl(null, config);
    FilterEventAdapter filter = new FilterEventAdapter() {
    };
    String sql = "SELECT * FROM PATROL";
    ConnectionProxy connection = new ConnectionProxyImpl(dataSource, null, new Properties(), 1001);
    final PreparedStatementProxy statement = new PreparedStatementProxyImpl(connection, null, sql, 1002);
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public boolean statement_execute(StatementProxy statement, String sql) throws SQLException {
                throw new SQLException();
            }
        };
        Throwable error = null;
        try {
            filter.statement_execute(chain, statement, sql);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public boolean statement_execute(StatementProxy statement, String sql) throws SQLException {
                throw new RuntimeException();
            }
        };
        Throwable error = null;
        try {
            filter.statement_execute(chain, statement, sql);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public boolean statement_execute(StatementProxy statement, String sql) throws SQLException {
                throw new Error();
            }
        };
        Throwable error = null;
        try {
            filter.statement_execute(chain, statement, sql);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    // //////////////////////////
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public boolean statement_execute(StatementProxy statement, String sql, int autoGeneratedKeys) throws SQLException {
                throw new SQLException();
            }
        };
        Throwable error = null;
        try {
            filter.statement_execute(chain, statement, sql, Statement.NO_GENERATED_KEYS);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public boolean statement_execute(StatementProxy statement, String sql, int autoGeneratedKeys) throws SQLException {
                throw new RuntimeException();
            }
        };
        Throwable error = null;
        try {
            filter.statement_execute(chain, statement, sql, Statement.NO_GENERATED_KEYS);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public boolean statement_execute(StatementProxy statement, String sql, int autoGeneratedKeys) throws SQLException {
                throw new Error();
            }
        };
        Throwable error = null;
        try {
            filter.statement_execute(chain, statement, sql, Statement.NO_GENERATED_KEYS);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    // //////////////////////////
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public boolean statement_execute(StatementProxy statement, String sql, int[] columnIndexes) throws SQLException {
                throw new SQLException();
            }
        };
        Throwable error = null;
        try {
            filter.statement_execute(chain, statement, sql, new int[0]);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public boolean statement_execute(StatementProxy statement, String sql, int[] columnIndexes) throws SQLException {
                throw new RuntimeException();
            }
        };
        Throwable error = null;
        try {
            filter.statement_execute(chain, statement, sql, new int[0]);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public boolean statement_execute(StatementProxy statement, String sql, int[] columnIndexes) throws SQLException {
                throw new Error();
            }
        };
        Throwable error = null;
        try {
            filter.statement_execute(chain, statement, sql, new int[0]);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    // //////////////////////////
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public boolean statement_execute(StatementProxy statement, String sql, String[] columnNames) throws SQLException {
                throw new SQLException();
            }
        };
        Throwable error = null;
        try {
            filter.statement_execute(chain, statement, sql, new String[0]);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public boolean statement_execute(StatementProxy statement, String sql, String[] columnNames) throws SQLException {
                throw new RuntimeException();
            }
        };
        Throwable error = null;
        try {
            filter.statement_execute(chain, statement, sql, new String[0]);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public boolean statement_execute(StatementProxy statement, String sql, String[] columnNames) throws SQLException {
                throw new Error();
            }
        };
        Throwable error = null;
        try {
            filter.statement_execute(chain, statement, sql, new String[0]);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    // //////////////////////////
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public int[] statement_executeBatch(StatementProxy statement) throws SQLException {
                throw new SQLException();
            }
        };
        Throwable error = null;
        try {
            filter.statement_executeBatch(chain, statement);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public int[] statement_executeBatch(StatementProxy statement) throws SQLException {
                throw new RuntimeException();
            }
        };
        Throwable error = null;
        try {
            filter.statement_executeBatch(chain, statement);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public int[] statement_executeBatch(StatementProxy statement) throws SQLException {
                throw new Error();
            }
        };
        Throwable error = null;
        try {
            filter.statement_executeBatch(chain, statement);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    // //////////////////////////
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public ResultSetProxy statement_executeQuery(StatementProxy statement, String sql) throws SQLException {
                throw new SQLException();
            }
        };
        Throwable error = null;
        try {
            filter.statement_executeQuery(chain, statement, sql);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public ResultSetProxy statement_executeQuery(StatementProxy statement, String sql) throws SQLException {
                throw new RuntimeException();
            }
        };
        Throwable error = null;
        try {
            filter.statement_executeQuery(chain, statement, sql);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public ResultSetProxy statement_executeQuery(StatementProxy statement, String sql) throws SQLException {
                throw new Error();
            }
        };
        Throwable error = null;
        try {
            filter.statement_executeQuery(chain, statement, sql);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    // //////////////////////////
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public int preparedStatement_executeUpdate(PreparedStatementProxy statement) throws SQLException {
                throw new SQLException();
            }
        };
        Throwable error = null;
        try {
            filter.preparedStatement_executeUpdate(chain, statement);
        } catch (SQLException ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public int preparedStatement_executeUpdate(PreparedStatementProxy statement) throws SQLException {
                throw new RuntimeException();
            }
        };
        Throwable error = null;
        try {
            filter.preparedStatement_executeUpdate(chain, statement);
        } catch (RuntimeException ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public int preparedStatement_executeUpdate(PreparedStatementProxy statement) throws SQLException {
                throw new Error();
            }
        };
        Throwable error = null;
        try {
            filter.preparedStatement_executeUpdate(chain, statement);
        } catch (Error ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    // //////////////////////////
    // //////////////////////////
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public int statement_executeUpdate(StatementProxy statement, String sql) throws SQLException {
                throw new SQLException();
            }
        };
        Throwable error = null;
        try {
            filter.statement_executeUpdate(chain, statement, sql);
        } catch (SQLException ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public int statement_executeUpdate(StatementProxy statement, String sql) throws SQLException {
                throw new RuntimeException();
            }
        };
        Throwable error = null;
        try {
            filter.statement_executeUpdate(chain, statement, sql);
        } catch (RuntimeException ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public int statement_executeUpdate(StatementProxy statement, String sql) throws SQLException {
                throw new Error();
            }
        };
        Throwable error = null;
        try {
            filter.statement_executeUpdate(chain, statement, sql);
        } catch (Error ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    // //////////////////////////
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public int statement_executeUpdate(StatementProxy statement, String sql, int autoGeneratedKeys) throws SQLException {
                throw new SQLException();
            }
        };
        Throwable error = null;
        try {
            filter.statement_executeUpdate(chain, statement, sql, Statement.NO_GENERATED_KEYS);
        } catch (SQLException ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public int statement_executeUpdate(StatementProxy statement, String sql, int autoGeneratedKeys) throws SQLException {
                throw new RuntimeException();
            }
        };
        Throwable error = null;
        try {
            filter.statement_executeUpdate(chain, statement, sql, Statement.NO_GENERATED_KEYS);
        } catch (RuntimeException ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public int statement_executeUpdate(StatementProxy statement, String sql, int autoGeneratedKeys) throws SQLException {
                throw new Error();
            }
        };
        Throwable error = null;
        try {
            filter.statement_executeUpdate(chain, statement, sql, Statement.NO_GENERATED_KEYS);
        } catch (Error ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    // //////////////////////////
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public int statement_executeUpdate(StatementProxy statement, String sql, int[] columnIndexes) throws SQLException {
                throw new SQLException();
            }
        };
        Throwable error = null;
        try {
            filter.statement_executeUpdate(chain, statement, sql, new int[0]);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public int statement_executeUpdate(StatementProxy statement, String sql, int[] columnIndexes) throws SQLException {
                throw new RuntimeException();
            }
        };
        Throwable error = null;
        try {
            filter.statement_executeUpdate(chain, statement, sql, new int[0]);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public int statement_executeUpdate(StatementProxy statement, String sql, int[] columnIndexes) throws SQLException {
                throw new Error();
            }
        };
        Throwable error = null;
        try {
            filter.statement_executeUpdate(chain, statement, sql, new int[0]);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    // //////////////////////////
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public int statement_executeUpdate(StatementProxy statement, String sql, String[] columnNames) throws SQLException {
                throw new SQLException();
            }
        };
        Throwable error = null;
        try {
            filter.statement_executeUpdate(chain, statement, sql, new String[0]);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public int statement_executeUpdate(StatementProxy statement, String sql, String[] columnNames) throws SQLException {
                throw new RuntimeException();
            }
        };
        Throwable error = null;
        try {
            filter.statement_executeUpdate(chain, statement, sql, new String[0]);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public int statement_executeUpdate(StatementProxy statement, String sql, String[] columnNames) throws SQLException {
                throw new Error();
            }
        };
        Throwable error = null;
        try {
            filter.statement_executeUpdate(chain, statement, sql, new String[0]);
        } catch (Throwable ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    // ///////////////////////////
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public ResultSetProxy statement_getGeneratedKeys(StatementProxy statement) throws SQLException {
                return null;
            }
        };
        filter.statement_getGeneratedKeys(chain, statement);
    }
    {
        final ResultSetProxy resultSet = new ResultSetProxyImpl(statement, null, 2001, null);
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public ResultSetProxy statement_getGeneratedKeys(StatementProxy statement) throws SQLException {
                return resultSet;
            }
        };
        filter.statement_getGeneratedKeys(chain, statement);
    }
    // //////////////////////////
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public boolean preparedStatement_execute(PreparedStatementProxy statement) throws SQLException {
                throw new SQLException();
            }
        };
        Throwable error = null;
        try {
            filter.preparedStatement_execute(chain, statement);
        } catch (SQLException ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public boolean preparedStatement_execute(PreparedStatementProxy statement) throws SQLException {
                throw new RuntimeException();
            }
        };
        Throwable error = null;
        try {
            filter.preparedStatement_execute(chain, statement);
        } catch (RuntimeException ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public boolean preparedStatement_execute(PreparedStatementProxy statement) throws SQLException {
                throw new Error();
            }
        };
        Throwable error = null;
        try {
            filter.preparedStatement_execute(chain, statement);
        } catch (Error ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    // //////////////////////////
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public ResultSetProxy preparedStatement_executeQuery(PreparedStatementProxy statement) throws SQLException {
                throw new SQLException();
            }
        };
        Throwable error = null;
        try {
            filter.preparedStatement_executeQuery(chain, statement);
        } catch (SQLException ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public ResultSetProxy preparedStatement_executeQuery(PreparedStatementProxy statement) throws SQLException {
                throw new RuntimeException();
            }
        };
        Throwable error = null;
        try {
            filter.preparedStatement_executeQuery(chain, statement);
        } catch (RuntimeException ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public ResultSetProxy preparedStatement_executeQuery(PreparedStatementProxy statement) throws SQLException {
                throw new Error();
            }
        };
        Throwable error = null;
        try {
            filter.preparedStatement_executeQuery(chain, statement);
        } catch (Error ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    // //////////////////////////
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public void dataSource_recycle(DruidPooledConnection connection) throws SQLException {
                throw new SQLException();
            }
        };
        Throwable error = null;
        try {
            filter.dataSource_releaseConnection(chain, null);
        } catch (SQLException ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public void dataSource_recycle(DruidPooledConnection connection) throws SQLException {
                throw new RuntimeException();
            }
        };
        Throwable error = null;
        try {
            filter.dataSource_releaseConnection(chain, null);
        } catch (RuntimeException ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public void dataSource_recycle(DruidPooledConnection connection) throws SQLException {
                throw new Error();
            }
        };
        Throwable error = null;
        try {
            filter.dataSource_releaseConnection(chain, null);
        } catch (Error ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    // //////////////////////////
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public DruidPooledConnection dataSource_connect(DruidDataSource dataSource, long maxWaitMillis) throws SQLException {
                throw new SQLException();
            }
        };
        Throwable error = null;
        try {
            filter.dataSource_getConnection(chain, null, 0L);
        } catch (SQLException ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public DruidPooledConnection dataSource_connect(DruidDataSource dataSource, long maxWaitMillis) throws SQLException {
                throw new RuntimeException();
            }
        };
        Throwable error = null;
        try {
            filter.dataSource_getConnection(chain, null, 0L);
        } catch (RuntimeException ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    {
        FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

            public DruidPooledConnection dataSource_connect(DruidDataSource dataSource, long maxWaitMillis) throws SQLException {
                throw new Error();
            }
        };
        Throwable error = null;
        try {
            filter.dataSource_getConnection(chain, null, 0L);
        } catch (Error ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
}
Also used : SQLException(java.sql.SQLException) FilterChain(com.alibaba.druid.filter.FilterChain) ConnectionProxyImpl(com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl) Properties(java.util.Properties) ConnectionProxy(com.alibaba.druid.proxy.jdbc.ConnectionProxy) DruidPooledConnection(com.alibaba.druid.pool.DruidPooledConnection) PreparedStatementProxy(com.alibaba.druid.proxy.jdbc.PreparedStatementProxy) FilterChainImpl(com.alibaba.druid.filter.FilterChainImpl) DataSourceProxyConfig(com.alibaba.druid.proxy.jdbc.DataSourceProxyConfig) PreparedStatementProxyImpl(com.alibaba.druid.proxy.jdbc.PreparedStatementProxyImpl) DataSourceProxy(com.alibaba.druid.proxy.jdbc.DataSourceProxy) DataSourceProxyImpl(com.alibaba.druid.proxy.jdbc.DataSourceProxyImpl) ResultSetProxyImpl(com.alibaba.druid.proxy.jdbc.ResultSetProxyImpl) DruidDataSource(com.alibaba.druid.pool.DruidDataSource) FilterEventAdapter(com.alibaba.druid.filter.FilterEventAdapter) StatementProxy(com.alibaba.druid.proxy.jdbc.StatementProxy) PreparedStatementProxy(com.alibaba.druid.proxy.jdbc.PreparedStatementProxy) ResultSetProxy(com.alibaba.druid.proxy.jdbc.ResultSetProxy)

Aggregations

FilterEventAdapter (com.alibaba.druid.filter.FilterEventAdapter)3 ConnectionProxyImpl (com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl)3 DataSourceProxy (com.alibaba.druid.proxy.jdbc.DataSourceProxy)3 DataSourceProxyConfig (com.alibaba.druid.proxy.jdbc.DataSourceProxyConfig)3 DataSourceProxyImpl (com.alibaba.druid.proxy.jdbc.DataSourceProxyImpl)3 Properties (java.util.Properties)3 ConnectionProxy (com.alibaba.druid.proxy.jdbc.ConnectionProxy)2 FilterChain (com.alibaba.druid.filter.FilterChain)1 FilterChainImpl (com.alibaba.druid.filter.FilterChainImpl)1 DruidDataSource (com.alibaba.druid.pool.DruidDataSource)1 DruidPooledConnection (com.alibaba.druid.pool.DruidPooledConnection)1 CallableStatementProxyImpl (com.alibaba.druid.proxy.jdbc.CallableStatementProxyImpl)1 PreparedStatementProxy (com.alibaba.druid.proxy.jdbc.PreparedStatementProxy)1 PreparedStatementProxyImpl (com.alibaba.druid.proxy.jdbc.PreparedStatementProxyImpl)1 ResultSetProxy (com.alibaba.druid.proxy.jdbc.ResultSetProxy)1 ResultSetProxyImpl (com.alibaba.druid.proxy.jdbc.ResultSetProxyImpl)1 StatementProxy (com.alibaba.druid.proxy.jdbc.StatementProxy)1 BigDecimal (java.math.BigDecimal)1 SQLException (java.sql.SQLException)1