From ec999017f4e76ced8b3c0a50eba52a68f75397bf Mon Sep 17 00:00:00 2001 From: Cheng Pan Date: Mon, 26 Sep 2022 18:06:06 +0800 Subject: [PATCH] [KYUUBI #3549][FOLLOWUP] Simplify test ### _Why are the changes needed?_ Simplify test by using helper method `withJdbcStatement` ### _How was this patch tested?_ - [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible - [ ] Add screenshots for manual tests if appropriate - [x] [Run test](https://kyuubi.apache.org/docs/latest/develop_tools/testing.html#running-tests) locally before make a pull request Closes #3556 from pan3793/followup. Closes #3549 75103f85 [Cheng Pan] nit 449a2563 [Cheng Pan] [KYUUBI #3549][FOLLOWUP] Simplify test Authored-by: Cheng Pan Signed-off-by: Cheng Pan --- .../flink/operation/FlinkOperationSuite.scala | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/externals/kyuubi-flink-sql-engine/src/test/scala/org/apache/kyuubi/engine/flink/operation/FlinkOperationSuite.scala b/externals/kyuubi-flink-sql-engine/src/test/scala/org/apache/kyuubi/engine/flink/operation/FlinkOperationSuite.scala index 0d03cbf43..68ab3b757 100644 --- a/externals/kyuubi-flink-sql-engine/src/test/scala/org/apache/kyuubi/engine/flink/operation/FlinkOperationSuite.scala +++ b/externals/kyuubi-flink-sql-engine/src/test/scala/org/apache/kyuubi/engine/flink/operation/FlinkOperationSuite.scala @@ -19,7 +19,7 @@ package org.apache.kyuubi.engine.flink.operation import java.nio.file.Files import java.sql.DatabaseMetaData -import java.util.{Properties, UUID} +import java.util.UUID import scala.collection.JavaConverters._ @@ -34,7 +34,7 @@ import org.apache.kyuubi.engine.flink.FlinkEngineUtils._ import org.apache.kyuubi.engine.flink.WithFlinkSQLEngine import org.apache.kyuubi.engine.flink.result.Constants import org.apache.kyuubi.engine.flink.util.TestUserClassLoaderJar -import org.apache.kyuubi.jdbc.hive.{KyuubiConnection, KyuubiStatement} +import org.apache.kyuubi.jdbc.hive.KyuubiStatement import org.apache.kyuubi.operation.{HiveJDBCTestHelper, NoneMode} import org.apache.kyuubi.operation.meta.ResultSetSchemaConstant._ import org.apache.kyuubi.service.ServiceState._ @@ -977,14 +977,14 @@ class FlinkOperationSuite extends WithFlinkSQLEngine with HiveJDBCTestHelper { } test("get query id") { - val conn = new KyuubiConnection(jdbcUrl, new Properties()) - val stmt = conn.createStatement() - stmt.executeQuery("create table tbl_a (a int) with ('connector' = 'blackhole')") - assert(stmt.asInstanceOf[KyuubiStatement].getQueryId === null) - stmt.executeQuery("insert into tbl_a values (1)") - val queryId = stmt.asInstanceOf[KyuubiStatement].getQueryId - assert(queryId !== null) - // parse the string to check if it's valid Flink job id - assert(JobID.fromHexString(queryId) !== null) + withJdbcStatement("tbl_a") { stmt => + stmt.executeQuery("create table tbl_a (a int) with ('connector' = 'blackhole')") + assert(stmt.asInstanceOf[KyuubiStatement].getQueryId === null) + stmt.executeQuery("insert into tbl_a values (1)") + val queryId = stmt.asInstanceOf[KyuubiStatement].getQueryId + assert(queryId !== null) + // parse the string to check if it's valid Flink job id + assert(JobID.fromHexString(queryId) !== null) + } } }