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 38d535bba72 Fix sonar issues (#29454)
38d535bba72 is described below
commit 38d535bba72c9f14e9dd49d4710ff13ce0412a09
Author: Liang Zhang <[email protected]>
AuthorDate: Tue Dec 19 20:11:11 2023 +0800
Fix sonar issues (#29454)
---
.../metadata/database/enums/QuoteCharacter.java | 2 +-
.../type/TcClickHouseDatabaseType.java | 2 +-
.../testcontainers/type/TcMariaDBDatabaseType.java | 2 +-
.../testcontainers/type/TcMySQLDatabaseType.java | 2 +-
.../testcontainers/type/TcOracleDatabaseType.java | 2 +-
.../type/TcPostgreSQLDatabaseType.java | 2 +-
.../type/TcSQLServerDatabaseType.java | 2 +-
...seType.java => TestcontainersDatabaseType.java} | 2 +-
.../kernel/category/ConnectionSQLException.java | 2 +-
.../interval/IntervalInlineExpressionParser.java | 2 +-
.../IntervalInlineExpressionParserTest.java | 2 +-
.../JobConfigurationChangedProcessEngine.java | 2 +-
...ingCommonTest.java => TestShardingService.java} | 22 ++++++++++++--------
.../natived/jdbc/databases/MSSQLServerTest.java | 24 +++++++++++-----------
.../test/natived/jdbc/databases/MySQLTest.java | 24 +++++++++++-----------
.../test/natived/jdbc/databases/OpenGaussTest.java | 24 +++++++++++-----------
.../test/natived/jdbc/databases/PostgresTest.java | 24 +++++++++++-----------
.../test/natived/jdbc/features/ShardingTest.java | 22 ++++++++++----------
18 files changed, 84 insertions(+), 80 deletions(-)
diff --git
a/infra/database/core/src/main/java/org/apache/shardingsphere/infra/database/core/metadata/database/enums/QuoteCharacter.java
b/infra/database/core/src/main/java/org/apache/shardingsphere/infra/database/core/metadata/database/enums/QuoteCharacter.java
index 5e8593c88c9..84ebc2de64a 100644
---
a/infra/database/core/src/main/java/org/apache/shardingsphere/infra/database/core/metadata/database/enums/QuoteCharacter.java
+++
b/infra/database/core/src/main/java/org/apache/shardingsphere/infra/database/core/metadata/database/enums/QuoteCharacter.java
@@ -47,7 +47,7 @@ public enum QuoteCharacter {
static {
for (QuoteCharacter each : values()) {
- if (each.equals(NONE)) {
+ if (NONE == each) {
continue;
}
BY_FIRST_CHAR.put(each.startDelimiter.charAt(0), each);
diff --git
a/infra/database/type/testcontainers/src/main/java/org/apache/shardingsphere/infra/database/testcontainers/type/TcClickHouseDatabaseType.java
b/infra/database/type/testcontainers/src/main/java/org/apache/shardingsphere/infra/database/testcontainers/type/TcClickHouseDatabaseType.java
index 77f6ab97d6c..66dc84eb864 100644
---
a/infra/database/type/testcontainers/src/main/java/org/apache/shardingsphere/infra/database/testcontainers/type/TcClickHouseDatabaseType.java
+++
b/infra/database/type/testcontainers/src/main/java/org/apache/shardingsphere/infra/database/testcontainers/type/TcClickHouseDatabaseType.java
@@ -27,7 +27,7 @@ import java.util.Optional;
/**
* Database type of ClickHouse in testcontainers-java.
*/
-public final class TcClickHouseDatabaseType extends
AbstractTestcontainersDatabaseType {
+public final class TcClickHouseDatabaseType implements
TestcontainersDatabaseType {
@Override
public Collection<String> getJdbcUrlPrefixes() {
diff --git
a/infra/database/type/testcontainers/src/main/java/org/apache/shardingsphere/infra/database/testcontainers/type/TcMariaDBDatabaseType.java
b/infra/database/type/testcontainers/src/main/java/org/apache/shardingsphere/infra/database/testcontainers/type/TcMariaDBDatabaseType.java
index 36bf2f124b3..4b867c1ef01 100644
---
a/infra/database/type/testcontainers/src/main/java/org/apache/shardingsphere/infra/database/testcontainers/type/TcMariaDBDatabaseType.java
+++
b/infra/database/type/testcontainers/src/main/java/org/apache/shardingsphere/infra/database/testcontainers/type/TcMariaDBDatabaseType.java
@@ -27,7 +27,7 @@ import java.util.Optional;
/**
* Database type of MariaDB in testcontainers-java.
*/
-public final class TcMariaDBDatabaseType extends
AbstractTestcontainersDatabaseType {
+public final class TcMariaDBDatabaseType implements TestcontainersDatabaseType
{
@Override
public Collection<String> getJdbcUrlPrefixes() {
diff --git
a/infra/database/type/testcontainers/src/main/java/org/apache/shardingsphere/infra/database/testcontainers/type/TcMySQLDatabaseType.java
b/infra/database/type/testcontainers/src/main/java/org/apache/shardingsphere/infra/database/testcontainers/type/TcMySQLDatabaseType.java
index c19545a69ea..793ef28af63 100644
---
a/infra/database/type/testcontainers/src/main/java/org/apache/shardingsphere/infra/database/testcontainers/type/TcMySQLDatabaseType.java
+++
b/infra/database/type/testcontainers/src/main/java/org/apache/shardingsphere/infra/database/testcontainers/type/TcMySQLDatabaseType.java
@@ -27,7 +27,7 @@ import java.util.Optional;
/**
* Database type of MySQL in testcontainers-java.
*/
-public final class TcMySQLDatabaseType extends
AbstractTestcontainersDatabaseType {
+public final class TcMySQLDatabaseType implements TestcontainersDatabaseType {
@Override
public Collection<String> getJdbcUrlPrefixes() {
diff --git
a/infra/database/type/testcontainers/src/main/java/org/apache/shardingsphere/infra/database/testcontainers/type/TcOracleDatabaseType.java
b/infra/database/type/testcontainers/src/main/java/org/apache/shardingsphere/infra/database/testcontainers/type/TcOracleDatabaseType.java
index d5169f1d885..0201750f3a8 100644
---
a/infra/database/type/testcontainers/src/main/java/org/apache/shardingsphere/infra/database/testcontainers/type/TcOracleDatabaseType.java
+++
b/infra/database/type/testcontainers/src/main/java/org/apache/shardingsphere/infra/database/testcontainers/type/TcOracleDatabaseType.java
@@ -27,7 +27,7 @@ import java.util.Optional;
/**
* Database type of Oracle in testcontainers-java.
*/
-public final class TcOracleDatabaseType extends
AbstractTestcontainersDatabaseType {
+public final class TcOracleDatabaseType implements TestcontainersDatabaseType {
@Override
public Collection<String> getJdbcUrlPrefixes() {
diff --git
a/infra/database/type/testcontainers/src/main/java/org/apache/shardingsphere/infra/database/testcontainers/type/TcPostgreSQLDatabaseType.java
b/infra/database/type/testcontainers/src/main/java/org/apache/shardingsphere/infra/database/testcontainers/type/TcPostgreSQLDatabaseType.java
index d9136e6fb06..c4eba7a2b78 100644
---
a/infra/database/type/testcontainers/src/main/java/org/apache/shardingsphere/infra/database/testcontainers/type/TcPostgreSQLDatabaseType.java
+++
b/infra/database/type/testcontainers/src/main/java/org/apache/shardingsphere/infra/database/testcontainers/type/TcPostgreSQLDatabaseType.java
@@ -27,7 +27,7 @@ import java.util.Optional;
/**
* Database type of PostgreSQL in testcontainers-java.
*/
-public final class TcPostgreSQLDatabaseType extends
AbstractTestcontainersDatabaseType {
+public final class TcPostgreSQLDatabaseType implements
TestcontainersDatabaseType {
@Override
public Collection<String> getJdbcUrlPrefixes() {
diff --git
a/infra/database/type/testcontainers/src/main/java/org/apache/shardingsphere/infra/database/testcontainers/type/TcSQLServerDatabaseType.java
b/infra/database/type/testcontainers/src/main/java/org/apache/shardingsphere/infra/database/testcontainers/type/TcSQLServerDatabaseType.java
index 92049f5b30e..d67f9417fc4 100644
---
a/infra/database/type/testcontainers/src/main/java/org/apache/shardingsphere/infra/database/testcontainers/type/TcSQLServerDatabaseType.java
+++
b/infra/database/type/testcontainers/src/main/java/org/apache/shardingsphere/infra/database/testcontainers/type/TcSQLServerDatabaseType.java
@@ -27,7 +27,7 @@ import java.util.Optional;
/**
* Database type of MSSQL Server in testcontainers-java.
*/
-public final class TcSQLServerDatabaseType extends
AbstractTestcontainersDatabaseType {
+public final class TcSQLServerDatabaseType implements
TestcontainersDatabaseType {
@Override
public Collection<String> getJdbcUrlPrefixes() {
diff --git
a/infra/database/type/testcontainers/src/main/java/org/apache/shardingsphere/infra/database/testcontainers/type/AbstractTestcontainersDatabaseType.java
b/infra/database/type/testcontainers/src/main/java/org/apache/shardingsphere/infra/database/testcontainers/type/TestcontainersDatabaseType.java
similarity index 92%
rename from
infra/database/type/testcontainers/src/main/java/org/apache/shardingsphere/infra/database/testcontainers/type/AbstractTestcontainersDatabaseType.java
rename to
infra/database/type/testcontainers/src/main/java/org/apache/shardingsphere/infra/database/testcontainers/type/TestcontainersDatabaseType.java
index 328f3cbf911..0b6e496c545 100644
---
a/infra/database/type/testcontainers/src/main/java/org/apache/shardingsphere/infra/database/testcontainers/type/AbstractTestcontainersDatabaseType.java
+++
b/infra/database/type/testcontainers/src/main/java/org/apache/shardingsphere/infra/database/testcontainers/type/TestcontainersDatabaseType.java
@@ -23,5 +23,5 @@ import
org.apache.shardingsphere.infra.database.core.type.DatabaseType;
* Abstract Database type in testcontainers-java.
* All jdbcUrl prefixes supported by testcontainers-java should extend this
class.
*/
-public abstract class AbstractTestcontainersDatabaseType implements
DatabaseType {
+public interface TestcontainersDatabaseType extends DatabaseType {
}
diff --git
a/infra/exception/core/src/main/java/org/apache/shardingsphere/infra/exception/core/external/sql/type/kernel/category/ConnectionSQLException.java
b/infra/exception/core/src/main/java/org/apache/shardingsphere/infra/exception/core/external/sql/type/kernel/category/ConnectionSQLException.java
index 946adb49ada..dd08c471986 100644
---
a/infra/exception/core/src/main/java/org/apache/shardingsphere/infra/exception/core/external/sql/type/kernel/category/ConnectionSQLException.java
+++
b/infra/exception/core/src/main/java/org/apache/shardingsphere/infra/exception/core/external/sql/type/kernel/category/ConnectionSQLException.java
@@ -33,7 +33,7 @@ public abstract class ConnectionSQLException extends
KernelSQLException {
super(sqlState, KERNEL_CODE, errorCode, reason, messageArgs);
}
- public ConnectionSQLException(final SQLState sqlState, final int
errorCode, final String reason, final Exception cause) {
+ protected ConnectionSQLException(final SQLState sqlState, final int
errorCode, final String reason, final Exception cause) {
super(sqlState, KERNEL_CODE, errorCode, reason, cause);
}
}
diff --git
a/infra/expr/type/interval/src/main/java/org/apache/shardingsphere/infra/expr/interval/IntervalInlineExpressionParser.java
b/infra/expr/type/interval/src/main/java/org/apache/shardingsphere/infra/expr/interval/IntervalInlineExpressionParser.java
index 3f80d1cf80e..70db4398ec4 100644
---
a/infra/expr/type/interval/src/main/java/org/apache/shardingsphere/infra/expr/interval/IntervalInlineExpressionParser.java
+++
b/infra/expr/type/interval/src/main/java/org/apache/shardingsphere/infra/expr/interval/IntervalInlineExpressionParser.java
@@ -208,7 +208,7 @@ public class IntervalInlineExpressionParser implements
InlineExpressionParser {
Month startTimeAsMonth = startTime.query(Month::from);
Month endTimeAsMonth = endTime.query(Month::from);
return LongStream.iterate(0, x -> x + stepAmount)
- .limit((endTimeAsMonth.getValue() -
startTimeAsMonth.getValue()) / stepAmount + 1)
+ .limit((endTimeAsMonth.getValue() -
startTimeAsMonth.getValue()) / stepAmount + 1L)
.parallel()
.boxed()
.map(startTimeAsMonth::plus)
diff --git
a/infra/expr/type/interval/src/test/java/org/apache/shardingsphere/infra/expr/interval/IntervalInlineExpressionParserTest.java
b/infra/expr/type/interval/src/test/java/org/apache/shardingsphere/infra/expr/interval/IntervalInlineExpressionParserTest.java
index 01758a4a748..ae3963405ff 100644
---
a/infra/expr/type/interval/src/test/java/org/apache/shardingsphere/infra/expr/interval/IntervalInlineExpressionParserTest.java
+++
b/infra/expr/type/interval/src/test/java/org/apache/shardingsphere/infra/expr/interval/IntervalInlineExpressionParserTest.java
@@ -30,7 +30,7 @@ import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
-public class IntervalInlineExpressionParserTest {
+class IntervalInlineExpressionParserTest {
@Test
void assertEvaluateForSimple() {
diff --git
a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/metadata/node/config/processor/JobConfigurationChangedProcessEngine.java
b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/metadata/node/config/processor/JobConfigurationChangedProcessEngine.java
index 1422aed41dd..d606e05c896 100644
---
a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/metadata/node/config/processor/JobConfigurationChangedProcessEngine.java
+++
b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/metadata/node/config/processor/JobConfigurationChangedProcessEngine.java
@@ -45,7 +45,6 @@ public final class JobConfigurationChangedProcessEngine {
*/
@SuppressWarnings("unchecked")
public <T extends PipelineJobConfiguration> void process(final Type
eventType, final JobConfiguration jobConfig, final
JobConfigurationChangedProcessor<T> processor) {
- T pipelineJobConfig = (T)
PipelineJobIdUtils.parseJobType(jobConfig.getJobName()).getYamlJobConfigurationSwapper().swapToObject(jobConfig.getJobParameter());
String jobId = jobConfig.getJobName();
if (jobConfig.isDisabled()) {
PipelineJobRegistry.stop(jobId);
@@ -58,6 +57,7 @@ public final class JobConfigurationChangedProcessEngine {
if (PipelineJobRegistry.isExisting(jobId)) {
log.info("{} added to executing jobs failed since it
already exists", jobId);
} else {
+ T pipelineJobConfig = (T)
PipelineJobIdUtils.parseJobType(jobConfig.getJobName()).getYamlJobConfigurationSwapper().swapToObject(jobConfig.getJobParameter());
executeJob(jobConfig, pipelineJobConfig, processor);
}
break;
diff --git
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/commons/AbstractShardingCommonTest.java
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/commons/TestShardingService.java
similarity index 93%
rename from
test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/commons/AbstractShardingCommonTest.java
rename to
test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/commons/TestShardingService.java
index 7b4d989ad05..501c19efdcb 100644
---
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/commons/AbstractShardingCommonTest.java
+++
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/commons/TestShardingService.java
@@ -38,7 +38,7 @@ import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
@Getter
-public class AbstractShardingCommonTest {
+public final class TestShardingService {
private final OrderRepository orderRepository;
@@ -46,14 +46,15 @@ public class AbstractShardingCommonTest {
private final AddressRepository addressRepository;
- public AbstractShardingCommonTest(final DataSource dataSource) {
- this.orderRepository = new OrderRepository(dataSource);
- this.orderItemRepository = new OrderItemRepository(dataSource);
- this.addressRepository = new AddressRepository(dataSource);
+ public TestShardingService(final DataSource dataSource) {
+ orderRepository = new OrderRepository(dataSource);
+ orderItemRepository = new OrderItemRepository(dataSource);
+ addressRepository = new AddressRepository(dataSource);
}
/**
- * process success.
+ * Process success.
+ *
* @throws SQLException An exception that provides information on a
database access error or other errors.
*/
public void processSuccess() throws SQLException {
@@ -83,7 +84,8 @@ public class AbstractShardingCommonTest {
}
/**
- * insert data.
+ * Insert data.
+ *
* @return orderId of the insert statement.
* @throws SQLException An exception that provides information on a
database access error or other errors.
*/
@@ -110,7 +112,8 @@ public class AbstractShardingCommonTest {
}
/**
- * delete data.
+ * Delete data.
+ *
* @param orderIds orderId of the insert statement.
* @throws SQLException An exception that provides information on a
database access error or other errors.
*/
@@ -124,7 +127,8 @@ public class AbstractShardingCommonTest {
}
/**
- * clean environment.
+ * Clean environment.
+ *
* @throws SQLException An exception that provides information on a
database access error or other errors.
*/
public void cleanEnvironment() throws SQLException {
diff --git
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/MSSQLServerTest.java
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/MSSQLServerTest.java
index f9d874e33c0..bf2f8ea9707 100644
---
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/MSSQLServerTest.java
+++
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/MSSQLServerTest.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.test.natived.jdbc.databases;
import
org.apache.shardingsphere.driver.api.yaml.YamlShardingSphereDataSourceFactory;
-import
org.apache.shardingsphere.test.natived.jdbc.commons.AbstractShardingCommonTest;
+import org.apache.shardingsphere.test.natived.jdbc.commons.TestShardingService;
import org.apache.shardingsphere.test.natived.jdbc.commons.FileTestUtils;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledInNativeImage;
@@ -27,26 +27,26 @@ import javax.sql.DataSource;
import java.io.IOException;
import java.sql.SQLException;
-public class MSSQLServerTest {
+class MSSQLServerTest {
- private AbstractShardingCommonTest abstractShardingCommonTest;
+ private TestShardingService testShardingService;
@Test
@EnabledInNativeImage
void assertShardingInLocalTransactions() throws SQLException, IOException {
DataSource dataSource =
YamlShardingSphereDataSourceFactory.createDataSource(FileTestUtils.readFromFileURLString("test-native/yaml/databases/mssqlserver.yaml"));
- abstractShardingCommonTest = new
AbstractShardingCommonTest(dataSource);
+ testShardingService = new TestShardingService(dataSource);
this.initEnvironment();
- abstractShardingCommonTest.processSuccess();
- abstractShardingCommonTest.cleanEnvironment();
+ testShardingService.processSuccess();
+ testShardingService.cleanEnvironment();
}
private void initEnvironment() throws SQLException {
-
abstractShardingCommonTest.getOrderRepository().createTableInSQLServer();
-
abstractShardingCommonTest.getOrderItemRepository().createTableInSQLServer();
-
abstractShardingCommonTest.getAddressRepository().createTableInSQLServer();
- abstractShardingCommonTest.getOrderRepository().truncateTable();
- abstractShardingCommonTest.getOrderItemRepository().truncateTable();
- abstractShardingCommonTest.getAddressRepository().truncateTable();
+ testShardingService.getOrderRepository().createTableInSQLServer();
+ testShardingService.getOrderItemRepository().createTableInSQLServer();
+ testShardingService.getAddressRepository().createTableInSQLServer();
+ testShardingService.getOrderRepository().truncateTable();
+ testShardingService.getOrderItemRepository().truncateTable();
+ testShardingService.getAddressRepository().truncateTable();
}
}
diff --git
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/MySQLTest.java
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/MySQLTest.java
index 6ca7b876f2d..73d9053217a 100644
---
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/MySQLTest.java
+++
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/MySQLTest.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.test.natived.jdbc.databases;
import com.mysql.cj.jdbc.exceptions.CommunicationsException;
import
org.apache.shardingsphere.driver.api.yaml.YamlShardingSphereDataSourceFactory;
-import
org.apache.shardingsphere.test.natived.jdbc.commons.AbstractShardingCommonTest;
+import org.apache.shardingsphere.test.natived.jdbc.commons.TestShardingService;
import org.apache.shardingsphere.test.natived.jdbc.commons.FileTestUtils;
import org.awaitility.Awaitility;
import org.junit.jupiter.api.Test;
@@ -34,7 +34,7 @@ import java.sql.SQLException;
import java.time.Duration;
import java.util.Properties;
-public class MySQLTest {
+class MySQLTest {
private static final String USERNAME = "root";
@@ -46,27 +46,27 @@ public class MySQLTest {
private static Process process;
- private AbstractShardingCommonTest abstractShardingCommonTest;
+ private TestShardingService testShardingService;
@Test
@EnabledInNativeImage
void assertShardingInLocalTransactions() throws SQLException, IOException {
beforeAll();
DataSource dataSource =
YamlShardingSphereDataSourceFactory.createDataSource(FileTestUtils.readFromFileURLString("test-native/yaml/databases/mysql.yaml"));
- abstractShardingCommonTest = new
AbstractShardingCommonTest(dataSource);
+ testShardingService = new TestShardingService(dataSource);
this.initEnvironment();
- abstractShardingCommonTest.processSuccess();
- abstractShardingCommonTest.cleanEnvironment();
+ testShardingService.processSuccess();
+ testShardingService.cleanEnvironment();
tearDown();
}
private void initEnvironment() throws SQLException {
-
abstractShardingCommonTest.getOrderRepository().createTableIfNotExistsInMySQL();
-
abstractShardingCommonTest.getOrderItemRepository().createTableIfNotExistsInMySQL();
-
abstractShardingCommonTest.getAddressRepository().createTableIfNotExists();
- abstractShardingCommonTest.getOrderRepository().truncateTable();
- abstractShardingCommonTest.getOrderItemRepository().truncateTable();
- abstractShardingCommonTest.getAddressRepository().truncateTable();
+
testShardingService.getOrderRepository().createTableIfNotExistsInMySQL();
+
testShardingService.getOrderItemRepository().createTableIfNotExistsInMySQL();
+ testShardingService.getAddressRepository().createTableIfNotExists();
+ testShardingService.getOrderRepository().truncateTable();
+ testShardingService.getOrderItemRepository().truncateTable();
+ testShardingService.getAddressRepository().truncateTable();
}
private static Connection openConnection() throws SQLException {
diff --git
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/OpenGaussTest.java
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/OpenGaussTest.java
index 1c84b9e923f..cb4d1778991 100644
---
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/OpenGaussTest.java
+++
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/OpenGaussTest.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.test.natived.jdbc.databases;
import
org.apache.shardingsphere.driver.api.yaml.YamlShardingSphereDataSourceFactory;
-import
org.apache.shardingsphere.test.natived.jdbc.commons.AbstractShardingCommonTest;
+import org.apache.shardingsphere.test.natived.jdbc.commons.TestShardingService;
import org.apache.shardingsphere.test.natived.jdbc.commons.FileTestUtils;
import org.awaitility.Awaitility;
import org.junit.jupiter.api.Test;
@@ -33,7 +33,7 @@ import java.sql.SQLException;
import java.time.Duration;
import java.util.Properties;
-public class OpenGaussTest {
+class OpenGaussTest {
private static final String USERNAME = "gaussdb";
@@ -45,27 +45,27 @@ public class OpenGaussTest {
private static Process process;
- private AbstractShardingCommonTest abstractShardingCommonTest;
+ private TestShardingService testShardingService;
@Test
@EnabledInNativeImage
void assertShardingInLocalTransactions() throws SQLException, IOException {
beforeAll();
DataSource dataSource =
YamlShardingSphereDataSourceFactory.createDataSource(FileTestUtils.readFromFileURLString("test-native/yaml/databases/opengauss.yaml"));
- abstractShardingCommonTest = new
AbstractShardingCommonTest(dataSource);
+ testShardingService = new TestShardingService(dataSource);
this.initEnvironment();
- abstractShardingCommonTest.processSuccess();
- abstractShardingCommonTest.cleanEnvironment();
+ testShardingService.processSuccess();
+ testShardingService.cleanEnvironment();
tearDown();
}
private void initEnvironment() throws SQLException {
-
abstractShardingCommonTest.getOrderRepository().createTableIfNotExistsInPostgres();
-
abstractShardingCommonTest.getOrderItemRepository().createTableIfNotExistsInPostgres();
-
abstractShardingCommonTest.getAddressRepository().createTableIfNotExists();
- abstractShardingCommonTest.getOrderRepository().truncateTable();
- abstractShardingCommonTest.getOrderItemRepository().truncateTable();
- abstractShardingCommonTest.getAddressRepository().truncateTable();
+
testShardingService.getOrderRepository().createTableIfNotExistsInPostgres();
+
testShardingService.getOrderItemRepository().createTableIfNotExistsInPostgres();
+ testShardingService.getAddressRepository().createTableIfNotExists();
+ testShardingService.getOrderRepository().truncateTable();
+ testShardingService.getOrderItemRepository().truncateTable();
+ testShardingService.getAddressRepository().truncateTable();
}
private static Connection openConnection() throws SQLException {
diff --git
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/PostgresTest.java
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/PostgresTest.java
index d804325380b..650502117e2 100644
---
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/PostgresTest.java
+++
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/PostgresTest.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.test.natived.jdbc.databases;
import
org.apache.shardingsphere.driver.api.yaml.YamlShardingSphereDataSourceFactory;
-import
org.apache.shardingsphere.test.natived.jdbc.commons.AbstractShardingCommonTest;
+import org.apache.shardingsphere.test.natived.jdbc.commons.TestShardingService;
import org.apache.shardingsphere.test.natived.jdbc.commons.FileTestUtils;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledInNativeImage;
@@ -27,26 +27,26 @@ import javax.sql.DataSource;
import java.io.IOException;
import java.sql.SQLException;
-public class PostgresTest {
+class PostgresTest {
- private AbstractShardingCommonTest abstractShardingCommonTest;
+ private TestShardingService testShardingService;
@Test
@EnabledInNativeImage
void assertShardingInLocalTransactions() throws SQLException, IOException {
DataSource dataSource =
YamlShardingSphereDataSourceFactory.createDataSource(FileTestUtils.readFromFileURLString("test-native/yaml/databases/postgresql.yaml"));
- abstractShardingCommonTest = new
AbstractShardingCommonTest(dataSource);
+ testShardingService = new TestShardingService(dataSource);
this.initEnvironment();
- abstractShardingCommonTest.processSuccess();
- abstractShardingCommonTest.cleanEnvironment();
+ testShardingService.processSuccess();
+ testShardingService.cleanEnvironment();
}
private void initEnvironment() throws SQLException {
-
abstractShardingCommonTest.getOrderRepository().createTableIfNotExistsInPostgres();
-
abstractShardingCommonTest.getOrderItemRepository().createTableIfNotExistsInPostgres();
-
abstractShardingCommonTest.getAddressRepository().createTableIfNotExists();
- abstractShardingCommonTest.getOrderRepository().truncateTable();
- abstractShardingCommonTest.getOrderItemRepository().truncateTable();
- abstractShardingCommonTest.getAddressRepository().truncateTable();
+
testShardingService.getOrderRepository().createTableIfNotExistsInPostgres();
+
testShardingService.getOrderItemRepository().createTableIfNotExistsInPostgres();
+ testShardingService.getAddressRepository().createTableIfNotExists();
+ testShardingService.getOrderRepository().truncateTable();
+ testShardingService.getOrderItemRepository().truncateTable();
+ testShardingService.getAddressRepository().truncateTable();
}
}
diff --git
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/features/ShardingTest.java
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/features/ShardingTest.java
index 27f3e83357a..76b966af7b5 100644
---
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/features/ShardingTest.java
+++
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/features/ShardingTest.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.test.natived.jdbc.features;
import
org.apache.shardingsphere.driver.api.yaml.YamlShardingSphereDataSourceFactory;
-import
org.apache.shardingsphere.test.natived.jdbc.commons.AbstractShardingCommonTest;
+import org.apache.shardingsphere.test.natived.jdbc.commons.TestShardingService;
import org.apache.shardingsphere.test.natived.jdbc.commons.FileTestUtils;
import org.junit.jupiter.api.Test;
@@ -28,23 +28,23 @@ import java.sql.SQLException;
class ShardingTest {
- private AbstractShardingCommonTest abstractShardingCommonTest;
+ private TestShardingService testShardingService;
@Test
void assertShardingInLocalTransactions() throws SQLException, IOException {
DataSource dataSource =
YamlShardingSphereDataSourceFactory.createDataSource(FileTestUtils.readFromFileURLString("test-native/yaml/features/sharding.yaml"));
- abstractShardingCommonTest = new
AbstractShardingCommonTest(dataSource);
+ testShardingService = new TestShardingService(dataSource);
this.initEnvironment();
- abstractShardingCommonTest.processSuccess();
- abstractShardingCommonTest.cleanEnvironment();
+ testShardingService.processSuccess();
+ testShardingService.cleanEnvironment();
}
private void initEnvironment() throws SQLException {
-
abstractShardingCommonTest.getOrderRepository().createTableIfNotExistsInMySQL();
-
abstractShardingCommonTest.getOrderItemRepository().createTableIfNotExistsInMySQL();
-
abstractShardingCommonTest.getAddressRepository().createTableIfNotExists();
- abstractShardingCommonTest.getOrderRepository().truncateTable();
- abstractShardingCommonTest.getOrderItemRepository().truncateTable();
- abstractShardingCommonTest.getAddressRepository().truncateTable();
+
testShardingService.getOrderRepository().createTableIfNotExistsInMySQL();
+
testShardingService.getOrderItemRepository().createTableIfNotExistsInMySQL();
+ testShardingService.getAddressRepository().createTableIfNotExists();
+ testShardingService.getOrderRepository().truncateTable();
+ testShardingService.getOrderItemRepository().truncateTable();
+ testShardingService.getAddressRepository().truncateTable();
}
}