mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
test fixed
This commit is contained in:
@@ -10,6 +10,7 @@ import oracle.jdbc.OracleConnection;
|
||||
import oracle.jdbc.internal.OraclePreparedStatement;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.alibaba.druid.pool.PreparedStatementHolder;
|
||||
import com.alibaba.druid.test.util.OracleMockDriver;
|
||||
import com.alibaba.druid.util.JdbcUtils;
|
||||
|
||||
@@ -34,20 +35,25 @@ public class TestOraclePrefetch extends TestCase {
|
||||
|
||||
String sql = "SELECT 1";
|
||||
|
||||
OracleConnection oracleConn;
|
||||
OraclePreparedStatement oracleStmt;
|
||||
PreparedStatementHolder stmtHolder;
|
||||
{
|
||||
Connection conn = dataSource.getConnection();
|
||||
|
||||
{
|
||||
OracleConnection oracleConn = conn.unwrap(OracleConnection.class);
|
||||
oracleConn = conn.unwrap(OracleConnection.class);
|
||||
Assert.assertEquals(50, oracleConn.getDefaultRowPrefetch());
|
||||
}
|
||||
|
||||
PreparedStatement stmt = conn.prepareStatement(sql);
|
||||
|
||||
{
|
||||
OraclePreparedStatement oracleStmt = stmt.unwrap(OraclePreparedStatement.class);
|
||||
Assert.assertEquals(50, oracleStmt.getRowPrefetch());
|
||||
}
|
||||
oracleStmt = stmt.unwrap(OraclePreparedStatement.class);
|
||||
Assert.assertEquals(50, oracleStmt.getRowPrefetch());
|
||||
|
||||
stmtHolder = stmt.unwrap(PreparedStatementHolder.class);
|
||||
Assert.assertNotNull(stmtHolder);
|
||||
Assert.assertEquals(0, stmtHolder.getHitCount());
|
||||
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
@@ -61,22 +67,29 @@ public class TestOraclePrefetch extends TestCase {
|
||||
Connection conn = dataSource.getConnection();
|
||||
|
||||
{
|
||||
OracleConnection oracleConn = conn.unwrap(OracleConnection.class);
|
||||
Assert.assertEquals(50, oracleConn.getDefaultRowPrefetch());
|
||||
OracleConnection oracleConn2 = conn.unwrap(OracleConnection.class);
|
||||
Assert.assertEquals(50, oracleConn2.getDefaultRowPrefetch());
|
||||
Assert.assertSame(oracleConn, oracleConn2);
|
||||
}
|
||||
|
||||
PreparedStatement stmt = conn.prepareStatement(sql);
|
||||
|
||||
{
|
||||
PreparedStatementHolder stmtHolder2 = stmt.unwrap(PreparedStatementHolder.class);
|
||||
Assert.assertSame(stmtHolder2, stmtHolder);
|
||||
Assert.assertEquals(1, stmtHolder.getHitCount());
|
||||
}
|
||||
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
|
||||
rs.close();
|
||||
stmt.close();
|
||||
{
|
||||
OraclePreparedStatement oracleStmt = stmt.unwrap(OraclePreparedStatement.class);
|
||||
OraclePreparedStatement oracleStmt2 = stmt.unwrap(OraclePreparedStatement.class);
|
||||
Assert.assertSame(oracleStmt, oracleStmt2);
|
||||
Assert.assertEquals(2, oracleStmt.getRowPrefetch());
|
||||
}
|
||||
|
||||
rs.close();
|
||||
stmt.close();
|
||||
conn.close();
|
||||
}
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ public class START_TRANSACTION_Test extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SET autocommit = 0;", text);
|
||||
Assert.assertEquals("SET @@autocommit = 0;", text);
|
||||
}
|
||||
|
||||
private String output(List<SQLStatement> stmtList) {
|
||||
|
||||
Reference in New Issue
Block a user