This is an automated email from the ASF dual-hosted git repository.

panjuan 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 13fcc8359c7 Refactor : refactor the duplicated util(#19957) (#19962)
13fcc8359c7 is described below

commit 13fcc8359c734fce274430cc1789b7d84fedf729
Author: 孙念君 Nianjun Sun <[email protected]>
AuthorDate: Mon Aug 8 13:38:24 2022 +0800

    Refactor : refactor the duplicated util(#19957) (#19962)
---
 .../integration/env/container/atomic}/util/DatabaseTypeUtil.java   | 4 ++--
 .../integration/data/pipeline/cases/base/BaseExtraSQLITCase.java   | 2 +-
 .../integration/data/pipeline/cases/base/BaseITCase.java           | 2 +-
 .../container/proxy/ShardingSphereProxyDockerContainer.java        | 2 +-
 .../integration/transaction/engine/base/BaseITCase.java            | 7 ++++---
 .../integration/transaction/env/IntegrationTestEnvironment.java    | 6 +++---
 .../container/proxy/ShardingSphereProxyDockerContainer.java        | 5 ++---
 7 files changed, 14 insertions(+), 14 deletions(-)

diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/util/DatabaseTypeUtil.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/util/DatabaseTypeUtil.java
similarity index 97%
rename from 
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/util/DatabaseTypeUtil.java
rename to 
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/util/DatabaseTypeUtil.java
index 3038e72c69c..26d827bae2f 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/util/DatabaseTypeUtil.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-env/src/test/java/org/apache/shardingsphere/test/integration/env/container/atomic/util/DatabaseTypeUtil.java
@@ -15,13 +15,13 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.integration.data.pipeline.util;
+package org.apache.shardingsphere.test.integration.env.container.atomic.util;
 
+import org.apache.commons.lang.StringUtils;
 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;
-import org.apache.commons.lang.StringUtils;
 
 public final class DatabaseTypeUtil {
     
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/base/BaseExtraSQLITCase.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/base/BaseExtraSQLITCase.java
index e6fff8bbb0f..2e11753be6f 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/base/BaseExtraSQLITCase.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/base/BaseExtraSQLITCase.java
@@ -21,7 +21,7 @@ import lombok.Getter;
 import lombok.extern.slf4j.Slf4j;
 import 
org.apache.shardingsphere.integration.data.pipeline.cases.command.ExtraSQLCommand;
 import 
org.apache.shardingsphere.integration.data.pipeline.framework.param.ScalingParameterized;
-import 
org.apache.shardingsphere.integration.data.pipeline.util.DatabaseTypeUtil;
+import 
org.apache.shardingsphere.test.integration.env.container.atomic.util.DatabaseTypeUtil;
 
 import javax.xml.bind.JAXB;
 import java.util.Objects;
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/base/BaseITCase.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/base/BaseITCase.java
index 71fccbc6bde..bf0095f07e9 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/base/BaseITCase.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/base/BaseITCase.java
@@ -38,8 +38,8 @@ import 
org.apache.shardingsphere.integration.data.pipeline.framework.container.c
 import 
org.apache.shardingsphere.integration.data.pipeline.framework.container.compose.NativeComposedContainer;
 import 
org.apache.shardingsphere.integration.data.pipeline.framework.param.ScalingParameterized;
 import 
org.apache.shardingsphere.integration.data.pipeline.framework.watcher.ScalingWatcher;
-import 
org.apache.shardingsphere.integration.data.pipeline.util.DatabaseTypeUtil;
 import 
org.apache.shardingsphere.test.integration.env.container.atomic.storage.DockerStorageContainer;
+import 
org.apache.shardingsphere.test.integration.env.container.atomic.util.DatabaseTypeUtil;
 import 
org.apache.shardingsphere.test.integration.env.runtime.DataSourceEnvironment;
 import org.junit.Rule;
 import org.opengauss.util.PSQLException;
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/framework/container/proxy/ShardingSphereProxyDockerContainer.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/framework/container/proxy/ShardingSphereProxyDockerContainer.java
index 7f2b2aacf19..7f0491b8cc2 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/framework/container/proxy/ShardingSphereProxyDockerContainer.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/framework/container/proxy/ShardingSphereProxyDockerContainer.java
@@ -19,8 +19,8 @@ package 
org.apache.shardingsphere.integration.data.pipeline.framework.container.
 
 import lombok.extern.slf4j.Slf4j;
 import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import 
org.apache.shardingsphere.integration.data.pipeline.util.DatabaseTypeUtil;
 import 
org.apache.shardingsphere.test.integration.env.container.atomic.DockerITContainer;
+import 
org.apache.shardingsphere.test.integration.env.container.atomic.util.DatabaseTypeUtil;
 import 
org.apache.shardingsphere.test.integration.env.container.wait.JDBCConnectionWaitStrategy;
 import 
org.apache.shardingsphere.test.integration.env.runtime.DataSourceEnvironment;
 import org.testcontainers.containers.BindMode;
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 b4eb3ffb17a..e1d532b1da5 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
@@ -42,6 +42,7 @@ import 
org.apache.shardingsphere.integration.transaction.framework.container.com
 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.TransactionTestCaseClassScanner;
+import 
org.apache.shardingsphere.test.integration.env.container.atomic.util.DatabaseTypeUtil;
 import 
org.apache.shardingsphere.test.integration.env.runtime.DataSourceEnvironment;
 import org.apache.shardingsphere.transaction.core.TransactionType;
 
@@ -350,11 +351,11 @@ public abstract class BaseITCase {
     
     private String getProxyJdbcUrl(final DatabaseType databaseType) {
         String defaultDatabaseName = "";
-        if (databaseType instanceof PostgreSQLDatabaseType || databaseType 
instanceof OpenGaussDatabaseType) {
+        if (DatabaseTypeUtil.isPostgreSQL(databaseType) || 
DatabaseTypeUtil.isOpenGauss(databaseType)) {
             defaultDatabaseName = "postgres";
         }
         String jdbcUrl = 
composedContainer.getProxyJdbcUrl(defaultDatabaseName);
-        if (databaseType instanceof PostgreSQLDatabaseType || databaseType 
instanceof OpenGaussDatabaseType) {
+        if (DatabaseTypeUtil.isPostgreSQL(databaseType) || 
DatabaseTypeUtil.isOpenGauss(databaseType)) {
             jdbcUrl = JDBC_URL_APPENDER.appendQueryProperties(jdbcUrl, 
getPostgreSQLQueryProperties());
         }
         return jdbcUrl;
@@ -382,7 +383,7 @@ public abstract class BaseITCase {
     
     @SneakyThrows
     protected void addResources() {
-        if (databaseType instanceof MySQLDatabaseType) {
+        if (DatabaseTypeUtil.isMySQL(databaseType)) {
             try (Connection connection = 
DriverManager.getConnection(getComposedContainer().getProxyJdbcUrl(""), 
ENV.getProxyUserName(), ENV.getProxyPassword())) {
                 executeWithLog(connection, "USE sharding_db");
                 addResources(connection);
diff --git 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/env/IntegrationTestEnvironment.java
 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/env/IntegrationTestEnvironment.java
index c79adfdb684..c019390cd69 100644
--- 
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/env/IntegrationTestEnvironment.java
+++ 
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/env/IntegrationTestEnvironment.java
@@ -21,10 +21,10 @@ import lombok.Getter;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import 
org.apache.shardingsphere.infra.database.type.dialect.OpenGaussDatabaseType;
 import 
org.apache.shardingsphere.integration.transaction.engine.entity.JdbcInfoEntity;
 import 
org.apache.shardingsphere.integration.transaction.env.enums.TransactionITEnvTypeEnum;
 import 
org.apache.shardingsphere.integration.transaction.env.enums.TransactionTestCaseRegistry;
+import 
org.apache.shardingsphere.test.integration.env.container.atomic.util.DatabaseTypeUtil;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -166,7 +166,7 @@ public final class IntegrationTestEnvironment {
      */
     public String getActualDataSourceUsername(final DatabaseType databaseType) 
{
         String username;
-        if (databaseType instanceof OpenGaussDatabaseType) {
+        if (DatabaseTypeUtil.isOpenGauss(databaseType)) {
             username = "gaussdb";
         } else {
             username = "root";
@@ -185,7 +185,7 @@ public final class IntegrationTestEnvironment {
      */
     public String getActualDataSourcePassword(final DatabaseType databaseType) 
{
         String password;
-        if (databaseType instanceof OpenGaussDatabaseType) {
+        if (DatabaseTypeUtil.isOpenGauss(databaseType)) {
             password = "Root@123";
         } else {
             password = "root";
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 fe80174e0bd..578ae200da7 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,9 +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.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.atomic.util.DatabaseTypeUtil;
 import 
org.apache.shardingsphere.test.integration.env.container.wait.JDBCConnectionWaitStrategy;
 import 
org.apache.shardingsphere.test.integration.env.runtime.DataSourceEnvironment;
 import org.testcontainers.containers.BindMode;
@@ -45,7 +44,7 @@ public final class ShardingSphereProxyDockerContainer extends 
DockerITContainer
     protected void configure() {
         withExposedPorts(3307);
         mapConfigurationFiles();
-        if (databaseType instanceof PostgreSQLDatabaseType || databaseType 
instanceof OpenGaussDatabaseType) {
+        if (DatabaseTypeUtil.isPostgreSQL(databaseType) || 
DatabaseTypeUtil.isOpenGauss(databaseType)) {
             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")));

Reply via email to