(chore) load from jar test case added

This commit is contained in:
Andreas Penski (init) 2020-08-11 17:28:54 +02:00
parent 183ddab179
commit 4e48730c71
10 changed files with 43 additions and 17 deletions

View file

@ -116,7 +116,7 @@ public class ContentRepositoryTest {
public void loadFromJar() throws URISyntaxException {
assert Helper.JAR_REPOSITORY != null;
this.repository = new ContentRepository(ResolvingMode.STRICT_RELATIVE.getStrategy(), Helper.JAR_REPOSITORY.toURI());
final XsltExecutable xsltExecutable = this.repository.loadXsltScript(URI.create("resources/eRechnung/report.xsl"));
final XsltExecutable xsltExecutable = this.repository.loadXsltScript(URI.create("report.xsl"));
assertThat(xsltExecutable).isNotNull();
}

View file

@ -27,8 +27,10 @@ import static de.kosit.validationtool.impl.Helper.Simple.REJECTED;
import static de.kosit.validationtool.impl.Helper.Simple.SCHEMATRON_INVALID;
import static de.kosit.validationtool.impl.Helper.Simple.SIMPLE_VALID;
import static de.kosit.validationtool.impl.Helper.Simple.UNKNOWN;
import static java.util.Objects.requireNonNull;
import static org.assertj.core.api.Assertions.assertThat;
import java.net.URISyntaxException;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
@ -57,13 +59,22 @@ public class DefaultCheckTest {
// for checking certain error scenarios.
private DefaultCheck errorCheck;
private DefaultCheck jarScenarioCheck;
@Before
public void setup() {
public void setup() throws URISyntaxException {
final Configuration validConfig = Configuration.load(Simple.SCENARIOS, Simple.REPOSITORY_URI).build();
this.validCheck = new DefaultCheck(validConfig);
final Configuration errorConfig = Configuration.load(Simple.ERROR_SCENARIOS, Simple.REPOSITORY_URI).build();
this.errorCheck = new DefaultCheck(errorConfig);
final Configuration jarConfig = Configuration
.load(requireNonNull(DefaultCheckTest.class.getClassLoader().getResource("simple/packaged/scenarios.xml")).toURI(),
requireNonNull(DefaultCheckTest.class.getClassLoader().getResource("simple/packaged/repository/")).toURI())
.build();
this.jarScenarioCheck = new DefaultCheck(jarConfig);
}
@Test
@ -77,6 +88,17 @@ public class DefaultCheckTest {
assertThat(doc.getAcceptRecommendation()).isEqualTo(AcceptRecommendation.ACCEPTABLE);
}
@Test
public void testJarCase() {
final Result doc = this.jarScenarioCheck.checkInput(read(SIMPLE_VALID));
assertThat(doc).isNotNull();
assertThat(doc.getReport()).isNotNull();
assertThat(doc.isAcceptable()).isTrue();
assertThat(doc.isSchematronValid()).isTrue();
assertThat(doc.isSchemaValid()).isTrue();
assertThat(doc.getAcceptRecommendation()).isEqualTo(AcceptRecommendation.ACCEPTABLE);
}
@Test
public void testWithoutAcceptMatch() {
final Result doc = this.validCheck.checkInput(read(Simple.FOO));

View file

@ -123,7 +123,7 @@ public class Helper {
public static final URI ASSERTIONS = EXAMPLES_DIR.resolve("assertions/tests-xrechnung.xml");
public static final URL JAR_REPOSITORY = Helper.class.getClassLoader().getResource("xrechnung/repository/");
public static final URL JAR_REPOSITORY = Helper.class.getClassLoader().getResource("simple/packaged/repository/");
/**
* Lädt ein XML-Dokument von der gegebenen URL