use of com.alibaba.druid.mock.MockClob in project druid by alibaba.
the class StatFilterClobTest method test_clob.
public void test_clob() throws Exception {
String sql = "select ?";
Connection conn = dataSource.getConnection();
PreparedStatement stmt = conn.prepareStatement(sql);
MockClob clob = new MockClob();
stmt.setClob(1, clob);
ResultSet rs = stmt.executeQuery();
rs.next();
Assert.assertTrue(rs.getObject(1) instanceof ClobProxy);
rs.close();
stmt.close();
conn.close();
JdbcSqlStat sqlStat = dataSource.getDataSourceStat().getSqlStat(sql);
Assert.assertNotNull(sqlStat);
Assert.assertEquals(1, sqlStat.getClobOpenCount());
sqlStat.reset();
Assert.assertEquals(0, sqlStat.getClobOpenCount());
}
use of com.alibaba.druid.mock.MockClob 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();
}
Aggregations