This is an automated email from the ASF dual-hosted git repository. peacewong pushed a commit to branch dev-1.2.0 in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git
commit b31f47688236803397dfe71113fe762179c20404 Author: CCweixiao <[email protected]> AuthorDate: Fri May 27 20:26:33 2022 +0800 [feture-2140] Use h2 to improve test cases. --- .../manager/engineplugin/jdbc/ConnectionManager.java | 4 ++-- .../engineplugin/jdbc/conf/JDBCConfiguration.scala | 4 ++-- .../manager/engineplugin/jdbc/ConnectionManagerTest.java | 16 +++++++++------- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/linkis-engineconn-plugins/engineconn-plugins/jdbc/src/main/java/org/apache/linkis/manager/engineplugin/jdbc/ConnectionManager.java b/linkis-engineconn-plugins/engineconn-plugins/jdbc/src/main/java/org/apache/linkis/manager/engineplugin/jdbc/ConnectionManager.java index 60d54188f..95e2cc47b 100644 --- a/linkis-engineconn-plugins/engineconn-plugins/jdbc/src/main/java/org/apache/linkis/manager/engineplugin/jdbc/ConnectionManager.java +++ b/linkis-engineconn-plugins/engineconn-plugins/jdbc/src/main/java/org/apache/linkis/manager/engineplugin/jdbc/ConnectionManager.java @@ -103,7 +103,7 @@ public class ConnectionManager { if (StringUtils.isEmpty(url)) { throw new NullPointerException(JDBCEngineConnConstant.JDBC_URL + " cannot be null."); } - if (!url.matches("jdbc:\\w+://\\S+:[0-9]{2,6}(/\\S*)?")) { + if (!url.matches("jdbc:\\w+://\\S+:[0-9]{2,6}(/\\S*)?") && !url.startsWith("jdbc:h2")) { throw new IllegalArgumentException("Unknown the jdbc url: " + url); } for (String supportedDBName : supportedDBNames) { @@ -180,7 +180,7 @@ public class ConnectionManager { public Connection getConnection(Map<String, String> properties) throws SQLException { String url = getJdbcUrl(properties); - logger.info("jdbc is {}", url); + logger.info("The jdbc url is: {}", url); JdbcAuthType jdbcAuthType = getJdbcAuthType(properties); Connection connection = null; switch (jdbcAuthType) { diff --git a/linkis-engineconn-plugins/engineconn-plugins/jdbc/src/main/scala/org/apache/linkis/manager/engineplugin/jdbc/conf/JDBCConfiguration.scala b/linkis-engineconn-plugins/engineconn-plugins/jdbc/src/main/scala/org/apache/linkis/manager/engineplugin/jdbc/conf/JDBCConfiguration.scala index 900b2e460..8a7411def 100644 --- a/linkis-engineconn-plugins/engineconn-plugins/jdbc/src/main/scala/org/apache/linkis/manager/engineplugin/jdbc/conf/JDBCConfiguration.scala +++ b/linkis-engineconn-plugins/engineconn-plugins/jdbc/src/main/scala/org/apache/linkis/manager/engineplugin/jdbc/conf/JDBCConfiguration.scala @@ -27,9 +27,9 @@ object JDBCConfiguration { val JDBC_QUERY_TIMEOUT = CommonVars("wds.linkis.jdbc.query.timeout", 1800) - val JDBC_SUPPORT_DBS = CommonVars("wds.linkis.jdbc.support.dbs", "mysql=>com.mysql.jdbc.Driver,postgresql=>org.postgresql.Driver,oracle=>oracle.jdbc.driver.OracleDriver,hive2=>org.apache.hive.jdbc.HiveDriver,presto=>com.facebook.presto.jdbc.PrestoDriver,clickhouse=>ru.yandex.clickhouse.ClickHouseDriver") + val JDBC_SUPPORT_DBS = CommonVars("wds.linkis.jdbc.support.dbs", "h2=>org.h2.Driver,mysql=>com.mysql.jdbc.Driver,postgresql=>org.postgresql.Driver,oracle=>oracle.jdbc.driver.OracleDriver,hive2=>org.apache.hive.jdbc.HiveDriver,presto=>com.facebook.presto.jdbc.PrestoDriver,clickhouse=>ru.yandex.clickhouse.ClickHouseDriver") - val JDBC_SUPPORT_DBS_VALIDATION_QUERY = CommonVars("wds.linkis.jdbc.support.dbs.validation.query", "mysql=>SELECT 1,postgresql=>SELECT 1,oracle=>SELECT 1 FROM dual,hive2=>SELECT 1,presto=>SELECT 1") + val JDBC_SUPPORT_DBS_VALIDATION_QUERY = CommonVars("wds.linkis.jdbc.support.dbs.validation.query", "h2=>SELECT 1,mysql=>SELECT 1,postgresql=>SELECT 1,oracle=>SELECT 1 FROM dual,hive2=>SELECT 1,presto=>SELECT 1") val JDBC_CONCURRENT_LIMIT = CommonVars[Int]("wds.linkis.engineconn.jdbc.concurrent.limit", 100) diff --git a/linkis-engineconn-plugins/engineconn-plugins/jdbc/src/test/java/org/apache/linkis/manager/engineplugin/jdbc/ConnectionManagerTest.java b/linkis-engineconn-plugins/engineconn-plugins/jdbc/src/test/java/org/apache/linkis/manager/engineplugin/jdbc/ConnectionManagerTest.java index d26f8ba06..811b633ce 100644 --- a/linkis-engineconn-plugins/engineconn-plugins/jdbc/src/test/java/org/apache/linkis/manager/engineplugin/jdbc/ConnectionManagerTest.java +++ b/linkis-engineconn-plugins/engineconn-plugins/jdbc/src/test/java/org/apache/linkis/manager/engineplugin/jdbc/ConnectionManagerTest.java @@ -38,9 +38,11 @@ public class ConnectionManagerTest { @DisplayName("testCreateJdbcConnAndExecSql") public void testCreateJdbcConnAndExecSql() throws SQLException { Map<String, String> properties = new HashMap<>(8); - properties.put(JDBCEngineConnConstant.JDBC_URL, "jdbc:mysql://dev:3306/db?useSSL=false"); - properties.put(JDBCEngineConnConstant.JDBC_USERNAME, "leo"); - properties.put(JDBCEngineConnConstant.JDBC_PASSWORD, "Yyf5211314!"); + properties.put( + JDBCEngineConnConstant.JDBC_URL, + "jdbc:h2:mem:linkis_db;MODE=MySQL;DATABASE_TO_LOWER=TRUE"); + properties.put(JDBCEngineConnConstant.JDBC_USERNAME, "user"); + properties.put(JDBCEngineConnConstant.JDBC_PASSWORD, "password"); properties.put(JDBCEngineConnConstant.JDBC_AUTH_TYPE, "USERNAME"); properties.put(JDBCEngineConnConstant.JDBC_KERBEROS_AUTH_TYPE_PRINCIPAL, ""); properties.put(JDBCEngineConnConstant.JDBC_KERBEROS_AUTH_TYPE_KEYTAB_LOCATION, ""); @@ -62,10 +64,10 @@ public class ConnectionManagerTest { @DisplayName("testExecSql") public void testExecSql() throws Exception { Properties properties = new Properties(); - properties.put("driverClassName", "com.mysql.jdbc.Driver"); - properties.put("url", "jdbc:mysql://dev:3306/db?useSSL=false"); - properties.put("username", "leo"); - properties.put("password", "Yyf5211314!"); + properties.put("driverClassName", "org.h2.Driver"); + properties.put("url", "jdbc:h2:mem:linkis_db;MODE=MySQL;DATABASE_TO_LOWER=TRUE"); + properties.put("username", "user"); + properties.put("password", "password"); properties.put("maxIdle", 20); properties.put("minIdle", 0); properties.put("initialSize", 1); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
