diff --git a/java/openmldb-jdbc/src/test/java/com/_4paradigm/openmldb/jdbc/SQLRouterSmokeTest.java b/java/openmldb-jdbc/src/test/java/com/_4paradigm/openmldb/jdbc/SQLRouterSmokeTest.java index 63b5f43ce57..abadd7ed216 100644 --- a/java/openmldb-jdbc/src/test/java/com/_4paradigm/openmldb/jdbc/SQLRouterSmokeTest.java +++ b/java/openmldb-jdbc/src/test/java/com/_4paradigm/openmldb/jdbc/SQLRouterSmokeTest.java @@ -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); @@ -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 @@ -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(); diff --git a/java/openmldb-jdbc/src/test/java/com/_4paradigm/openmldb/jdbc/StatementTest.java b/java/openmldb-jdbc/src/test/java/com/_4paradigm/openmldb/jdbc/StatementTest.java index 854ee733026..79c17e37935 100644 --- a/java/openmldb-jdbc/src/test/java/com/_4paradigm/openmldb/jdbc/StatementTest.java +++ b/java/openmldb-jdbc/src/test/java/com/_4paradigm/openmldb/jdbc/StatementTest.java @@ -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(); @@ -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);