Skip to content

Commit

Permalink
for #601: remove AnalyzeConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu committed May 4, 2018
1 parent 761f1f3 commit b2ed5d1
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package io.shardingjdbc.dbtest;

import io.shardingjdbc.dbtest.asserts.AssertEngine;
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;
Expand All @@ -35,7 +34,10 @@
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import java.io.FileReader;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
Expand Down Expand Up @@ -73,7 +75,7 @@ public static Collection<String[]> getParameters() throws IOException, JAXBExcep
URL integrateResources = StartTest.class.getClassLoader().getResource(INTEGRATION_RESOURCES_PATH);
assertNotNull(integrateResources);
for (String each : getAssertFiles(integrateResources)) {
AssertsDefinition assertsDefinition = AnalyzeConfig.analyze(each);
AssertsDefinition assertsDefinition = unmarshal(each);
if (StringUtils.isNotBlank(assertsDefinition.getBaseConfig())) {
String[] dbs = StringUtils.split(assertsDefinition.getBaseConfig(), ",");
for (String db : dbs) {
Expand Down Expand Up @@ -110,6 +112,13 @@ public FileVisitResult visitFile(final Path file, final BasicFileAttributes basi
return result;
}

private static AssertsDefinition unmarshal(final String assertFilePath) throws IOException, JAXBException {
Unmarshaller unmarshal = JAXBContext.newInstance(AssertsDefinition.class).createUnmarshaller();
try (FileReader reader = new FileReader(assertFilePath)) {
return (AssertsDefinition) unmarshal.unmarshal(reader);
}
}

private static <T extends AssertDefinition> void collateData(final List<String[]> result, final String path, final List<T> asserts) {
if (asserts == null) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ public static void addAssertDefinition(final String assertPath, final AssertsDef
public static boolean runAssert(final String path, final String id) {
AssertsDefinition assertsDefinition = ASSERT_DEFINITION_MAPS.get(path);
String rootPath = path.substring(0, path.lastIndexOf(File.separator) + 1);
assertsDefinition.setPath(rootPath);
try {
String msg = "The file path " + path + ", under which id is " + id;

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,13 @@

package io.shardingjdbc.dbtest.config.bean;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import lombok.Getter;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import io.shardingjdbc.core.constant.DatabaseType;
import lombok.Getter;
import lombok.Setter;
import java.util.ArrayList;
import java.util.List;

@Getter
@XmlRootElement(name = "asserts")
Expand All @@ -48,12 +44,6 @@ public class AssertsDefinition {
@XmlAttribute(name = "init-data-file")
private String initDataFile;

@Setter
private String path;

@Setter
private String pathBaseCofig;

@XmlElement(name = "assertDQL")
private List<AssertDQLDefinition> assertDQL = new ArrayList<>();

Expand Down

0 comments on commit b2ed5d1

Please sign in to comment.