Skip to content

Commit

Permalink
fix java test
Browse files Browse the repository at this point in the history
  • Loading branch information
vagetablechicken committed Jul 6, 2022
1 parent 9aa6122 commit abae23f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ public void testInsertPreparedState(SqlExecutor router) {
try {
impl2.setString(2, "c");
} catch (Exception e) {
Assert.assertEquals("data type not match", e.getMessage());
Assert.assertTrue(e.getMessage().contains("data type not match"));
}
impl2.setString(1, "sandong");
impl2.setDate(2, d3);
Expand Down Expand Up @@ -486,7 +486,7 @@ public void testInsertPreparedStateBatch(SqlExecutor router) {
try {
impl.setInt(2, 1002);
} catch (Exception e) {
Assert.assertEquals(e.getMessage(), "data type not match");
Assert.assertTrue(e.getMessage().contains("data type not match"));
}
try {
// set failed, so the row is uncompleted, appending row will be failed
Expand Down Expand Up @@ -522,7 +522,7 @@ public void testInsertPreparedStateBatch(SqlExecutor router) {
try {
impl2.setInt(2, 1002);
} catch (Exception e) {
Assert.assertEquals(e.getMessage(), "data type not match");
Assert.assertTrue(e.getMessage().contains("data type not match"));
}
try {
impl2.execute();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,22 @@ public void testExecute() {
java.sql.Statement state = router.getStatement();

try {
// execute success -> result != null -> true
boolean ret = state.execute("SET @@execute_mode='online';");
ret = state.execute("create database test");
Assert.assertFalse(ret);
ret = state.execute("create database if not exists test");
Assert.assertFalse(ret);
ret = state.execute("use test");
Assert.assertFalse(ret);
ret = state.execute("create table testtable111(col1 bigint, col2 string, index(key=col2, ts=col1));");
// TODO(hw): drop table if exists
ret = state.execute("create table testtable111(col1 bigint, col2 string, index(key=col2, " +
"ts=col1));");
Assert.assertFalse(ret);
state.executeUpdate("insert into testtable111 values(1000, 'hello');");
state.executeUpdate("insert into testtable111 values(1001, 'xxxx');");
int r = state.executeUpdate("insert into testtable111 values(1000, 'hello');");
// update insert stmt, is not dml, return nothing
Assert.assertEquals(r,0);
r = state.executeUpdate("insert into testtable111 values(1001, 'xxxx');");
Assert.assertEquals(r,0);
ret = state.execute("select * from testtable111");
Assert.assertTrue(ret);
java.sql.ResultSet rs = state.getResultSet();
Expand All @@ -45,9 +52,9 @@ public void testExecute() {
result.put(rs.getLong(1), rs.getString(2));
Assert.assertTrue(rs.next());
result.put(rs.getLong(1), rs.getString(2));
Assert.assertEquals(2, result.size());
Assert.assertEquals("hello", result.get(1000L));
Assert.assertEquals("xxxx", result.get(1001L));
Assert.assertEquals(result.size(), 2);
Assert.assertEquals( result.get(1000L), "hello");
Assert.assertEquals( result.get(1001L), "xxxx");

ret = state.execute("drop table testtable111");
Assert.assertFalse(ret);
Expand Down

0 comments on commit abae23f

Please sign in to comment.