提交 84069e20 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Add tests

上级 d573e9b2
...@@ -20,6 +20,7 @@ import java.sql.Clob; ...@@ -20,6 +20,7 @@ import java.sql.Clob;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DatabaseMetaData; import java.sql.DatabaseMetaData;
import java.sql.Date; import java.sql.Date;
import java.sql.NClob;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.Ref; import java.sql.Ref;
import java.sql.ResultSet; import java.sql.ResultSet;
...@@ -194,8 +195,9 @@ public class TestResultSet extends TestDb { ...@@ -194,8 +195,9 @@ public class TestResultSet extends TestDb {
PreparedStatement prep = conn.prepareStatement("select * from test", PreparedStatement prep = conn.prepareStatement("select * from test",
ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
ResultSet rs = prep.executeQuery(); ResultSet rs = prep.executeQuery();
int idx = 1;
rs.moveToInsertRow(); rs.moveToInsertRow();
rs.updateInt(1, 1); rs.updateInt(1, idx++);
rs.insertRow(); rs.insertRow();
rs.close(); rs.close();
rs = stat.executeQuery("select * from test"); rs = stat.executeQuery("select * from test");
...@@ -216,12 +218,12 @@ public class TestResultSet extends TestDb { ...@@ -216,12 +218,12 @@ public class TestResultSet extends TestDb {
rs = prep.executeQuery(); rs = prep.executeQuery();
rs.moveToInsertRow(); rs.moveToInsertRow();
rs.updateInt(1, 2); rs.updateInt(1, idx++);
rs.updateNString(2, "Hello"); rs.updateNString(2, "Hello");
rs.insertRow(); rs.insertRow();
rs.moveToInsertRow(); rs.moveToInsertRow();
rs.updateInt(1, 3); rs.updateInt(1, idx++);
rs.updateNString("data", "Hello"); rs.updateNString("data", "Hello");
rs.insertRow(); rs.insertRow();
...@@ -229,7 +231,7 @@ public class TestResultSet extends TestDb { ...@@ -229,7 +231,7 @@ public class TestResultSet extends TestDb {
Writer w; Writer w;
rs.moveToInsertRow(); rs.moveToInsertRow();
rs.updateInt(1, 4); rs.updateInt(1, idx++);
c = conn.createClob(); c = conn.createClob();
w = c.setCharacterStream(1); w = c.setCharacterStream(1);
w.write("Hello"); w.write("Hello");
...@@ -238,7 +240,7 @@ public class TestResultSet extends TestDb { ...@@ -238,7 +240,7 @@ public class TestResultSet extends TestDb {
rs.insertRow(); rs.insertRow();
rs.moveToInsertRow(); rs.moveToInsertRow();
rs.updateInt(1, 5); rs.updateInt(1, idx++);
c = conn.createClob(); c = conn.createClob();
w = c.setCharacterStream(1); w = c.setCharacterStream(1);
w.write("Hello"); w.write("Hello");
...@@ -246,48 +248,70 @@ public class TestResultSet extends TestDb { ...@@ -246,48 +248,70 @@ public class TestResultSet extends TestDb {
rs.updateClob("data", c); rs.updateClob("data", c);
rs.insertRow(); rs.insertRow();
NClob nc;
rs.moveToInsertRow();
rs.updateInt(1, idx++);
nc = conn.createNClob();
w = nc.setCharacterStream(1);
w.write("Hello");
w.close();
rs.updateNClob(2, nc);
rs.insertRow();
rs.moveToInsertRow();
rs.updateInt(1, idx++);
nc = conn.createNClob();
w = nc.setCharacterStream(1);
w.write("Hello");
w.close();
rs.updateNClob("data", nc);
rs.insertRow();
InputStream in; InputStream in;
rs.moveToInsertRow(); rs.moveToInsertRow();
rs.updateInt(1, 6); rs.updateInt(1, idx++);
in = new ByteArrayInputStream("Hello".getBytes(StandardCharsets.UTF_8)); in = new ByteArrayInputStream("Hello".getBytes(StandardCharsets.UTF_8));
rs.updateAsciiStream(2, in); rs.updateAsciiStream(2, in);
rs.insertRow(); rs.insertRow();
rs.moveToInsertRow(); rs.moveToInsertRow();
rs.updateInt(1, 7); rs.updateInt(1, idx++);
in = new ByteArrayInputStream("Hello".getBytes(StandardCharsets.UTF_8)); in = new ByteArrayInputStream("Hello".getBytes(StandardCharsets.UTF_8));
rs.updateAsciiStream("data", in); rs.updateAsciiStream("data", in);
rs.insertRow(); rs.insertRow();
rs.moveToInsertRow(); rs.moveToInsertRow();
rs.updateInt(1, 8); rs.updateInt(1, idx++);
in = new ByteArrayInputStream("Hello-".getBytes(StandardCharsets.UTF_8)); in = new ByteArrayInputStream("Hello-".getBytes(StandardCharsets.UTF_8));
rs.updateAsciiStream(2, in, 5); rs.updateAsciiStream(2, in, 5);
rs.insertRow(); rs.insertRow();
rs.moveToInsertRow(); rs.moveToInsertRow();
rs.updateInt(1, 9); rs.updateInt(1, idx++);
in = new ByteArrayInputStream("Hello-".getBytes(StandardCharsets.UTF_8)); in = new ByteArrayInputStream("Hello-".getBytes(StandardCharsets.UTF_8));
rs.updateAsciiStream("data", in, 5); rs.updateAsciiStream("data", in, 5);
rs.insertRow(); rs.insertRow();
rs.moveToInsertRow(); rs.moveToInsertRow();
rs.updateInt(1, 10); rs.updateInt(1, idx++);
in = new ByteArrayInputStream("Hello-".getBytes(StandardCharsets.UTF_8)); in = new ByteArrayInputStream("Hello-".getBytes(StandardCharsets.UTF_8));
rs.updateAsciiStream(2, in, 5L); rs.updateAsciiStream(2, in, 5L);
rs.insertRow(); rs.insertRow();
rs.moveToInsertRow(); rs.moveToInsertRow();
rs.updateInt(1, 11); rs.updateInt(1, idx++);
in = new ByteArrayInputStream("Hello-".getBytes(StandardCharsets.UTF_8)); in = new ByteArrayInputStream("Hello-".getBytes(StandardCharsets.UTF_8));
rs.updateAsciiStream("data", in, 5L); rs.updateAsciiStream("data", in, 5L);
rs.insertRow(); rs.insertRow();
rs = stat.executeQuery("select * from test"); rs = stat.executeQuery("select * from test");
while (rs.next()) { for (int i = 1; i < idx; i++) {
assertTrue(rs.next());
assertEquals("Hello", rs.getString(2)); assertEquals("Hello", rs.getString(2));
} }
assertFalse(rs.next());
stat.execute("drop table test"); stat.execute("drop table test");
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论