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

sunnianjun 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 2cd1bdf0c55 Upgrade junit 5 on dialect-exception modules (#24448)
2cd1bdf0c55 is described below

commit 2cd1bdf0c55b06f1db61b5c3dcf0e45cd0f90033
Author: Liang Zhang <[email protected]>
AuthorDate: Sat Mar 4 11:21:55 2023 +0800

    Upgrade junit 5 on dialect-exception modules (#24448)
---
 .../mapper/MySQLDialectExceptionMapperTest.java    | 59 ++++++++++------------
 .../dialect/mysql/vendor/MySQLVendorErrorTest.java |  2 +-
 .../PostgreSQLDialectExceptionMapperTest.java      | 45 ++++++++---------
 .../message/ServerErrorMessageBuilderTest.java     |  2 +-
 test/e2e/pipeline/pom.xml                          |  2 +-
 5 files changed, 50 insertions(+), 60 deletions(-)

diff --git 
a/dialect-exception/mysql/src/test/java/org/apache/shardingsphere/dialect/mysql/mapper/MySQLDialectExceptionMapperTest.java
 
b/dialect-exception/mysql/src/test/java/org/apache/shardingsphere/dialect/mysql/mapper/MySQLDialectExceptionMapperTest.java
index 56e6ab93d99..6dafc03f8d4 100644
--- 
a/dialect-exception/mysql/src/test/java/org/apache/shardingsphere/dialect/mysql/mapper/MySQLDialectExceptionMapperTest.java
+++ 
b/dialect-exception/mysql/src/test/java/org/apache/shardingsphere/dialect/mysql/mapper/MySQLDialectExceptionMapperTest.java
@@ -17,7 +17,6 @@
 
 package org.apache.shardingsphere.dialect.mysql.mapper;
 
-import lombok.RequiredArgsConstructor;
 import org.apache.shardingsphere.dialect.exception.SQLDialectException;
 import 
org.apache.shardingsphere.dialect.exception.connection.TooManyConnectionsException;
 import 
org.apache.shardingsphere.dialect.exception.data.InsertColumnsAndValuesMismatchedException;
@@ -32,48 +31,44 @@ import 
org.apache.shardingsphere.dialect.mysql.exception.UnknownCollationExcepti
 import 
org.apache.shardingsphere.dialect.mysql.exception.UnsupportedPreparedStatementException;
 import org.apache.shardingsphere.dialect.mysql.vendor.MySQLVendorError;
 import 
org.apache.shardingsphere.infra.util.exception.external.sql.vendor.VendorError;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.ArgumentsProvider;
+import org.junit.jupiter.params.provider.ArgumentsSource;
 
 import java.sql.SQLException;
-import java.util.Arrays;
-import java.util.Collection;
+import java.util.stream.Stream;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.mockito.Mockito.mock;
 
-@RunWith(Parameterized.class)
-@RequiredArgsConstructor
 public final class MySQLDialectExceptionMapperTest {
     
-    private final Class<SQLDialectException> sqlDialectExceptionClazz;
-    
-    private final VendorError vendorError;
-    
-    @Parameters(name = "{1} -> {0}")
-    public static Collection<Object[]> getTestParameters() {
-        return Arrays.asList(new Object[][]{
-                {UnknownDatabaseException.class, 
MySQLVendorError.ER_NO_DB_ERROR},
-                {NoDatabaseSelectedException.class, 
MySQLVendorError.ER_NO_DB_ERROR},
-                {DatabaseCreateExistsException.class, 
MySQLVendorError.ER_DB_CREATE_EXISTS_ERROR},
-                {DatabaseDropNotExistsException.class, 
MySQLVendorError.ER_DB_DROP_NOT_EXISTS_ERROR},
-                {TableExistsException.class, 
MySQLVendorError.ER_TABLE_EXISTS_ERROR},
-                {NoSuchTableException.class, 
MySQLVendorError.ER_NO_SUCH_TABLE},
-                {InsertColumnsAndValuesMismatchedException.class, 
MySQLVendorError.ER_WRONG_VALUE_COUNT_ON_ROW},
-                {TableModifyInTransactionException.class, 
MySQLVendorError.ER_ERROR_ON_MODIFYING_GTID_EXECUTED_TABLE},
-                {TooManyConnectionsException.class, 
MySQLVendorError.ER_CON_COUNT_ERROR},
-                {UnsupportedPreparedStatementException.class, 
MySQLVendorError.ER_UNSUPPORTED_PS},
-                {UnknownCollationException.class, 
MySQLVendorError.ER_UNKNOWN_COLLATION},
-        });
-    }
-    
-    @Test
-    public void assertConvert() {
+    @ParameterizedTest(name = "{1} -> {0}")
+    @ArgumentsSource(TestCaseArgumentsProvider.class)
+    public void assertConvert(final Class<SQLDialectException> 
sqlDialectExceptionClazz, final VendorError vendorError) {
         SQLException actual = new 
MySQLDialectExceptionMapper().convert(mock(sqlDialectExceptionClazz));
         assertThat(actual.getSQLState(), 
is(vendorError.getSqlState().getValue()));
         assertThat(actual.getErrorCode(), is(vendorError.getVendorCode()));
     }
+    
+    private static class TestCaseArgumentsProvider implements 
ArgumentsProvider {
+        
+        @Override
+        public Stream<? extends Arguments> provideArguments(final 
ExtensionContext extensionContext) {
+            return Stream.of(Arguments.of(UnknownDatabaseException.class, 
MySQLVendorError.ER_NO_DB_ERROR),
+                    Arguments.of(NoDatabaseSelectedException.class, 
MySQLVendorError.ER_NO_DB_ERROR),
+                    Arguments.of(DatabaseCreateExistsException.class, 
MySQLVendorError.ER_DB_CREATE_EXISTS_ERROR),
+                    Arguments.of(DatabaseDropNotExistsException.class, 
MySQLVendorError.ER_DB_DROP_NOT_EXISTS_ERROR),
+                    Arguments.of(TableExistsException.class, 
MySQLVendorError.ER_TABLE_EXISTS_ERROR),
+                    Arguments.of(NoSuchTableException.class, 
MySQLVendorError.ER_NO_SUCH_TABLE),
+                    
Arguments.of(InsertColumnsAndValuesMismatchedException.class, 
MySQLVendorError.ER_WRONG_VALUE_COUNT_ON_ROW),
+                    Arguments.of(TableModifyInTransactionException.class, 
MySQLVendorError.ER_ERROR_ON_MODIFYING_GTID_EXECUTED_TABLE),
+                    Arguments.of(TooManyConnectionsException.class, 
MySQLVendorError.ER_CON_COUNT_ERROR),
+                    Arguments.of(UnsupportedPreparedStatementException.class, 
MySQLVendorError.ER_UNSUPPORTED_PS),
+                    Arguments.of(UnknownCollationException.class, 
MySQLVendorError.ER_UNKNOWN_COLLATION));
+        }
+    }
 }
diff --git 
a/dialect-exception/mysql/src/test/java/org/apache/shardingsphere/dialect/mysql/vendor/MySQLVendorErrorTest.java
 
b/dialect-exception/mysql/src/test/java/org/apache/shardingsphere/dialect/mysql/vendor/MySQLVendorErrorTest.java
index 3de9a57a0bf..bd7e49a1daf 100644
--- 
a/dialect-exception/mysql/src/test/java/org/apache/shardingsphere/dialect/mysql/vendor/MySQLVendorErrorTest.java
+++ 
b/dialect-exception/mysql/src/test/java/org/apache/shardingsphere/dialect/mysql/vendor/MySQLVendorErrorTest.java
@@ -17,7 +17,7 @@
 
 package org.apache.shardingsphere.dialect.mysql.vendor;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
diff --git 
a/dialect-exception/postgresql/src/test/java/org/apache/shardingsphere/dialect/postgresql/mapper/PostgreSQLDialectExceptionMapperTest.java
 
b/dialect-exception/postgresql/src/test/java/org/apache/shardingsphere/dialect/postgresql/mapper/PostgreSQLDialectExceptionMapperTest.java
index ddae382bcaa..23654b052a0 100644
--- 
a/dialect-exception/postgresql/src/test/java/org/apache/shardingsphere/dialect/postgresql/mapper/PostgreSQLDialectExceptionMapperTest.java
+++ 
b/dialect-exception/postgresql/src/test/java/org/apache/shardingsphere/dialect/postgresql/mapper/PostgreSQLDialectExceptionMapperTest.java
@@ -17,47 +17,42 @@
 
 package org.apache.shardingsphere.dialect.postgresql.mapper;
 
-import lombok.RequiredArgsConstructor;
 import org.apache.shardingsphere.dialect.exception.SQLDialectException;
 import 
org.apache.shardingsphere.dialect.exception.connection.TooManyConnectionsException;
 import 
org.apache.shardingsphere.dialect.exception.data.InsertColumnsAndValuesMismatchedException;
 import 
org.apache.shardingsphere.dialect.exception.data.InvalidParameterValueException;
 import 
org.apache.shardingsphere.dialect.exception.syntax.database.DatabaseCreateExistsException;
 import 
org.apache.shardingsphere.dialect.exception.transaction.InTransactionException;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.ArgumentsProvider;
+import org.junit.jupiter.params.provider.ArgumentsSource;
 import org.postgresql.util.PSQLState;
 
-import java.util.Arrays;
-import java.util.Collection;
+import java.util.stream.Stream;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.mockito.Mockito.mock;
 
-@RunWith(Parameterized.class)
-@RequiredArgsConstructor
 public final class PostgreSQLDialectExceptionMapperTest {
     
-    private final Class<SQLDialectException> sqlDialectExceptionClazz;
-    
-    private final String sqlState;
-    
-    @Parameters(name = "{1} -> {0}")
-    public static Collection<Object[]> getTestParameters() {
-        return Arrays.asList(new Object[][]{
-                {DatabaseCreateExistsException.class, "42P04"},
-                {InTransactionException.class, 
PSQLState.TRANSACTION_STATE_INVALID.getState()},
-                {InsertColumnsAndValuesMismatchedException.class, 
PSQLState.SYNTAX_ERROR.getState()},
-                {InvalidParameterValueException.class, 
PSQLState.INVALID_PARAMETER_VALUE.getState()},
-                {TooManyConnectionsException.class, 
PSQLState.CONNECTION_REJECTED.getState()},
-        });
+    @ParameterizedTest(name = "{1} -> {0}")
+    @ArgumentsSource(TestCaseArgumentsProvider.class)
+    public void convert(final Class<SQLDialectException> 
sqlDialectExceptionClazz, final String sqlState) {
+        assertThat(new 
PostgreSQLDialectExceptionMapper().convert(mock(sqlDialectExceptionClazz)).getSQLState(),
 is(sqlState));
     }
     
-    @Test
-    public void convert() {
-        assertThat(new 
PostgreSQLDialectExceptionMapper().convert(mock(sqlDialectExceptionClazz)).getSQLState(),
 is(sqlState));
+    private static class TestCaseArgumentsProvider implements 
ArgumentsProvider {
+        
+        @Override
+        public Stream<? extends Arguments> provideArguments(final 
ExtensionContext extensionContext) {
+            return Stream.of(Arguments.of(DatabaseCreateExistsException.class, 
"42P04"),
+                    Arguments.of(InTransactionException.class, 
PSQLState.TRANSACTION_STATE_INVALID.getState()),
+                    
Arguments.of(InsertColumnsAndValuesMismatchedException.class, 
PSQLState.SYNTAX_ERROR.getState()),
+                    Arguments.of(InvalidParameterValueException.class, 
PSQLState.INVALID_PARAMETER_VALUE.getState()),
+                    Arguments.of(TooManyConnectionsException.class, 
PSQLState.CONNECTION_REJECTED.getState()));
+        }
     }
 }
diff --git 
a/dialect-exception/postgresql/src/test/java/org/apache/shardingsphere/dialect/postgresql/message/ServerErrorMessageBuilderTest.java
 
b/dialect-exception/postgresql/src/test/java/org/apache/shardingsphere/dialect/postgresql/message/ServerErrorMessageBuilderTest.java
index 2951851b379..fe80ac01054 100644
--- 
a/dialect-exception/postgresql/src/test/java/org/apache/shardingsphere/dialect/postgresql/message/ServerErrorMessageBuilderTest.java
+++ 
b/dialect-exception/postgresql/src/test/java/org/apache/shardingsphere/dialect/postgresql/message/ServerErrorMessageBuilderTest.java
@@ -18,7 +18,7 @@
 package org.apache.shardingsphere.dialect.postgresql.message;
 
 import 
org.apache.shardingsphere.dialect.postgresql.vendor.PostgreSQLVendorError;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.postgresql.util.ServerErrorMessage;
 
 import static org.hamcrest.CoreMatchers.is;
diff --git a/test/e2e/pipeline/pom.xml b/test/e2e/pipeline/pom.xml
index 1186e431ee1..e67c92a6949 100644
--- a/test/e2e/pipeline/pom.xml
+++ b/test/e2e/pipeline/pom.xml
@@ -91,7 +91,7 @@
             <groupId>org.opengauss</groupId>
             <artifactId>opengauss-jdbc</artifactId>
         </dependency>
-    
+        
         <dependency>
             <groupId>org.testcontainers</groupId>
             <artifactId>testcontainers</artifactId>

Reply via email to