Skip to content

Commit

Permalink
for #601: remove assert.path from env config
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu committed May 3, 2018
1 parent c15ec09 commit 497e3dd
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ public final class IntegrateTestEnvironment {

private final boolean initialized;

private final String assertPath;

private final Collection<DatabaseType> databaseTypes;

private IntegrateTestEnvironment() {
Expand All @@ -49,7 +47,6 @@ private IntegrateTestEnvironment() {
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", DatabaseType.H2.name()).split(",")) {
databaseTypes.add(DatabaseType.valueOf(each.trim()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

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;
Expand All @@ -40,14 +39,19 @@
import javax.xml.bind.JAXBException;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import static org.junit.Assert.assertNotNull;

@RunWith(Parameterized.class)
@RequiredArgsConstructor
public final class StartTest {

private static final String INTEGRATION_RESOURCES_PATH = "asserts";

private static boolean isInitialized = IntegrateTestEnvironment.getInstance().isInitialized();

private static boolean isCleaned = IntegrateTestEnvironment.getInstance().isInitialized();
Expand All @@ -60,9 +64,9 @@ public final class StartTest {

@Parameters(name = "{0} ({2}) -> {1}")
public static Collection<String[]> getParameters() throws IOException, JAXBException {
String assertPath = IntegrateTestEnvironment.getInstance().getAssertPath();
assertPath = PathUtil.getPath(assertPath);
List<String> paths = FileUtil.getAllFilePaths(new File(assertPath), "assert-", "xml");
URL integrateResources = StartTest.class.getClassLoader().getResource(INTEGRATION_RESOURCES_PATH);
assertNotNull(integrateResources);
List<String> paths = FileUtil.getAllFilePaths(new File(integrateResources.getPath()), "assert-", "xml");
for (String each : paths) {
AssertsDefinition assertsDefinition = AnalyzeConfig.analyze(each);
if (StringUtils.isNotBlank(assertsDefinition.getBaseConfig())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

public class PathUtil {

private static final String BASEPATH = PathUtil.class.getClassLoader().getResource("").getPath();
private static final String BASE_PATH = PathUtil.class.getClassLoader().getResource("").getPath();

/**
* Get the resource path.
Expand All @@ -34,27 +34,15 @@ public static String getPath(final String path, final String parent) {
if (path == null) {
throw new DbTestException("The path cannot be empty");
}

String result = path;
if (result.startsWith("classpath:")) {
result = result.substring("classpath:".length());
result = BASEPATH + result;
result = BASE_PATH + result;
return result;
}
if (parent != null) {
return parent + result;
}
return result;
}

/**
* Get the resource path.
*
* @param path path
* @return path
*/
public static String getPath(final String path) {
return getPath(path, null);
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
initialized=false
assert.path=classpath:asserts
#databases=H2,MySQL,Oracle,SQLServer,PostgreSQL
databases=H2

0 comments on commit 497e3dd

Please sign in to comment.