diff --git a/sharding-jdbc-core/src/test/java/io/shardingjdbc/dbtest/IntegrateTestRunningEnvironment.java b/sharding-jdbc-core/src/test/java/io/shardingjdbc/dbtest/IntegrateTestRunningEnvironment.java
new file mode 100644
index 0000000000000..316cce7009517
--- /dev/null
+++ b/sharding-jdbc-core/src/test/java/io/shardingjdbc/dbtest/IntegrateTestRunningEnvironment.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 1999-2015 dangdang.com.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package io.shardingjdbc.dbtest;
+
+import lombok.Getter;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.Properties;
+
+/**
+ * Integrate test running environment.
+ *
+ * @author zhangliang
+ */
+@Getter
+public final class IntegrateTestRunningEnvironment {
+
+ private static final IntegrateTestRunningEnvironment INSTANCE = new IntegrateTestRunningEnvironment();
+
+ private final boolean initialized;
+
+ private final String assertPath;
+
+ private final Collection databaseTypes;
+
+ private IntegrateTestRunningEnvironment() {
+ Properties prop = new Properties();
+ try {
+ prop.load(StartTest.class.getClassLoader().getResourceAsStream("integrate/env.properties"));
+ } catch (final IOException ex) {
+ ex.printStackTrace();
+ }
+ initialized = Boolean.valueOf(prop.getProperty("initialized", Boolean.FALSE.toString()));
+ assertPath = prop.getProperty("assert.path");
+ databaseTypes = new LinkedList<>();
+ for (String each : prop.getProperty("databases", "h2").split(",")) {
+ databaseTypes.add(each.trim());
+ }
+ }
+
+ /**
+ * Get instance.
+ *
+ * @return singleton instance
+ */
+ public static IntegrateTestRunningEnvironment getInstance() {
+ return INSTANCE;
+ }
+}
diff --git a/sharding-jdbc-core/src/test/java/io/shardingjdbc/dbtest/StartTest.java b/sharding-jdbc-core/src/test/java/io/shardingjdbc/dbtest/StartTest.java
index b7ab3a9c2c775..63e1a7ee74234 100644
--- a/sharding-jdbc-core/src/test/java/io/shardingjdbc/dbtest/StartTest.java
+++ b/sharding-jdbc-core/src/test/java/io/shardingjdbc/dbtest/StartTest.java
@@ -17,15 +17,18 @@
package io.shardingjdbc.dbtest;
-import java.io.File;
-import java.io.IOException;
-import java.util.*;
-
-import javax.xml.bind.JAXBException;
-
-import io.shardingjdbc.core.constant.DatabaseType;
-import io.shardingjdbc.dbtest.config.bean.*;
-import lombok.AllArgsConstructor;
+import io.shardingjdbc.dbtest.asserts.AssertEngine;
+import io.shardingjdbc.dbtest.common.FileUtil;
+import io.shardingjdbc.dbtest.common.PathUtil;
+import io.shardingjdbc.dbtest.config.AnalyzeConfig;
+import io.shardingjdbc.dbtest.config.bean.AssertDDLDefinition;
+import io.shardingjdbc.dbtest.config.bean.AssertDMLDefinition;
+import io.shardingjdbc.dbtest.config.bean.AssertDQLDefinition;
+import io.shardingjdbc.dbtest.config.bean.AssertDefinition;
+import io.shardingjdbc.dbtest.config.bean.AssertsDefinition;
+import io.shardingjdbc.dbtest.exception.DbTestException;
+import io.shardingjdbc.dbtest.init.InItCreateSchema;
+import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -34,57 +37,30 @@
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
-import io.shardingjdbc.dbtest.asserts.AssertEngine;
-import io.shardingjdbc.dbtest.common.FileUtil;
-import io.shardingjdbc.dbtest.common.PathUtil;
-import io.shardingjdbc.dbtest.config.AnalyzeConfig;
-import io.shardingjdbc.dbtest.exception.DbTestException;
-import io.shardingjdbc.dbtest.init.InItCreateSchema;
+import javax.xml.bind.JAXBException;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
-@RunWith(value = Parameterized.class)
-@AllArgsConstructor
+@RunWith(Parameterized.class)
+@RequiredArgsConstructor
public class StartTest {
- private String path;
-
- private String id;
+ private static boolean isInitialized = IntegrateTestRunningEnvironment.getInstance().isInitialized();
- private static Properties config = new Properties();
+ private static boolean isClean = IntegrateTestRunningEnvironment.getInstance().isInitialized();
private static final List RESULT_ASSERT = new ArrayList<>();
- static {
- try {
- config.load(StartTest.class.getClassLoader().getResourceAsStream("integrate/env.properties"));
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
+ private final String path;
- /**
- * query value.
- *
- * @param key key
- * @param defaultValue default Value
- * @return value
- */
- public static String getString(final String key, final String defaultValue) {
- return config.getProperty(key, defaultValue);
- }
+ private final String id;
- /**
- * query Assert Path.
- *
- * @return Assert Path
- */
- public static String getAssertPath() {
- return getString("assert.path", null);
- }
-
-
- @Parameters
+ @Parameters(name = "{0} ({2}) -> {1}")
public static Collection getParameters() {
- String assertPath = getAssertPath();
+ String assertPath = IntegrateTestRunningEnvironment.getInstance().getAssertPath();
assertPath = PathUtil.getPath(assertPath);
List paths = FileUtil.getAllFilePaths(new File(assertPath), "assert-", "xml");
@@ -136,10 +112,10 @@ private static void collateData(final List DEFAULT_DATABASES = Arrays.asList("db", "dbtbl", "nullable");
- @Getter
- @Setter
- private static volatile boolean initialized;
-
- @Getter
- @Setter
- private static volatile boolean clean;
-
- @Getter
- @Setter
- private static final List databases = new ArrayList<>();
-
- static {
- initialized = Boolean.valueOf(StartTest.getString("initialized", "false"));
- clean = Boolean.valueOf(StartTest.getString("initialized", "false"));
- String databasesStr = StartTest.getString("databases", "h2,mysql,oracle,sqlserver,postgresql");
- String[] databaseLocals = StringUtils.split(databasesStr, ",");
- for (String database : databaseLocals) {
- databases.add(database);
- }
- }
-
/**
* add check use cases.
*
diff --git a/sharding-jdbc-core/src/test/java/io/shardingjdbc/dbtest/init/InItCreateSchema.java b/sharding-jdbc-core/src/test/java/io/shardingjdbc/dbtest/init/InItCreateSchema.java
index e3055e55c4275..1d747f5d08233 100644
--- a/sharding-jdbc-core/src/test/java/io/shardingjdbc/dbtest/init/InItCreateSchema.java
+++ b/sharding-jdbc-core/src/test/java/io/shardingjdbc/dbtest/init/InItCreateSchema.java
@@ -17,15 +17,9 @@
package io.shardingjdbc.dbtest.init;
-import java.io.*;
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.*;
-
+import io.shardingjdbc.core.constant.DatabaseType;
import io.shardingjdbc.core.yaml.sharding.YamlShardingConfiguration;
-import io.shardingjdbc.dbtest.StartTest;
-import io.shardingjdbc.dbtest.asserts.AssertEngine;
+import io.shardingjdbc.dbtest.IntegrateTestRunningEnvironment;
import io.shardingjdbc.dbtest.common.DatabaseEnvironment;
import io.shardingjdbc.dbtest.common.FileUtil;
import io.shardingjdbc.dbtest.common.PathUtil;
@@ -33,19 +27,29 @@
import io.shardingjdbc.dbtest.config.AnalyzeSql;
import io.shardingjdbc.test.sql.SQLCasesLoader;
import lombok.Getter;
-import lombok.Setter;
import org.apache.commons.dbcp2.BasicDataSource;
import org.apache.commons.lang3.StringUtils;
import org.h2.tools.RunScript;
-
-import io.shardingjdbc.core.constant.DatabaseType;
import org.xml.sax.SAXException;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.Constructor;
-import javax.sql.DataSource;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPathExpressionException;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.StringReader;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
public class InItCreateSchema {
@@ -64,7 +68,7 @@ public static void addDatabase(String database) {
}
static {
- String assertPath = StartTest.getAssertPath();
+ String assertPath = IntegrateTestRunningEnvironment.getInstance().getAssertPath();
assertPath = PathUtil.getPath(assertPath);
List paths = FileUtil.getAllFilePaths(new File(assertPath), "t", "yaml");
try {
@@ -475,7 +479,7 @@ private static Connection initialConnection(final String dbName, final DatabaseT
*/
public static Set getDatabaseSchema() throws IOException {
Set dbset = new HashSet<>();
- for (String each : AssertEngine.getDatabases()) {
+ for (String each : IntegrateTestRunningEnvironment.getInstance().getDatabaseTypes()) {
DatabaseType databaseType = getDatabaseType(each);
dbset.add(databaseType);
}