mirror of
https://github.com/itplr-kosit/validator.git
synced 2026-05-26 01:05:38 +00:00
(enhance) ContentRepository is only based on uri and strategy
This commit is contained in:
parent
35c0797898
commit
7ca3ef90f3
9 changed files with 38 additions and 42 deletions
|
|
@ -114,7 +114,8 @@ public class ContentRepositoryTest {
|
|||
|
||||
@Test
|
||||
public void loadFromJar() throws URISyntaxException {
|
||||
this.repository = new ContentRepository(TestObjectFactory.createProcessor(), Helper.JAR_REPOSITORY.toURI(), null);
|
||||
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"));
|
||||
assertThat(xsltExecutable).isNotNull();
|
||||
}
|
||||
|
|
@ -122,6 +123,7 @@ public class ContentRepositoryTest {
|
|||
@Test
|
||||
public void testLoadSchema() {
|
||||
final URL main = RelativeUriResolverTest.class.getClassLoader().getResource("loading/main.xsd");
|
||||
assert main != null;
|
||||
final Schema schema = this.repository.createSchema(main, new ClassPathResourceResolver("/loading"));
|
||||
assertThat(schema).isNotNull();
|
||||
}
|
||||
|
|
@ -129,6 +131,7 @@ public class ContentRepositoryTest {
|
|||
@Test
|
||||
public void testLoadSchemaPackaged() throws URISyntaxException {
|
||||
final URL main = RelativeUriResolverTest.class.getClassLoader().getResource("packaged/main.xsd");
|
||||
assert main != null;
|
||||
final Schema schema = this.repository.createSchema(main,
|
||||
new ClassPathResourceResolver(RelativeUriResolverTest.class.getClassLoader().getResource("packaged/").toURI()));
|
||||
assertThat(schema).isNotNull();
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ import net.sf.saxon.s9api.XdmNode;
|
|||
*/
|
||||
|
||||
public class Helper {
|
||||
|
||||
public static class Simple {
|
||||
|
||||
public static final URI ROOT = EXAMPLES_DIR.resolve("simple/");
|
||||
|
|
@ -83,12 +84,9 @@ public class Helper {
|
|||
|
||||
public static final ContentRepository createContentRepository() {
|
||||
final ResolvingConfigurationStrategy strategy = ResolvingMode.STRICT_RELATIVE.getStrategy();
|
||||
final ContentRepository rep = new ContentRepository(TestObjectFactory.createProcessor(), Simple.REPOSITORY_URI,
|
||||
strategy.createResolver(Simple.REPOSITORY_URI));
|
||||
rep.setResolvingConfigurationStrategy(strategy);
|
||||
rep.setSchemaFactory(strategy.createSchemaFactory());
|
||||
return rep;
|
||||
return new ContentRepository(strategy, Simple.REPOSITORY_URI);
|
||||
}
|
||||
|
||||
public static URI getSchemaLocation() {
|
||||
return ROOT.resolve("repository/simple.xsd");
|
||||
}
|
||||
|
|
@ -103,27 +101,18 @@ public class Helper {
|
|||
public static final URI SCENARIOS_ILLFORMED = ROOT.resolve("scenarios-illformed.xml");
|
||||
}
|
||||
|
||||
|
||||
public static final URI MODEL_ROOT = Paths.get("src/main/model").toUri();
|
||||
|
||||
public static final URI ASSERTION_SCHEMA = MODEL_ROOT.resolve("xsd/assertions.xsd");
|
||||
|
||||
|
||||
public static final URI TEST_ROOT = Paths.get("src/test/resources").toUri();
|
||||
|
||||
public static final URI EXAMPLES_DIR = TEST_ROOT.resolve("examples/");
|
||||
|
||||
public static final URI ASSERTIONS = EXAMPLES_DIR.resolve("assertions/tests-xrechnung.xml");
|
||||
|
||||
|
||||
|
||||
public static final URL JAR_REPOSITORY = Helper.class.getClassLoader().getResource("xrechnung/repository/");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Lädt ein XML-Dokument von der gegebenen URL
|
||||
*
|
||||
|
|
@ -154,7 +143,8 @@ public class Helper {
|
|||
* @return ein {@link ContentRepository}
|
||||
*/
|
||||
public static ContentRepository loadTestRepository() {
|
||||
return new ContentRepository(TestObjectFactory.createProcessor(), new File("src/test/resources/examples/repository").toURI(), null);
|
||||
return new ContentRepository(ResolvingMode.STRICT_RELATIVE.getStrategy(),
|
||||
new File("src/test/resources/examples/repository").toURI());
|
||||
}
|
||||
|
||||
public static String serialize(final Document doc) {
|
||||
|
|
|
|||
|
|
@ -139,6 +139,6 @@ public class ScenarioRepositoryTest {
|
|||
}
|
||||
|
||||
private static XPathExecutable createXpath(final String expression) {
|
||||
return new ContentRepository(TestObjectFactory.createProcessor(), null, null).createXPath(expression, new HashMap<>());
|
||||
return new ContentRepository(ResolvingMode.STRICT_RELATIVE.getStrategy(), null).createXPath(expression, new HashMap<>());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import org.junit.Test;
|
|||
|
||||
import de.kosit.validationtool.api.AcceptRecommendation;
|
||||
import de.kosit.validationtool.impl.ContentRepository;
|
||||
import de.kosit.validationtool.impl.TestObjectFactory;
|
||||
import de.kosit.validationtool.impl.ResolvingMode;
|
||||
import de.kosit.validationtool.impl.tasks.CheckAction.Bag;
|
||||
|
||||
import net.sf.saxon.s9api.XPathExecutable;
|
||||
|
|
@ -105,6 +105,6 @@ public class ComputeAcceptanceActionTest {
|
|||
|
||||
|
||||
private static XPathExecutable createXpath(final String expression) {
|
||||
return new ContentRepository(TestObjectFactory.createProcessor(), null, null).createXPath(expression, new HashMap<>());
|
||||
return new ContentRepository(ResolvingMode.STRICT_RELATIVE.getStrategy(), null).createXPath(expression, new HashMap<>());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ import de.kosit.validationtool.impl.ContentRepository;
|
|||
import de.kosit.validationtool.impl.Helper;
|
||||
import de.kosit.validationtool.impl.ResolvingMode;
|
||||
import de.kosit.validationtool.impl.Scenario;
|
||||
import de.kosit.validationtool.impl.TestObjectFactory;
|
||||
import de.kosit.validationtool.impl.model.Result;
|
||||
import de.kosit.validationtool.impl.tasks.CheckAction.Bag;
|
||||
import de.kosit.validationtool.model.reportInput.CreateReportInput;
|
||||
|
|
@ -74,8 +73,7 @@ public class TestBagBuilder {
|
|||
}
|
||||
|
||||
private static Schema createSchema(final URL toURL) {
|
||||
final ContentRepository contentRepository = new ContentRepository(TestObjectFactory.createProcessor(), null, null);
|
||||
contentRepository.setSchemaFactory(ResolvingMode.STRICT_RELATIVE.getStrategy().createSchemaFactory());
|
||||
final ContentRepository contentRepository = new ContentRepository(ResolvingMode.STRICT_RELATIVE.getStrategy(), null);
|
||||
return contentRepository.createSchema(toURL);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue