use of com.alibaba.druid.mock.MockPreparedStatement in project druid by alibaba.
the class TestPoolPreparedStatement method test_removeAbandoned.
public void test_removeAbandoned() throws Exception {
MockPreparedStatement raw;
{
Connection conn = dataSource.getConnection();
PreparedStatement stmt = conn.prepareStatement("SELECT ?");
raw = stmt.unwrap(MockPreparedStatement.class);
stmt.execute();
stmt.close();
conn.close();
}
{
Connection conn = dataSource.getConnection();
PreparedStatement stmt = conn.prepareStatement("SELECT ?");
Assert.assertTrue(raw == stmt.unwrap(MockPreparedStatement.class));
stmt.execute();
stmt.close();
conn.close();
}
Assert.assertEquals(0, dataSource.getActiveCount());
Assert.assertEquals(1, dataSource.getPoolingCount());
}
use of com.alibaba.druid.mock.MockPreparedStatement in project druid by alibaba.
the class TestGetUpdateCount method setUp.
protected void setUp() throws Exception {
driver = new MockDriver() {
@Override
public MockPreparedStatement createMockPreparedStatement(MockConnection conn, String sql) {
return new MyPreparedStatement(conn, sql);
}
};
// /////////////////////////////
dataSource = new DruidDataSource();
dataSource.setDriver(driver);
dataSource.setUrl("jdbc:mock:xx");
dataSource.setFilters("stat");
dataSource.setMaxOpenPreparedStatements(30);
}
use of com.alibaba.druid.mock.MockPreparedStatement in project druid by alibaba.
the class ConnectionTest4 method test_prepareStatement_3.
public void test_prepareStatement_3() throws Exception {
DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);
MockPreparedStatement raw = null;
{
PreparedStatement stmt = conn.prepareStatement("SELECT 1", new String[0]);
raw = stmt.unwrap(MockPreparedStatement.class);
stmt.close();
}
{
PreparedStatement stmt = conn.prepareStatement("SELECT 1", new String[0]);
Assert.assertEquals(raw, stmt.unwrap(MockPreparedStatement.class));
stmt.close();
}
conn.close();
}
use of com.alibaba.druid.mock.MockPreparedStatement in project druid by alibaba.
the class ConnectionTest4 method test_prepareStatement_4.
public void test_prepareStatement_4() throws Exception {
DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);
MockPreparedStatement raw = null;
{
PreparedStatement stmt = conn.prepareStatement("SELECT 1", 0);
raw = stmt.unwrap(MockPreparedStatement.class);
stmt.close();
}
{
PreparedStatement stmt = conn.prepareStatement("SELECT 1", 0);
Assert.assertEquals(raw, stmt.unwrap(MockPreparedStatement.class));
stmt.close();
}
conn.close();
}
use of com.alibaba.druid.mock.MockPreparedStatement in project druid by alibaba.
the class ConnectionTest4 method test_prepareStatement_1.
public void test_prepareStatement_1() throws Exception {
DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);
MockPreparedStatement raw = null;
{
PreparedStatement stmt = conn.prepareStatement("SELECT 1", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
raw = stmt.unwrap(MockPreparedStatement.class);
stmt.close();
}
{
PreparedStatement stmt = conn.prepareStatement("SELECT 1", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
Assert.assertSame(raw, stmt.unwrap(MockPreparedStatement.class));
stmt.close();
}
conn.close();
}
Aggregations