Skip to content

Commit

Permalink
for #601: add default value for AssertsDefinition.baseConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu committed May 4, 2018
1 parent ee2d6e5 commit ca88439
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

package io.shardingjdbc.dbtest;

import com.google.common.base.Strings;
import io.shardingjdbc.dbtest.asserts.AssertEngine;
import io.shardingjdbc.dbtest.config.bean.AssertDDLDefinition;
import io.shardingjdbc.dbtest.config.bean.AssertDMLDefinition;
Expand Down Expand Up @@ -76,15 +75,9 @@ public static Collection<String[]> getParameters() throws IOException, JAXBExcep
assertNotNull(integrateResources);
for (String each : getAssertFiles(integrateResources)) {
AssertsDefinition assertsDefinition = unmarshal(each);
if (!Strings.isNullOrEmpty(assertsDefinition.getBaseConfig())) {
String[] dbs = assertsDefinition.getBaseConfig().split(",");
for (String db : dbs) {
InItCreateSchema.addDatabase(db);
}
} else {
for (String db : AssertEngine.DEFAULT_DATABASES) {
InItCreateSchema.addDatabase(db);
}
String[] dbs = assertsDefinition.getBaseConfig().split(",");
for (String db : dbs) {
InItCreateSchema.addDatabase(db);
}
List<AssertDQLDefinition> assertDQLs = assertsDefinition.getAssertDQL();
collateData(RESULT_ASSERT, each, assertDQLs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@
import java.sql.SQLException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand All @@ -59,8 +57,6 @@ public class AssertEngine {

public static final Map<String, AssertsDefinition> ASSERT_DEFINITION_MAPS = new HashMap<>();

public static final List<String> DEFAULT_DATABASES = Arrays.asList("db", "dbtbl", "nullable");

/**
* add check use cases.
*
Expand All @@ -83,15 +79,7 @@ public static boolean runAssert(final String path, final String id) {
String rootPath = path.substring(0, path.lastIndexOf(File.separator) + 1);
try {
String msg = "The file path " + path + ", under which id is " + id;

List<String> dbNames = new ArrayList<>();
if (StringUtils.isNotBlank(assertsDefinition.getBaseConfig())) {
String[] dbs = StringUtils.split(assertsDefinition.getBaseConfig(), ",");
Collections.addAll(dbNames, dbs);
} else {
dbNames.addAll(AssertEngine.DEFAULT_DATABASES);
}
for (String each : dbNames) {
for (String each : assertsDefinition.getBaseConfig().split(",")) {
String initDataFile = rootPath + assertsDefinition.getInitDataFile();
String initDataPath = initDataFile + "/" + each;
File fileDirDatabase = new File(initDataPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class AssertsDefinition {
private String shardingRuleConfig;

@XmlAttribute(name = "base-config")
private String baseConfig;
private String baseConfig = "db,dbtbl,nullable";

@XmlAttribute(name = "database-config")
private String databaseConfig;
Expand Down

0 comments on commit ca88439

Please sign in to comment.