You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by me...@apache.org on 2020/12/30 07:05:02 UTC
[shardingsphere] branch master updated: Move database and table
operation from BaseIT to SchemaEnvironmentManager (#8823)
This is an automated email from the ASF dual-hosted git repository.
menghaoran 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 6fe5e23 Move database and table operation from BaseIT to SchemaEnvironmentManager (#8823)
6fe5e23 is described below
commit 6fe5e23d3004bc4deb189765abc3ed64a2f1ef63
Author: Liang Zhang <te...@163.com>
AuthorDate: Wed Dec 30 15:04:35 2020 +0800
Move database and table operation from BaseIT to SchemaEnvironmentManager (#8823)
* Refactor BaseDDLIT
* Rename DataSetEnvironmentManager.load
* Refactor BaseDDLIT
* Move database and table operation from BaseIT to SchemaEnvironmentManager
---
.../test/integration/engine/BaseIT.java | 40 +--------
.../test/integration/engine/BatchIT.java | 15 ++--
.../test/integration/engine/dcl/BaseDCLIT.java | 25 +++---
.../test/integration/engine/ddl/BaseDDLIT.java | 99 +++++++++++-----------
.../test/integration/engine/ddl/GeneralDDLIT.java | 2 +-
.../test/integration/engine/dml/BaseDMLIT.java | 15 ++--
.../test/integration/engine/dql/BaseDQLIT.java | 10 ++-
.../env/dataset/DataSetEnvironmentManager.java | 4 +-
.../env/schema/SchemaEnvironmentManager.java | 37 ++++++--
9 files changed, 119 insertions(+), 128 deletions(-)
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/BaseIT.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/BaseIT.java
index 237eb6a..db69403 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/BaseIT.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/BaseIT.java
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.test.integration.engine;
import lombok.AccessLevel;
import lombok.Getter;
-import lombok.SneakyThrows;
import org.apache.shardingsphere.driver.api.yaml.YamlShardingSphereDataSourceFactory;
import org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
@@ -87,44 +86,7 @@ public abstract class BaseIT {
: YamlShardingSphereDataSourceFactory.createDataSource(actualDataSources, new File(EnvironmentPath.getRulesConfigurationFile(ruleType)));
}
- protected static void setUpDatabasesAndTables() {
- createDatabases();
- dropTables();
- createTables();
- }
-
- @SneakyThrows({JAXBException.class, IOException.class})
- protected static void createDatabases() {
- for (String each : IntegrateTestEnvironment.getInstance().getRuleTypes()) {
- SchemaEnvironmentManager.dropDatabases(each);
- }
- for (String each : IntegrateTestEnvironment.getInstance().getRuleTypes()) {
- SchemaEnvironmentManager.createDatabases(each);
- }
- }
-
- @SneakyThrows({JAXBException.class, IOException.class})
- protected static void createTables() {
- for (String each : IntegrateTestEnvironment.getInstance().getRuleTypes()) {
- SchemaEnvironmentManager.createTables(each);
- }
- }
-
- @SneakyThrows({JAXBException.class, IOException.class})
- protected static void dropDatabases() {
- for (String each : IntegrateTestEnvironment.getInstance().getRuleTypes()) {
- SchemaEnvironmentManager.dropDatabases(each);
- }
- }
-
- @SneakyThrows({JAXBException.class, IOException.class})
- protected static void dropTables() {
- for (String each : IntegrateTestEnvironment.getInstance().getRuleTypes()) {
- SchemaEnvironmentManager.dropTables(each);
- }
- }
-
- protected void resetTargetDataSource() throws IOException, SQLException {
+ protected final void resetTargetDataSource() throws IOException, SQLException {
targetDataSource = createTargetDataSource();
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/BatchIT.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/BatchIT.java
index a062ab8..b6253a2 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/BatchIT.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/BatchIT.java
@@ -26,12 +26,13 @@ import org.apache.shardingsphere.sharding.algorithm.sharding.inline.InlineExpres
import org.apache.shardingsphere.test.integration.cases.assertion.IntegrateTestCaseContext;
import org.apache.shardingsphere.test.integration.cases.assertion.root.IntegrateTestCaseAssertion;
import org.apache.shardingsphere.test.integration.cases.dataset.DataSet;
+import org.apache.shardingsphere.test.integration.cases.dataset.DataSetLoader;
import org.apache.shardingsphere.test.integration.cases.dataset.metadata.DataSetColumn;
import org.apache.shardingsphere.test.integration.cases.dataset.metadata.DataSetMetadata;
import org.apache.shardingsphere.test.integration.cases.dataset.row.DataSetRow;
-import org.apache.shardingsphere.test.integration.cases.dataset.DataSetLoader;
import org.apache.shardingsphere.test.integration.env.EnvironmentPath;
import org.apache.shardingsphere.test.integration.env.dataset.DataSetEnvironmentManager;
+import org.apache.shardingsphere.test.integration.env.schema.SchemaEnvironmentManager;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
@@ -82,18 +83,20 @@ public abstract class BatchIT extends BaseIT {
}
@BeforeClass
- public static void initDatabasesAndTables() {
- setUpDatabasesAndTables();
+ public static void initDatabasesAndTables() throws JAXBException, IOException {
+ SchemaEnvironmentManager.createDatabases();
+ SchemaEnvironmentManager.dropTables();
+ SchemaEnvironmentManager.createTables();
}
@AfterClass
- public static void destroyDatabasesAndTables() {
- dropDatabases();
+ public static void destroyDatabasesAndTables() throws IOException, JAXBException {
+ SchemaEnvironmentManager.dropDatabases();
}
@Before
public void insertData() throws SQLException, ParseException {
- dataSetEnvironmentManager.initialize();
+ dataSetEnvironmentManager.load();
}
@After
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/dcl/BaseDCLIT.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/dcl/BaseDCLIT.java
index 09fb31a..1d869dd 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/dcl/BaseDCLIT.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/dcl/BaseDCLIT.java
@@ -17,14 +17,15 @@
package org.apache.shardingsphere.test.integration.engine.dcl;
+import org.apache.shardingsphere.infra.database.metadata.DataSourceMetaData;
+import org.apache.shardingsphere.infra.database.metadata.MemorizedDataSourceMetaData;
+import org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.test.integration.cases.assertion.dcl.DCLIntegrateTestCaseAssertion;
import org.apache.shardingsphere.test.integration.cases.assertion.root.SQLCaseType;
import org.apache.shardingsphere.test.integration.engine.SingleIT;
import org.apache.shardingsphere.test.integration.env.EnvironmentPath;
import org.apache.shardingsphere.test.integration.env.authority.AuthorityEnvironmentManager;
-import org.apache.shardingsphere.infra.database.metadata.DataSourceMetaData;
-import org.apache.shardingsphere.infra.database.metadata.MemorizedDataSourceMetaData;
-import org.apache.shardingsphere.infra.database.type.DatabaseType;
+import org.apache.shardingsphere.test.integration.env.schema.SchemaEnvironmentManager;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
@@ -96,22 +97,24 @@ public abstract class BaseDCLIT extends SingleIT {
}
@BeforeClass
- public static void initDatabasesAndTables() {
- setUpDatabasesAndTables();
+ public static void initDatabasesAndTables() throws JAXBException, IOException {
+ SchemaEnvironmentManager.createDatabases();
+ SchemaEnvironmentManager.dropTables();
+ SchemaEnvironmentManager.createTables();
}
-
+
@AfterClass
- public static void destroyDatabasesAndTables() {
- dropDatabases();
+ public static void destroyDatabasesAndTables() throws IOException, JAXBException {
+ SchemaEnvironmentManager.dropDatabases();
}
-
+
@Before
- public void insertData() throws SQLException {
+ public final void insertData() throws SQLException {
authorityEnvironmentManager.initialize();
}
@After
- public void cleanData() throws SQLException {
+ public final void cleanData() throws SQLException {
authorityEnvironmentManager.clean();
}
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/ddl/BaseDDLIT.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/ddl/BaseDDLIT.java
index b2e3c0c..a6616d7 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/ddl/BaseDDLIT.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/ddl/BaseDDLIT.java
@@ -27,6 +27,7 @@ import org.apache.shardingsphere.test.integration.cases.dataset.metadata.DataSet
import org.apache.shardingsphere.test.integration.engine.SingleIT;
import org.apache.shardingsphere.test.integration.env.EnvironmentPath;
import org.apache.shardingsphere.test.integration.env.dataset.DataSetEnvironmentManager;
+import org.apache.shardingsphere.test.integration.env.schema.SchemaEnvironmentManager;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
@@ -51,41 +52,37 @@ import static org.junit.Assert.assertTrue;
@Slf4j
public abstract class BaseDDLIT extends SingleIT {
+ private final DataSetEnvironmentManager dataSetEnvironmentManager;
+
protected BaseDDLIT(final String parentPath, final DDLIntegrateTestCaseAssertion assertion, final String ruleType,
final DatabaseType databaseType, final SQLCaseType caseType, final String sql) throws IOException, JAXBException, SQLException, ParseException {
super(parentPath, assertion, ruleType, databaseType, caseType, sql);
+ dataSetEnvironmentManager = new DataSetEnvironmentManager(EnvironmentPath.getDataSetFile(ruleType), getActualDataSources());
}
@BeforeClass
- public static void initDatabases() {
- createDatabases();
+ public static void initDatabases() throws IOException, JAXBException {
+ SchemaEnvironmentManager.createDatabases();
}
@AfterClass
- public static void destroyDatabases() {
- dropDatabases();
+ public static void destroyDatabases() throws IOException, JAXBException {
+ SchemaEnvironmentManager.dropDatabases();
}
@Before
public final void initTables() throws SQLException, ParseException, IOException, JAXBException {
- if ("H2".equals(getDatabaseType().getName())) {
- dropTables();
- }
- createTables();
- new DataSetEnvironmentManager(EnvironmentPath.getDataSetFile(getRuleType()), getActualDataSources()).initialize();
+ SchemaEnvironmentManager.createTables();
resetTargetDataSource();
+ dataSetEnvironmentManager.load();
}
@After
- public final void destroyTables() {
- dropTables();
+ public final void destroyTables() throws JAXBException, IOException {
+ SchemaEnvironmentManager.dropTables();
}
- protected final void assertMetaData(final Connection connection) throws SQLException {
- if (null == getAssertion().getExpectedDataFile()) {
- log.warn("Expected data file `{}` is empty", getSql());
- return;
- }
+ protected final void assertTableMetaData(final Connection connection) throws SQLException {
String tableName = ((DDLIntegrateTestCaseAssertion) getAssertion()).getTable();
List<DataSetColumn> actualColumns = getActualColumns(connection, tableName);
List<DataSetIndex> actualIndexes = getActualIndexes(connection, tableName);
@@ -95,14 +92,14 @@ public abstract class BaseDDLIT extends SingleIT {
return;
}
try {
- assertMetaData(actualColumns, actualIndexes, getDataSet().findMetadata(tableName));
+ assertTableMetaData(actualColumns, actualIndexes, getDataSet().findMetadata(tableName));
} catch (final AssertionError ex) {
log.error("[ERROR] SQL::{}, Parameter::{}, Expect::{}", getCaseIdentifier(), getAssertion().getParameters(), getAssertion().getExpectedDataFile());
throw ex;
}
}
- private void assertMetaData(final List<DataSetColumn> actualColumns, final List<DataSetIndex> actualIndexes, final DataSetMetadata expected) {
+ private void assertTableMetaData(final List<DataSetColumn> actualColumns, final List<DataSetIndex> actualIndexes, final DataSetMetadata expected) {
for (DataSetColumn each : expected.getColumns()) {
assertColumnMetaData(actualColumns, each);
}
@@ -111,6 +108,39 @@ public abstract class BaseDDLIT extends SingleIT {
}
}
+ private List<DataSetColumn> getActualColumns(final Connection connection, final String tableName) throws SQLException {
+ DatabaseMetaData metaData = connection.getMetaData();
+ boolean isTableExisted = metaData.getTables(null, null, tableName, new String[] {"TABLE"}).next();
+ if (!isTableExisted) {
+ return Collections.emptyList();
+ }
+ try (ResultSet resultSet = metaData.getColumns(null, null, tableName, null)) {
+ List<DataSetColumn> result = new LinkedList<>();
+ while (resultSet.next()) {
+ DataSetColumn each = new DataSetColumn();
+ each.setName(resultSet.getString("COLUMN_NAME"));
+ each.setType(resultSet.getString("TYPE_NAME").toLowerCase());
+ result.add(each);
+ }
+ return result;
+ }
+ }
+
+ private List<DataSetIndex> getActualIndexes(final Connection connection, final String tableName) throws SQLException {
+ DatabaseMetaData metaData = connection.getMetaData();
+ try (ResultSet resultSet = metaData.getIndexInfo(null, null, tableName, false, false)) {
+ List<DataSetIndex> result = new LinkedList<>();
+ while (resultSet.next()) {
+ DataSetIndex each = new DataSetIndex();
+ each.setName(resultSet.getString("INDEX_NAME"));
+ each.setUnique(!resultSet.getBoolean("NON_UNIQUE"));
+ each.setColumns(resultSet.getString("COLUMN_NAME"));
+ result.add(each);
+ }
+ return result;
+ }
+ }
+
private void assertIfDropTable(final List<DataSetColumn> actualColumns) {
if (getSql().startsWith("DROP TABLE")) {
assertTrue(actualColumns.isEmpty());
@@ -145,39 +175,6 @@ public abstract class BaseDDLIT extends SingleIT {
}
}
- private List<DataSetColumn> getActualColumns(final Connection connection, final String tableName) throws SQLException {
- DatabaseMetaData metaData = connection.getMetaData();
- boolean isTableExisted = metaData.getTables(null, null, tableName, new String[] {"TABLE"}).next();
- if (!isTableExisted) {
- return Collections.emptyList();
- }
- try (ResultSet resultSet = metaData.getColumns(null, null, tableName, null)) {
- List<DataSetColumn> result = new LinkedList<>();
- while (resultSet.next()) {
- DataSetColumn each = new DataSetColumn();
- each.setName(resultSet.getString("COLUMN_NAME"));
- each.setType(resultSet.getString("TYPE_NAME").toLowerCase());
- result.add(each);
- }
- return result;
- }
- }
-
- private List<DataSetIndex> getActualIndexes(final Connection connection, final String tableName) throws SQLException {
- DatabaseMetaData metaData = connection.getMetaData();
- try (ResultSet resultSet = metaData.getIndexInfo(null, null, tableName, false, false)) {
- List<DataSetIndex> result = new LinkedList<>();
- while (resultSet.next()) {
- DataSetIndex each = new DataSetIndex();
- each.setName(resultSet.getString("INDEX_NAME"));
- each.setUnique(!resultSet.getBoolean("NON_UNIQUE"));
- each.setColumns(resultSet.getString("COLUMN_NAME"));
- result.add(each);
- }
- return result;
- }
- }
-
protected final void dropTableIfExisted(final Connection connection) {
try (PreparedStatement preparedStatement = connection.prepareStatement(String.format("DROP TABLE %s", ((DDLIntegrateTestCaseAssertion) getAssertion()).getTable()))) {
preparedStatement.executeUpdate();
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/ddl/GeneralDDLIT.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/ddl/GeneralDDLIT.java
index 18855e6..912eaf2 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/ddl/GeneralDDLIT.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/ddl/GeneralDDLIT.java
@@ -77,7 +77,7 @@ public final class GeneralDDLIT extends BaseDDLIT {
connection.prepareStatement(getSql()).execute();
}
}
- assertMetaData(connection);
+ assertTableMetaData(connection);
dropTableIfExisted(connection);
} catch (final SQLException ex) {
logException(ex);
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/dml/BaseDMLIT.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/dml/BaseDMLIT.java
index b6ec56e..f614354 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/dml/BaseDMLIT.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/dml/BaseDMLIT.java
@@ -30,6 +30,7 @@ import org.apache.shardingsphere.test.integration.cases.dataset.row.DataSetRow;
import org.apache.shardingsphere.test.integration.engine.SingleIT;
import org.apache.shardingsphere.test.integration.env.EnvironmentPath;
import org.apache.shardingsphere.test.integration.env.dataset.DataSetEnvironmentManager;
+import org.apache.shardingsphere.test.integration.env.schema.SchemaEnvironmentManager;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
@@ -59,22 +60,24 @@ public abstract class BaseDMLIT extends SingleIT {
protected BaseDMLIT(final String parentPath, final DMLIntegrateTestCaseAssertion assertion, final String ruleType,
final DatabaseType databaseType, final SQLCaseType caseType, final String sql) throws IOException, JAXBException, SQLException, ParseException {
super(parentPath, assertion, ruleType, databaseType, caseType, sql);
- dataSetEnvironmentManager = new DataSetEnvironmentManager(EnvironmentPath.getDataSetFile(getRuleType()), getActualDataSources());
+ dataSetEnvironmentManager = new DataSetEnvironmentManager(EnvironmentPath.getDataSetFile(ruleType), getActualDataSources());
}
@BeforeClass
- public static void initDatabasesAndTables() {
- setUpDatabasesAndTables();
+ public static void initDatabasesAndTables() throws IOException, JAXBException {
+ SchemaEnvironmentManager.createDatabases();
+ SchemaEnvironmentManager.dropTables();
+ SchemaEnvironmentManager.createTables();
}
@AfterClass
- public static void destroyDatabasesAndTables() {
- dropDatabases();
+ public static void destroyDatabasesAndTables() throws IOException, JAXBException {
+ SchemaEnvironmentManager.dropDatabases();
}
@Before
public void insertData() throws SQLException, ParseException {
- dataSetEnvironmentManager.initialize();
+ dataSetEnvironmentManager.load();
}
@After
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/dql/BaseDQLIT.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/dql/BaseDQLIT.java
index f60ff7e..5973955 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/dql/BaseDQLIT.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/dql/BaseDQLIT.java
@@ -62,7 +62,9 @@ public abstract class BaseDQLIT extends SingleIT {
@BeforeClass
public static void insertData() throws IOException, JAXBException, SQLException, ParseException {
- setUpDatabasesAndTables();
+ SchemaEnvironmentManager.createDatabases();
+ SchemaEnvironmentManager.dropTables();
+ SchemaEnvironmentManager.createTables();
for (DatabaseType each : IntegrateTestEnvironment.getInstance().getDatabaseEnvironments().keySet()) {
insertData(each);
}
@@ -70,13 +72,13 @@ public abstract class BaseDQLIT extends SingleIT {
private static void insertData(final DatabaseType databaseType) throws SQLException, ParseException, IOException, JAXBException {
for (String each : IntegrateTestEnvironment.getInstance().getRuleTypes()) {
- new DataSetEnvironmentManager(EnvironmentPath.getDataSetFile(each), createDataSourceMap(databaseType, each)).initialize();
+ new DataSetEnvironmentManager(EnvironmentPath.getDataSetFile(each), createDataSourceMap(databaseType, each)).load();
}
}
@AfterClass
- public static void clearData() {
- dropDatabases();
+ public static void clearData() throws IOException, JAXBException {
+ SchemaEnvironmentManager.dropDatabases();
}
private static Map<String, DataSource> createDataSourceMap(final DatabaseType databaseType, final String ruleType) throws IOException, JAXBException {
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/test/integration/env/dataset/DataSetEnvironmentManager.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/test/integration/env/dataset/DataSetEnvironmentManager.java
index b975ac7..5b9b167 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/test/integration/env/dataset/DataSetEnvironmentManager.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/test/integration/env/dataset/DataSetEnvironmentManager.java
@@ -78,12 +78,12 @@ public final class DataSetEnvironmentManager {
}
/**
- * Initialize data.
+ * Load data.
*
* @throws SQLException SQL exception
* @throws ParseException parse exception
*/
- public void initialize() throws SQLException, ParseException {
+ public void load() throws SQLException, ParseException {
Map<DataNode, List<DataSetRow>> dataNodeListMap = getDataSetRowMap();
List<Callable<Void>> insertTasks = new LinkedList<>();
for (Entry<DataNode, List<DataSetRow>> entry : dataNodeListMap.entrySet()) {
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/test/integration/env/schema/SchemaEnvironmentManager.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/test/integration/env/schema/SchemaEnvironmentManager.java
index 2198fe0..b367fb8 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/test/integration/env/schema/SchemaEnvironmentManager.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/test/integration/env/schema/SchemaEnvironmentManager.java
@@ -65,11 +65,17 @@ public final class SchemaEnvironmentManager {
/**
* Create databases.
*
- * @param ruleType rule type
* @throws IOException IO exception
* @throws JAXBException JAXB exception
*/
- public static void createDatabases(final String ruleType) throws IOException, JAXBException {
+ public static void createDatabases() throws IOException, JAXBException {
+ for (String each : IntegrateTestEnvironment.getInstance().getRuleTypes()) {
+ dropDatabases(each);
+ createDatabases(each);
+ }
+ }
+
+ private static void createDatabases(final String ruleType) throws IOException, JAXBException {
SchemaEnvironment schemaEnvironment = unmarshal(EnvironmentPath.getSchemaFile(ruleType));
for (DatabaseType each : IntegrateTestEnvironment.getInstance().getDatabaseEnvironments().keySet()) {
DataSource dataSource = JdbcDataSourceBuilder.build(null, each);
@@ -91,11 +97,16 @@ public final class SchemaEnvironmentManager {
/**
* Drop databases.
*
- * @param ruleType rule type
* @throws IOException IO exception
* @throws JAXBException JAXB exception
*/
- public static void dropDatabases(final String ruleType) throws IOException, JAXBException {
+ public static void dropDatabases() throws IOException, JAXBException {
+ for (String each : IntegrateTestEnvironment.getInstance().getRuleTypes()) {
+ dropDatabases(each);
+ }
+ }
+
+ private static void dropDatabases(final String ruleType) throws IOException, JAXBException {
SchemaEnvironment schemaEnvironment = unmarshal(EnvironmentPath.getSchemaFile(ruleType));
for (DatabaseType each : IntegrateTestEnvironment.getInstance().getDatabaseEnvironments().keySet()) {
DataSource dataSource = JdbcDataSourceBuilder.build(null, each);
@@ -126,11 +137,16 @@ public final class SchemaEnvironmentManager {
/**
* Create tables.
*
- * @param ruleType rule type
* @throws JAXBException JAXB exception
* @throws IOException IO exception
*/
- public static void createTables(final String ruleType) throws JAXBException, IOException {
+ public static void createTables() throws JAXBException, IOException {
+ for (String each : IntegrateTestEnvironment.getInstance().getRuleTypes()) {
+ createTables(each);
+ }
+ }
+
+ private static void createTables(final String ruleType) throws JAXBException, IOException {
SchemaEnvironment schemaEnvironment = unmarshal(EnvironmentPath.getSchemaFile(ruleType));
for (DatabaseType each : IntegrateTestEnvironment.getInstance().getDatabaseEnvironments().keySet()) {
createTables(schemaEnvironment, each);
@@ -147,11 +163,16 @@ public final class SchemaEnvironmentManager {
/**
* Drop tables.
*
- * @param ruleType rule type
* @throws JAXBException JAXB exception
* @throws IOException IO exception
*/
- public static void dropTables(final String ruleType) throws JAXBException, IOException {
+ public static void dropTables() throws JAXBException, IOException {
+ for (String each : IntegrateTestEnvironment.getInstance().getRuleTypes()) {
+ dropTables(each);
+ }
+ }
+
+ private static void dropTables(final String ruleType) throws JAXBException, IOException {
SchemaEnvironment schemaEnvironment = unmarshal(EnvironmentPath.getSchemaFile(ruleType));
for (DatabaseType each : IntegrateTestEnvironment.getInstance().getDatabaseEnvironments().keySet()) {
dropTables(schemaEnvironment, each);