You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2023/03/12 14:30:51 UTC
[shardingsphere] branch master updated: Upgrade junit 5 on Yaml DataSource E2E (#24566)
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 95f2035d770 Upgrade junit 5 on Yaml DataSource E2E (#24566)
95f2035d770 is described below
commit 95f2035d7703b5c35e0503d0d5ff2c95303bac01
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Sun Mar 12 22:30:42 2023 +0800
Upgrade junit 5 on Yaml DataSource E2E (#24566)
---
.../e2e/driver/AbstractYamlDataSourceE2EIT.java | 4 +-
.../YamlShardingWithReadwriteSplittingE2EIT.java | 47 +++++++++----------
.../readwrite/YamlReadwriteSplittingE2EIT.java | 52 ++++++++++------------
.../e2e/driver/sharding/YamlShardingE2EIT.java | 49 +++++++++-----------
4 files changed, 69 insertions(+), 83 deletions(-)
diff --git a/test/e2e/driver/src/test/java/org/apache/shardingsphere/test/e2e/driver/AbstractYamlDataSourceE2EIT.java b/test/e2e/driver/src/test/java/org/apache/shardingsphere/test/e2e/driver/AbstractYamlDataSourceE2EIT.java
index 873c9cceba7..36da9eaef32 100644
--- a/test/e2e/driver/src/test/java/org/apache/shardingsphere/test/e2e/driver/AbstractYamlDataSourceE2EIT.java
+++ b/test/e2e/driver/src/test/java/org/apache/shardingsphere/test/e2e/driver/AbstractYamlDataSourceE2EIT.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.test.e2e.driver;
import com.zaxxer.hikari.HikariDataSource;
import org.h2.tools.RunScript;
-import org.junit.BeforeClass;
+import org.junit.jupiter.api.BeforeAll;
import javax.sql.DataSource;
import java.io.File;
@@ -32,7 +32,7 @@ import java.util.Objects;
// TODO move to new acceptance test module with mode
public abstract class AbstractYamlDataSourceE2EIT {
- @BeforeClass
+ @BeforeAll
public static void createSchema() throws SQLException {
for (String each : getSchemaFiles()) {
RunScript.execute(
diff --git a/test/e2e/driver/src/test/java/org/apache/shardingsphere/test/e2e/driver/mix/YamlShardingWithReadwriteSplittingE2EIT.java b/test/e2e/driver/src/test/java/org/apache/shardingsphere/test/e2e/driver/mix/YamlShardingWithReadwriteSplittingE2EIT.java
index 2085e5f9a22..089bb604f0a 100644
--- a/test/e2e/driver/src/test/java/org/apache/shardingsphere/test/e2e/driver/mix/YamlShardingWithReadwriteSplittingE2EIT.java
+++ b/test/e2e/driver/src/test/java/org/apache/shardingsphere/test/e2e/driver/mix/YamlShardingWithReadwriteSplittingE2EIT.java
@@ -17,45 +17,29 @@
package org.apache.shardingsphere.test.e2e.driver.mix;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.test.e2e.driver.AbstractYamlDataSourceE2EIT;
import org.apache.shardingsphere.driver.api.yaml.YamlShardingSphereDataSourceFactory;
import org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.apache.shardingsphere.test.e2e.driver.AbstractYamlDataSourceE2EIT;
+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 javax.sql.DataSource;
import java.io.File;
import java.sql.Connection;
import java.sql.Statement;
-import java.util.Arrays;
-import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
+import java.util.stream.Stream;
-@RunWith(Parameterized.class)
-@RequiredArgsConstructor
public final class YamlShardingWithReadwriteSplittingE2EIT extends AbstractYamlDataSourceE2EIT {
- private final String filePath;
-
- private final boolean hasDataSource;
-
- @Parameters(name = "{index}:{0}-{1}")
- public static Collection<Object[]> init() {
- return Arrays.asList(new Object[][]{
- {"/yaml/integrate/sharding_readwrite_splitting/configWithDataSourceWithoutProps.yaml", true},
- {"/yaml/integrate/sharding_readwrite_splitting/configWithoutDataSourceWithoutProps.yaml", false},
- {"/yaml/integrate/sharding_readwrite_splitting/configWithDataSourceWithProps.yaml", true},
- {"/yaml/integrate/sharding_readwrite_splitting/configWithoutDataSourceWithProps.yaml", false},
- });
- }
-
- @Test
- public void assertWithDataSource() throws Exception {
+ @ParameterizedTest(name = "{index}:{0}-{1}")
+ @ArgumentsSource(TestCaseArgumentsProvider.class)
+ public void assertWithDataSource(final String filePath, final boolean hasDataSource) throws Exception {
File yamlFile = new File(Objects.requireNonNull(YamlShardingWithReadwriteSplittingE2EIT.class.getResource(filePath)).toURI());
DataSource dataSource;
if (hasDataSource) {
@@ -80,4 +64,15 @@ public final class YamlShardingWithReadwriteSplittingE2EIT extends AbstractYamlD
}
((ShardingSphereDataSource) dataSource).close();
}
+
+ private static class TestCaseArgumentsProvider implements ArgumentsProvider {
+
+ @Override
+ public Stream<? extends Arguments> provideArguments(final ExtensionContext extensionContext) {
+ return Stream.of(Arguments.of("/yaml/integrate/sharding_readwrite_splitting/configWithDataSourceWithoutProps.yaml", true),
+ Arguments.of("/yaml/integrate/sharding_readwrite_splitting/configWithoutDataSourceWithoutProps.yaml", false),
+ Arguments.of("/yaml/integrate/sharding_readwrite_splitting/configWithDataSourceWithProps.yaml", true),
+ Arguments.of("/yaml/integrate/sharding_readwrite_splitting/configWithoutDataSourceWithProps.yaml", false));
+ }
+ }
}
diff --git a/test/e2e/driver/src/test/java/org/apache/shardingsphere/test/e2e/driver/readwrite/YamlReadwriteSplittingE2EIT.java b/test/e2e/driver/src/test/java/org/apache/shardingsphere/test/e2e/driver/readwrite/YamlReadwriteSplittingE2EIT.java
index 3c568ba5fcf..59d3cd07a31 100644
--- a/test/e2e/driver/src/test/java/org/apache/shardingsphere/test/e2e/driver/readwrite/YamlReadwriteSplittingE2EIT.java
+++ b/test/e2e/driver/src/test/java/org/apache/shardingsphere/test/e2e/driver/readwrite/YamlReadwriteSplittingE2EIT.java
@@ -17,45 +17,29 @@
package org.apache.shardingsphere.test.e2e.driver.readwrite;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.test.e2e.driver.AbstractYamlDataSourceE2EIT;
import org.apache.shardingsphere.driver.api.yaml.YamlShardingSphereDataSourceFactory;
import org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.apache.shardingsphere.test.e2e.driver.AbstractYamlDataSourceE2EIT;
+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 javax.sql.DataSource;
import java.io.File;
import java.sql.Connection;
import java.sql.Statement;
-import java.util.Arrays;
-import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
+import java.util.stream.Stream;
-@RunWith(Parameterized.class)
-@RequiredArgsConstructor
public final class YamlReadwriteSplittingE2EIT extends AbstractYamlDataSourceE2EIT {
- private final String filePath;
-
- private final boolean hasDataSource;
-
- @Parameters(name = "{index}:{0}-{1}")
- public static Collection<Object[]> init() {
- return Arrays.asList(new Object[][]{
- {"/yaml/integrate/readwrite_splitting/configWithReadwriteSplittingDataSourceWithoutProps.yaml", true},
- {"/yaml/integrate/readwrite_splitting/configWithReadwriteSplittingDataSourceWithoutProps.yaml", true},
- {"/yaml/integrate/readwrite_splitting/configWithReadwriteSplittingDataSourceWithProps.yaml", true},
- {"/yaml/integrate/readwrite_splitting/configWithReadwriteSplittingDataSourceWithProps.yaml", true},
- });
- }
-
- @Test
- public void assertWithDataSource() throws Exception {
+ @ParameterizedTest(name = "{index}:{0}-{1}")
+ @ArgumentsSource(TestCaseArgumentsProvider.class)
+ public void assertWithDataSource(final String filePath, final boolean hasDataSource) throws Exception {
File yamlFile = new File(Objects.requireNonNull(YamlReadwriteSplittingE2EIT.class.getResource(filePath)).toURI());
DataSource dataSource;
if (hasDataSource) {
@@ -77,8 +61,9 @@ public final class YamlReadwriteSplittingE2EIT extends AbstractYamlDataSourceE2E
((ShardingSphereDataSource) dataSource).close();
}
- @Test
- public void assertWithDataSourceByYamlBytes() throws Exception {
+ @ParameterizedTest(name = "{index}:{0}-{1}")
+ @ArgumentsSource(TestCaseArgumentsProvider.class)
+ public void assertWithDataSourceByYamlBytes(final String filePath, final boolean hasDataSource) throws Exception {
File yamlFile = new File(Objects.requireNonNull(YamlReadwriteSplittingE2EIT.class.getResource(filePath)).toURI());
DataSource dataSource;
if (hasDataSource) {
@@ -99,4 +84,15 @@ public final class YamlReadwriteSplittingE2EIT extends AbstractYamlDataSourceE2E
}
((ShardingSphereDataSource) dataSource).close();
}
+
+ private static class TestCaseArgumentsProvider implements ArgumentsProvider {
+
+ @Override
+ public Stream<? extends Arguments> provideArguments(final ExtensionContext extensionContext) {
+ return Stream.of(Arguments.of("/yaml/integrate/readwrite_splitting/configWithReadwriteSplittingDataSourceWithoutProps.yaml", true),
+ Arguments.of("/yaml/integrate/readwrite_splitting/configWithReadwriteSplittingDataSourceWithoutProps.yaml", true),
+ Arguments.of("/yaml/integrate/readwrite_splitting/configWithReadwriteSplittingDataSourceWithProps.yaml", true),
+ Arguments.of("/yaml/integrate/readwrite_splitting/configWithReadwriteSplittingDataSourceWithProps.yaml", true));
+ }
+ }
}
diff --git a/test/e2e/driver/src/test/java/org/apache/shardingsphere/test/e2e/driver/sharding/YamlShardingE2EIT.java b/test/e2e/driver/src/test/java/org/apache/shardingsphere/test/e2e/driver/sharding/YamlShardingE2EIT.java
index 068f21adfb4..8a4ccf2bf76 100644
--- a/test/e2e/driver/src/test/java/org/apache/shardingsphere/test/e2e/driver/sharding/YamlShardingE2EIT.java
+++ b/test/e2e/driver/src/test/java/org/apache/shardingsphere/test/e2e/driver/sharding/YamlShardingE2EIT.java
@@ -17,45 +17,29 @@
package org.apache.shardingsphere.test.e2e.driver.sharding;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.test.e2e.driver.AbstractYamlDataSourceE2EIT;
import org.apache.shardingsphere.driver.api.yaml.YamlShardingSphereDataSourceFactory;
import org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.apache.shardingsphere.test.e2e.driver.AbstractYamlDataSourceE2EIT;
+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 javax.sql.DataSource;
import java.io.File;
import java.sql.Connection;
import java.sql.Statement;
-import java.util.Arrays;
-import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
+import java.util.stream.Stream;
-@RunWith(Parameterized.class)
-@RequiredArgsConstructor
-public class YamlShardingE2EIT extends AbstractYamlDataSourceE2EIT {
-
- private final String filePath;
+public final class YamlShardingE2EIT extends AbstractYamlDataSourceE2EIT {
- private final boolean hasDataSource;
-
- @Parameters(name = "{index}:{0}-{1}")
- public static Collection<Object[]> init() {
- return Arrays.asList(new Object[][]{
- {"/yaml/integrate/sharding/configWithDataSourceWithoutProps.yaml", true},
- {"/yaml/integrate/sharding/configWithoutDataSourceWithoutProps.yaml", false},
- {"/yaml/integrate/sharding/configWithDataSourceWithProps.yaml", true},
- {"/yaml/integrate/sharding/configWithoutDataSourceWithProps.yaml", false},
- });
- }
-
- @Test
- public void assertWithDataSource() throws Exception {
+ @ParameterizedTest(name = "{index}:{0}-{1}")
+ @ArgumentsSource(TestCaseArgumentsProvider.class)
+ public void assertWithDataSource(final String filePath, final boolean hasDataSource) throws Exception {
File yamlFile = new File(Objects.requireNonNull(YamlShardingE2EIT.class.getResource(filePath)).toURI());
DataSource dataSource;
if (hasDataSource) {
@@ -76,4 +60,15 @@ public class YamlShardingE2EIT extends AbstractYamlDataSourceE2EIT {
}
((ShardingSphereDataSource) dataSource).close();
}
+
+ private static class TestCaseArgumentsProvider implements ArgumentsProvider {
+
+ @Override
+ public Stream<? extends Arguments> provideArguments(final ExtensionContext extensionContext) {
+ return Stream.of(Arguments.of("/yaml/integrate/sharding/configWithDataSourceWithoutProps.yaml", true),
+ Arguments.of("/yaml/integrate/sharding/configWithoutDataSourceWithoutProps.yaml", false),
+ Arguments.of("/yaml/integrate/sharding/configWithDataSourceWithProps.yaml", true),
+ Arguments.of("/yaml/integrate/sharding/configWithoutDataSourceWithProps.yaml", false));
+ }
+ }
}