You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2022/08/06 11:36:02 UTC
[shardingsphere] branch master updated: Refactor: remove useless util for further refactor (#19919)
This is an automated email from the ASF dual-hosted git repository.
zhonghongsheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 0116a7bfc65 Refactor: remove useless util for further refactor (#19919)
0116a7bfc65 is described below
commit 0116a7bfc650d2ad99ff6302cc31465e8d7d4456
Author: 孙念君 Nianjun Sun <su...@sphere-ex.com>
AuthorDate: Sat Aug 6 19:35:56 2022 +0800
Refactor: remove useless util for further refactor (#19919)
* Refactor: remove useless util for further refactor
* Refactor : rename a constant
---
.../transaction/engine/base/BaseITCase.java | 5 +-
.../proxy/ShardingSphereProxyDockerContainer.java | 5 +-
.../transaction/util/DatabaseTypeUtil.java | 56 ----------------------
.../util/TransactionTestCaseClassScanner.java | 6 +--
4 files changed, 8 insertions(+), 64 deletions(-)
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/base/BaseITCase.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/base/BaseITCase.java
index 08eb2eb79a6..b4eb3ffb17a 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/base/BaseITCase.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/engine/base/BaseITCase.java
@@ -41,7 +41,6 @@ import org.apache.shardingsphere.integration.transaction.framework.container.com
import org.apache.shardingsphere.integration.transaction.framework.container.compose.NativeComposedContainer;
import org.apache.shardingsphere.integration.transaction.framework.container.database.DatabaseContainer;
import org.apache.shardingsphere.integration.transaction.framework.param.TransactionParameterized;
-import org.apache.shardingsphere.integration.transaction.util.DatabaseTypeUtil;
import org.apache.shardingsphere.integration.transaction.util.TransactionTestCaseClassScanner;
import org.apache.shardingsphere.test.integration.env.runtime.DataSourceEnvironment;
import org.apache.shardingsphere.transaction.core.TransactionType;
@@ -351,11 +350,11 @@ public abstract class BaseITCase {
private String getProxyJdbcUrl(final DatabaseType databaseType) {
String defaultDatabaseName = "";
- if (DatabaseTypeUtil.isPostgreSQL(databaseType) || DatabaseTypeUtil.isOpenGauss(databaseType)) {
+ if (databaseType instanceof PostgreSQLDatabaseType || databaseType instanceof OpenGaussDatabaseType) {
defaultDatabaseName = "postgres";
}
String jdbcUrl = composedContainer.getProxyJdbcUrl(defaultDatabaseName);
- if (DatabaseTypeUtil.isPostgreSQL(databaseType) || DatabaseTypeUtil.isOpenGauss(databaseType)) {
+ if (databaseType instanceof PostgreSQLDatabaseType || databaseType instanceof OpenGaussDatabaseType) {
jdbcUrl = JDBC_URL_APPENDER.appendQueryProperties(jdbcUrl, getPostgreSQLQueryProperties());
}
return jdbcUrl;
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/container/proxy/ShardingSphereProxyDockerContainer.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/container/proxy/ShardingSphereProxyDockerContainer.java
index bbb283be4e2..fe80174e0bd 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/container/proxy/ShardingSphereProxyDockerContainer.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/framework/container/proxy/ShardingSphereProxyDockerContainer.java
@@ -19,7 +19,8 @@ package org.apache.shardingsphere.integration.transaction.framework.container.pr
import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.integration.transaction.util.DatabaseTypeUtil;
+import org.apache.shardingsphere.infra.database.type.dialect.OpenGaussDatabaseType;
+import org.apache.shardingsphere.infra.database.type.dialect.PostgreSQLDatabaseType;
import org.apache.shardingsphere.test.integration.env.container.atomic.DockerITContainer;
import org.apache.shardingsphere.test.integration.env.container.wait.JDBCConnectionWaitStrategy;
import org.apache.shardingsphere.test.integration.env.runtime.DataSourceEnvironment;
@@ -44,7 +45,7 @@ public final class ShardingSphereProxyDockerContainer extends DockerITContainer
protected void configure() {
withExposedPorts(3307);
mapConfigurationFiles();
- if (DatabaseTypeUtil.isPostgreSQL(databaseType) || DatabaseTypeUtil.isOpenGauss(databaseType)) {
+ if (databaseType instanceof PostgreSQLDatabaseType || databaseType instanceof OpenGaussDatabaseType) {
setWaitStrategy(new JDBCConnectionWaitStrategy(() -> DriverManager.getConnection(DataSourceEnvironment.getURL(databaseType, getHost(), getMappedPort(3307), "postgres"), "root", "root")));
} else {
setWaitStrategy(new JDBCConnectionWaitStrategy(() -> DriverManager.getConnection(DataSourceEnvironment.getURL(databaseType, getHost(), getMappedPort(3307), ""), "root", "root")));
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/util/DatabaseTypeUtil.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/util/DatabaseTypeUtil.java
deleted file mode 100644
index f39ec70fe5d..00000000000
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/util/DatabaseTypeUtil.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.integration.transaction.util;
-
-import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
-import org.apache.shardingsphere.infra.database.type.dialect.OpenGaussDatabaseType;
-import org.apache.shardingsphere.infra.database.type.dialect.PostgreSQLDatabaseType;
-
-public final class DatabaseTypeUtil {
-
- /**
- * Check MySQL database type.
- *
- * @param databaseType database type
- * @return true if database type is MySQL, false otherwise
- */
- public static boolean isMySQL(final DatabaseType databaseType) {
- return databaseType instanceof MySQLDatabaseType;
- }
-
- /**
- * Check PostgreSQL database type.
- *
- * @param databaseType database type
- * @return true if database type is PostgreSQL, false otherwise
- */
- public static boolean isPostgreSQL(final DatabaseType databaseType) {
- return databaseType instanceof PostgreSQLDatabaseType;
- }
-
- /**
- * Check openGauss database type.
- *
- * @param databaseType database type
- * @return true if database type is openGauss, false otherwise
- */
- public static boolean isOpenGauss(final DatabaseType databaseType) {
- return databaseType instanceof OpenGaussDatabaseType;
- }
-}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/util/TransactionTestCaseClassScanner.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/util/TransactionTestCaseClassScanner.java
index bb550878e2b..45cf8c80790 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/util/TransactionTestCaseClassScanner.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/util/TransactionTestCaseClassScanner.java
@@ -39,7 +39,7 @@ import java.util.jar.JarFile;
*/
public class TransactionTestCaseClassScanner {
- private static final String TEST_CASE_BASE_PACKAGE_NAME = "org.apache.shardingsphere.integration.transaction.cases";
+ private static final String TEST_CASE_PACKAGE_NAME = "org.apache.shardingsphere.integration.transaction.cases";
private static final List<File> FILES = new ArrayList<>();
@@ -52,7 +52,7 @@ public class TransactionTestCaseClassScanner {
*/
@SneakyThrows
public static List<Class<? extends BaseTransactionTestCase>> scan() {
- final Enumeration<URL> urls = Thread.currentThread().getContextClassLoader().getResources(TEST_CASE_BASE_PACKAGE_NAME.replace(".", File.separator));
+ final Enumeration<URL> urls = Thread.currentThread().getContextClassLoader().getResources(TEST_CASE_PACKAGE_NAME.replace(".", File.separator));
return scanURL(urls);
}
@@ -95,7 +95,7 @@ public class TransactionTestCaseClassScanner {
while (jarEntryEnumeration.hasMoreElements()) {
JarEntry entry = jarEntryEnumeration.nextElement();
String jarEntryName = entry.getName();
- if (jarEntryName.contains(CLASS_SYMBOL) && jarEntryName.replace("/", ".").startsWith(TEST_CASE_BASE_PACKAGE_NAME)) {
+ if (jarEntryName.contains(CLASS_SYMBOL) && jarEntryName.replace("/", ".").startsWith(TEST_CASE_PACKAGE_NAME)) {
String className = jarEntryName.substring(0, jarEntryName.lastIndexOf(".")).replace("/", ".");
Class<?> clazz = Class.forName(className);
if (clazz.isAssignableFrom(BaseTransactionTestCase.class)) {