Search in sources :

Example 21 with MockResultSet

use of com.alibaba.druid.mock.MockResultSet in project druid by alibaba.

the class FilterChainTest_ResultSet method setUp.

protected void setUp() throws Exception {
    dataSource = new DruidDataSource();
    statement = new StatementProxyImpl(null, null, 1);
    mockResultSet = new MockResultSet(null) {

        public Object getObject(int columnIndex) throws SQLException {
            invokeCount++;
            return new MockResultSet(null);
        }
    };
}
Also used : SQLException(java.sql.SQLException) MockResultSet(com.alibaba.druid.mock.MockResultSet) DruidDataSource(com.alibaba.druid.pool.DruidDataSource) StatementProxyImpl(com.alibaba.druid.proxy.jdbc.StatementProxyImpl)

Example 22 with MockResultSet

use of com.alibaba.druid.mock.MockResultSet in project druid by alibaba.

the class DruidPooledResultSetTest2 method testWrap.

public void testWrap() throws Exception {
    String sql = "select ?";
    Connection conn = dataSource.getConnection();
    PreparedStatement stmt = conn.prepareStatement(sql);
    stmt.setString(1, "xxx");
    ResultSet rs = stmt.executeQuery();
    ResultSet raw = rs.unwrap(ResultSet.class);
    Assert.assertTrue(raw instanceof MockResultSet);
    rs.close();
    conn.close();
}
Also used : Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) MockResultSet(com.alibaba.druid.mock.MockResultSet) PreparedStatement(java.sql.PreparedStatement) MockResultSet(com.alibaba.druid.mock.MockResultSet)

Aggregations

MockResultSet (com.alibaba.druid.mock.MockResultSet)22 SQLException (java.sql.SQLException)11 ResultSet (java.sql.ResultSet)7 ResultSetProxyImpl (com.alibaba.druid.proxy.jdbc.ResultSetProxyImpl)6 FilterChainImpl (com.alibaba.druid.filter.FilterChainImpl)5 DruidDataSource (com.alibaba.druid.pool.DruidDataSource)5 ResultSetProxy (com.alibaba.druid.proxy.jdbc.ResultSetProxy)5 MockResultSetMetaData (com.alibaba.druid.mock.MockResultSetMetaData)4 DruidPooledResultSet (com.alibaba.druid.pool.DruidPooledResultSet)4 StatementProxyImpl (com.alibaba.druid.proxy.jdbc.StatementProxyImpl)4 Properties (java.util.Properties)4 DruidPooledStatement (com.alibaba.druid.pool.DruidPooledStatement)3 ConnectionProxyImpl (com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl)3 Connection (java.sql.Connection)3 MockCallableStatement (com.alibaba.druid.mock.MockCallableStatement)2 MockClob (com.alibaba.druid.mock.MockClob)2 MockConnection (com.alibaba.druid.mock.MockConnection)2 MockStatement (com.alibaba.druid.mock.MockStatement)2 StatementProxy (com.alibaba.druid.proxy.jdbc.StatementProxy)2 ColumnMetaData (com.alibaba.druid.util.jdbc.ResultSetMetaDataBase.ColumnMetaData)2