use of com.alibaba.druid.mock.MockCallableStatement in project druid by alibaba.
the class DruidJdbcExtractorTest method test_spring.
public void test_spring() throws Exception {
DruidDataSource dataSource = new DruidDataSource();
try {
DruidNativeJdbcExtractor extractor = new DruidNativeJdbcExtractor();
dataSource.setUrl("jdbc:mock:xx1");
Connection conn = dataSource.getConnection();
Assert.assertEquals(true, extractor.getNativeConnection(conn) instanceof MockConnection);
Statement stmt = conn.createStatement();
Assert.assertEquals(true, extractor.getNativeConnectionFromStatement(stmt) instanceof MockConnection);
Assert.assertEquals(true, extractor.getNativeStatement(stmt) instanceof MockStatement);
stmt.close();
PreparedStatement preStmt = conn.prepareStatement("select 1");
Assert.assertEquals(true, extractor.getNativeConnectionFromStatement(preStmt) instanceof MockConnection);
Assert.assertEquals(true, extractor.getNativeStatement(preStmt) instanceof MockPreparedStatement);
Assert.assertEquals(true, extractor.getNativePreparedStatement(preStmt) instanceof MockPreparedStatement);
preStmt.close();
PreparedStatement callStmt = conn.prepareCall("select 1");
Assert.assertEquals(true, extractor.getNativeConnectionFromStatement(callStmt) instanceof MockConnection);
Assert.assertEquals(true, extractor.getNativeStatement(callStmt) instanceof MockCallableStatement);
Assert.assertEquals(true, extractor.getNativePreparedStatement(callStmt) instanceof MockCallableStatement);
callStmt.close();
conn.close();
} finally {
dataSource.close();
}
}
use of com.alibaba.druid.mock.MockCallableStatement in project druid by alibaba.
the class DruidJdbcExtractorTest method test_spring_filter.
public void test_spring_filter() throws Exception {
DruidDataSource dataSource = new DruidDataSource();
try {
DruidNativeJdbcExtractor extractor = new DruidNativeJdbcExtractor();
dataSource.setUrl("jdbc:mock:xx1");
dataSource.setFilters("stat");
Connection conn = dataSource.getConnection();
Assert.assertEquals(true, extractor.getNativeConnection(conn) instanceof MockConnection);
Statement stmt = conn.createStatement();
Assert.assertEquals(true, extractor.getNativeConnectionFromStatement(stmt) instanceof MockConnection);
Assert.assertEquals(true, extractor.getNativeStatement(stmt) instanceof MockStatement);
stmt.close();
PreparedStatement preStmt = conn.prepareStatement("select 1");
Assert.assertEquals(true, extractor.getNativeConnectionFromStatement(preStmt) instanceof MockConnection);
Assert.assertEquals(true, extractor.getNativeStatement(preStmt) instanceof MockPreparedStatement);
Assert.assertEquals(true, extractor.getNativePreparedStatement(preStmt) instanceof MockPreparedStatement);
preStmt.close();
PreparedStatement callStmt = conn.prepareCall("select 1");
Assert.assertEquals(true, extractor.getNativeConnectionFromStatement(callStmt) instanceof MockConnection);
Assert.assertEquals(true, extractor.getNativeStatement(callStmt) instanceof MockCallableStatement);
Assert.assertEquals(true, extractor.getNativePreparedStatement(callStmt) instanceof MockCallableStatement);
callStmt.close();
conn.close();
} finally {
dataSource.close();
}
}
use of com.alibaba.druid.mock.MockCallableStatement in project druid by alibaba.
the class CallableStatmentTest method setUp.
protected void setUp() throws Exception {
dataSource = new DruidDataSource();
dataSource.setUrl("jdbc:mock:xxx");
dataSource.setTestOnBorrow(false);
dataSource.setPoolPreparedStatements(true);
dataSource.setMaxOpenPreparedStatements(100);
dataSource.setFilters("log4j");
dataSource.setDriver(new MockDriver() {
public MockCallableStatement createMockCallableStatement(MockConnection conn, String sql) {
return new MyMockCallableStatement(conn, sql);
}
});
}
use of com.alibaba.druid.mock.MockCallableStatement in project druid by alibaba.
the class FilterChainTest_NClob_2 method setUp.
protected void setUp() throws Exception {
dataSource = new DruidDataSource();
MockCallableStatement mockStmt = new MockCallableStatement(null, "") {
@Override
public Object getObject(int parameterIndex) throws SQLException {
invokeCount++;
return new MockNClob();
}
};
statement = new CallableStatementProxyImpl(new ConnectionProxyImpl(null, null, null, 0), mockStmt, "", 1);
}
Aggregations