提交 7b7b014d authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Fix TestStatement for Java 7

上级 383df1c3
......@@ -16,7 +16,9 @@ import java.util.HashMap;
import org.h2.api.ErrorCode;
import org.h2.engine.SysProperties;
import org.h2.jdbc.JdbcPreparedStatementBackwardsCompat;
import org.h2.jdbc.JdbcStatement;
import org.h2.jdbc.JdbcStatementBackwardsCompat;
import org.h2.store.fs.FileUtils;
import org.h2.test.TestBase;
import org.h2.util.New;
......@@ -258,15 +260,16 @@ public class TestStatement extends TestBase {
assertEquals(0, count);
count = stat.executeUpdate("DELETE FROM TEST WHERE ID=2");
assertEquals(1, count);
largeCount = stat.executeLargeUpdate("DELETE FROM TEST WHERE ID=-1");
JdbcStatementBackwardsCompat statBC = (JdbcStatementBackwardsCompat) stat;
largeCount = statBC.executeLargeUpdate("DELETE FROM TEST WHERE ID=-1");
assertEquals(0, largeCount);
assertEquals(0, stat.getLargeUpdateCount());
largeCount = stat.executeLargeUpdate("INSERT INTO TEST(VALUE,ID) VALUES('JDBC',2)");
assertEquals(0, statBC.getLargeUpdateCount());
largeCount = statBC.executeLargeUpdate("INSERT INTO TEST(VALUE,ID) VALUES('JDBC',2)");
assertEquals(1, largeCount);
assertEquals(1, stat.getLargeUpdateCount());
largeCount = stat.executeLargeUpdate("DELETE FROM TEST WHERE ID=2");
assertEquals(1, statBC.getLargeUpdateCount());
largeCount = statBC.executeLargeUpdate("DELETE FROM TEST WHERE ID=2");
assertEquals(1, largeCount);
assertEquals(1, stat.getLargeUpdateCount());
assertEquals(1, statBC.getLargeUpdateCount());
assertThrows(ErrorCode.METHOD_NOT_ALLOWED_FOR_QUERY, stat).
executeUpdate("SELECT * FROM TEST");
......@@ -453,15 +456,15 @@ public class TestStatement extends TestBase {
ps.setInt(1, 6);
ps.setString(2, "v6");
ps.addBatch();
assertTrue(Arrays.equals(new long[] {1, 1}, ps.executeLargeBatch()));
assertTrue(Arrays.equals(new long[] {1, 1}, ((JdbcStatementBackwardsCompat) ps).executeLargeBatch()));
ps.setInt(1, 7);
ps.setString(2, "v7");
assertEquals(1, ps.executeUpdate());
assertEquals(1, ps.getUpdateCount());
ps.setInt(1, 8);
ps.setString(2, "v8");
assertEquals(1, ps.executeLargeUpdate());
assertEquals(1, ps.getLargeUpdateCount());
assertEquals(1, ((JdbcPreparedStatementBackwardsCompat) ps).executeLargeUpdate());
assertEquals(1, ((JdbcStatementBackwardsCompat) ps).getLargeUpdateCount());
stat.execute("drop table test");
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论