mirror of
https://github.com/itplr-kosit/validator.git
synced 2026-05-26 01:05:38 +00:00
(enhance) introduce resolving strategy (configurable xml security); introduce API configuration
This commit is contained in:
parent
7a86f049ac
commit
35c0797898
67 changed files with 2441 additions and 845 deletions
|
|
@ -55,7 +55,7 @@ public class ContentRepositoryTest {
|
|||
|
||||
@Before
|
||||
public void setup() {
|
||||
this.repository = new ContentRepository(ObjectFactory.createProcessor(), Simple.REPOSITORY);
|
||||
this.repository = Simple.createContentRepository();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -114,7 +114,7 @@ public class ContentRepositoryTest {
|
|||
|
||||
@Test
|
||||
public void loadFromJar() throws URISyntaxException {
|
||||
this.repository = new ContentRepository(ObjectFactory.createProcessor(), Helper.JAR_REPOSITORY.toURI());
|
||||
this.repository = new ContentRepository(TestObjectFactory.createProcessor(), Helper.JAR_REPOSITORY.toURI(), null);
|
||||
final XsltExecutable xsltExecutable = this.repository.loadXsltScript(URI.create("resources/eRechnung/report.xsl"));
|
||||
assertThat(xsltExecutable).isNotNull();
|
||||
}
|
||||
|
|
@ -136,7 +136,7 @@ public class ContentRepositoryTest {
|
|||
|
||||
// @Test
|
||||
// public void loadFromJar() throws URISyntaxException {
|
||||
// this.content = new ContentRepository(ObjectFactory.createProcessor(), Helper.JAR_REPOSITORY.toURI());
|
||||
// this.content = new ContentRepository(TestObjectFactory.createProcessor(), Helper.JAR_REPOSITORY.toURI());
|
||||
// this.repository = new ScenarioRepository(this.content);
|
||||
// final CheckConfiguration conf = new CheckConfiguration(
|
||||
// ScenarioRepository.class.getClassLoader().getResource("xrechnung/scenarios.xml").toURI());
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ package de.kosit.validationtool.impl;
|
|||
|
||||
import static org.assertj.core.api.Java6Assertions.assertThat;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
|
|
@ -54,8 +53,7 @@ public class ConversionServiceTest {
|
|||
@Before
|
||||
public void setup() {
|
||||
this.service = new ConversionService();
|
||||
this.repository = new ContentRepository(ObjectFactory.createProcessor(),
|
||||
new File("src/test/resources/examples/repository").toURI());
|
||||
this.repository = Simple.createContentRepository();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ public class DefaultCheckTest {
|
|||
@Before
|
||||
public void setup() {
|
||||
final CheckConfiguration d = new CheckConfiguration(Simple.SCENARIOS);
|
||||
d.setScenarioRepository(new File(Simple.REPOSITORY).toURI());
|
||||
d.setScenarioRepository(new File(Simple.REPOSITORY_URI).toURI());
|
||||
this.implementation = new DefaultCheck(d);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ import org.junit.rules.ExpectedException;
|
|||
|
||||
import de.kosit.validationtool.impl.Helper.Simple;
|
||||
import de.kosit.validationtool.impl.model.Result;
|
||||
import de.kosit.validationtool.impl.tasks.DocumentParseAction;
|
||||
import de.kosit.validationtool.model.reportInput.XMLSyntaxError;
|
||||
|
||||
import net.sf.saxon.s9api.XdmNode;
|
||||
|
|
@ -45,7 +44,7 @@ public class DocumentParserTest {
|
|||
|
||||
@Test
|
||||
public void testSimple() {
|
||||
final Result<XdmNode, XMLSyntaxError> result = DocumentParseAction.parseDocument(read(Simple.SIMPLE_VALID));
|
||||
final Result<XdmNode, XMLSyntaxError> result = Helper.parseDocument(read(Simple.SIMPLE_VALID));
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.getObject()).isNotNull();
|
||||
assertThat(result.getErrors()).isEmpty();
|
||||
|
|
@ -54,7 +53,7 @@ public class DocumentParserTest {
|
|||
|
||||
@Test
|
||||
public void testIllformed() {
|
||||
final Result<XdmNode, XMLSyntaxError> result = DocumentParseAction.parseDocument(read(Simple.NOT_WELLFORMED));
|
||||
final Result<XdmNode, XMLSyntaxError> result = Helper.parseDocument(read(Simple.NOT_WELLFORMED));
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.getErrors()).isNotEmpty();
|
||||
assertThat(result.getObject()).isNull();
|
||||
|
|
@ -64,7 +63,7 @@ public class DocumentParserTest {
|
|||
@Test
|
||||
public void testNullInput() {
|
||||
this.exception.expect(IllegalArgumentException.class);
|
||||
DocumentParseAction.parseDocument(null);
|
||||
Helper.parseDocument(null);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,12 @@ import javax.xml.transform.stream.StreamSource;
|
|||
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
import de.kosit.validationtool.api.Input;
|
||||
import de.kosit.validationtool.api.ResolvingConfigurationStrategy;
|
||||
import de.kosit.validationtool.impl.model.Result;
|
||||
import de.kosit.validationtool.impl.tasks.DocumentParseAction;
|
||||
import de.kosit.validationtool.model.reportInput.XMLSyntaxError;
|
||||
|
||||
import net.sf.saxon.dom.NodeOverNodeInfo;
|
||||
import net.sf.saxon.s9api.SaxonApiException;
|
||||
import net.sf.saxon.s9api.XdmNode;
|
||||
|
|
@ -61,7 +67,7 @@ public class Helper {
|
|||
|
||||
public static final URI SCENARIOS = ROOT.resolve("scenarios.xml");
|
||||
|
||||
public static final URI REPOSITORY = ROOT.resolve("repository/");
|
||||
public static final URI REPOSITORY_URI = ROOT.resolve("repository/");
|
||||
|
||||
public static final URI INVALID = ROOT.resolve("input/simple-invalid.xml");
|
||||
|
||||
|
|
@ -73,8 +79,16 @@ public class Helper {
|
|||
|
||||
public static final URI NOT_EXISTING = EXAMPLES_DIR.resolve("doesnotexist");
|
||||
|
||||
public static final URI REPORT_XSL = REPOSITORY.resolve("report.xsl");
|
||||
public static final URI REPORT_XSL = REPOSITORY_URI.resolve("report.xsl");
|
||||
|
||||
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;
|
||||
}
|
||||
public static URI getSchemaLocation() {
|
||||
return ROOT.resolve("repository/simple.xsd");
|
||||
}
|
||||
|
|
@ -118,7 +132,7 @@ public class Helper {
|
|||
*/
|
||||
public static XdmNode load(final URL url) {
|
||||
try ( final InputStream input = url.openStream() ) {
|
||||
return ObjectFactory.createProcessor().newDocumentBuilder().build(new StreamSource(input));
|
||||
return TestObjectFactory.createProcessor().newDocumentBuilder().build(new StreamSource(input));
|
||||
} catch (final SaxonApiException | IOException e) {
|
||||
throw new IllegalStateException("Fehler beim Laden der XML-Datei", e);
|
||||
|
||||
|
|
@ -140,12 +154,12 @@ public class Helper {
|
|||
* @return ein {@link ContentRepository}
|
||||
*/
|
||||
public static ContentRepository loadTestRepository() {
|
||||
return new ContentRepository(ObjectFactory.createProcessor(), new File("src/test/resources/examples/repository").toURI());
|
||||
return new ContentRepository(TestObjectFactory.createProcessor(), new File("src/test/resources/examples/repository").toURI(), null);
|
||||
}
|
||||
|
||||
public static String serialize(final Document doc) {
|
||||
try ( final StringWriter writer = new StringWriter() ) {
|
||||
final Transformer transformer = ObjectFactory.createTransformer(true);
|
||||
final Transformer transformer = TestObjectFactory.createTransformer(true);
|
||||
transformer.transform(new DOMSource(doc), new StreamResult(writer));
|
||||
return writer.toString();
|
||||
} catch (final IOException | TransformerException e) {
|
||||
|
|
@ -157,4 +171,7 @@ public class Helper {
|
|||
return serialize((Document) NodeOverNodeInfo.wrap(node.getUnderlyingNode()));
|
||||
}
|
||||
|
||||
public static Result<XdmNode, XMLSyntaxError> parseDocument(final Input input) {
|
||||
return new DocumentParseAction(TestObjectFactory.createProcessor()).parseDocument(input);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@ import org.junit.Rule;
|
|||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import de.kosit.validationtool.impl.xml.RelativeUriResolver;
|
||||
|
||||
/**
|
||||
* Testet den Uri-Resolver der relative auflösen soll
|
||||
*
|
||||
|
|
@ -63,13 +65,13 @@ public class RelativeUriResolverTest {
|
|||
|
||||
@Test
|
||||
public void testNotExisting() throws TransformerException {
|
||||
this.exception.expect(IllegalStateException.class);
|
||||
this.exception.expect(TransformerException.class);
|
||||
this.resolver.resolve("ubl-0001", BASE.toASCIIString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOutOfPath() throws TransformerException {
|
||||
this.exception.expect(IllegalStateException.class);
|
||||
this.exception.expect(TransformerException.class);
|
||||
this.resolver.resolve("../results/report.xml", BASE.toASCIIString());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,21 +35,19 @@ import org.w3c.dom.Document;
|
|||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import de.kosit.validationtool.api.InputFactory;
|
||||
import de.kosit.validationtool.impl.Helper.Simple;
|
||||
import de.kosit.validationtool.impl.model.Result;
|
||||
import de.kosit.validationtool.impl.xml.RelativeUriResolver;
|
||||
import de.kosit.validationtool.model.reportInput.XMLSyntaxError;
|
||||
|
||||
import net.sf.saxon.s9api.DOMDestination;
|
||||
import net.sf.saxon.s9api.Processor;
|
||||
import net.sf.saxon.s9api.SaxonApiException;
|
||||
import net.sf.saxon.s9api.XdmNode;
|
||||
import net.sf.saxon.s9api.XsltCompiler;
|
||||
import net.sf.saxon.s9api.XsltExecutable;
|
||||
import net.sf.saxon.s9api.XsltTransformer;
|
||||
import de.kosit.validationtool.api.InputFactory;
|
||||
import de.kosit.validationtool.impl.model.Result;
|
||||
import de.kosit.validationtool.impl.tasks.DocumentParseAction;
|
||||
import de.kosit.validationtool.model.reportInput.XMLSyntaxError;
|
||||
|
||||
|
||||
import net.sf.saxon.s9api.XdmNode;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -62,19 +60,19 @@ public class SaxonSecurityTest {
|
|||
|
||||
@Test
|
||||
public void testEvilStylesheets() throws IOException {
|
||||
final Processor p = ObjectFactory.createProcessor();
|
||||
final Processor p = TestObjectFactory.createProcessor();
|
||||
for (int i = 1; i <= 5; i++) {
|
||||
try {
|
||||
final URL resource = SaxonSecurityTest.class.getResource(String.format("/evil/evil%s.xsl", i));
|
||||
final XsltCompiler compiler = p.newXsltCompiler();
|
||||
final RelativeUriResolver resolver = new RelativeUriResolver(Simple.REPOSITORY);
|
||||
final RelativeUriResolver resolver = new RelativeUriResolver(Simple.REPOSITORY_URI);
|
||||
compiler.setURIResolver(resolver);
|
||||
final XsltExecutable exetuable = compiler.compile(new StreamSource(resource.openStream()));
|
||||
final XsltTransformer transformer = exetuable.load();
|
||||
final Document document = ObjectFactory.createDocumentBuilder(false).newDocument();
|
||||
final Document document = TestObjectFactory.createDocumentBuilder(false).newDocument();
|
||||
document.createElement("root");
|
||||
final Document result = ObjectFactory.createDocumentBuilder(false).newDocument();
|
||||
transformer.getUnderlyingController().setUnparsedTextURIResolver(resolver);
|
||||
final Document result = TestObjectFactory.createDocumentBuilder(false).newDocument();
|
||||
// transformer.getUnderlyingController().setUnparsedTextURIResolver(resolver);
|
||||
transformer.setURIResolver(resolver);
|
||||
transformer.setSource(new DOMSource(document));
|
||||
transformer.setDestination(new DOMDestination(result));
|
||||
|
|
@ -94,7 +92,7 @@ public class SaxonSecurityTest {
|
|||
@Test
|
||||
public void testXxe() {
|
||||
final URL resource = SaxonSecurityTest.class.getResource("/evil/xxe.xml");
|
||||
final Result<XdmNode, XMLSyntaxError> result = DocumentParseAction.parseDocument(InputFactory.read(resource));
|
||||
final Result<XdmNode, XMLSyntaxError> result = Helper.parseDocument(InputFactory.read(resource));
|
||||
assertThat(result.isValid()).isFalse();
|
||||
assertThat(result.getObject()).isNull();
|
||||
assertThat(result.getErrors().stream().map(XMLSyntaxError::getMessage).collect(Collectors.joining()))
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import java.net.URI;
|
|||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
|
|
@ -38,7 +39,6 @@ import lombok.Data;
|
|||
import de.kosit.validationtool.api.Configuration;
|
||||
import de.kosit.validationtool.impl.Helper.Simple;
|
||||
import de.kosit.validationtool.impl.model.Result;
|
||||
import de.kosit.validationtool.impl.tasks.DocumentParseAction;
|
||||
import de.kosit.validationtool.model.scenarios.ScenarioType;
|
||||
|
||||
import net.sf.saxon.s9api.Processor;
|
||||
|
|
@ -70,10 +70,8 @@ public class ScenarioRepositoryTest {
|
|||
|
||||
private ContentRepository contentRepository;
|
||||
|
||||
@Override
|
||||
public void build() {
|
||||
// nothing
|
||||
}
|
||||
private Map<String, Object> additionalParameters;
|
||||
|
||||
}
|
||||
|
||||
@Rule
|
||||
|
|
@ -137,11 +135,10 @@ public class ScenarioRepositoryTest {
|
|||
}
|
||||
|
||||
private static XdmNode load(final URI uri) throws IOException {
|
||||
final DocumentParseAction p = new DocumentParseAction();
|
||||
return DocumentParseAction.parseDocument(read(uri.toURL())).getObject();
|
||||
return Helper.parseDocument(read(uri.toURL())).getObject();
|
||||
}
|
||||
|
||||
private static XPathExecutable createXpath(final String expression) {
|
||||
return new ContentRepository(ObjectFactory.createProcessor(), null).createXPath(expression, new HashMap<>());
|
||||
return new ContentRepository(TestObjectFactory.createProcessor(), null, null).createXPath(expression, new HashMap<>());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ public class SimpleScenarioCheckTest {
|
|||
@Before
|
||||
public void setup() {
|
||||
final CheckConfiguration d = new CheckConfiguration(Simple.SCENARIOS);
|
||||
d.setScenarioRepository(Simple.REPOSITORY);
|
||||
d.setScenarioRepository(Simple.REPOSITORY_URI);
|
||||
this.implementation = new DefaultCheck(d);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
package de.kosit.validationtool.impl;
|
||||
|
||||
/**
|
||||
* @author Andreas Penski
|
||||
*/
|
||||
public class TestObjectFactory extends ObjectFactory {
|
||||
}
|
||||
|
|
@ -56,7 +56,7 @@ public class VersioningTest {
|
|||
|
||||
@Before
|
||||
public void setup() {
|
||||
this.repository = new ContentRepository(ObjectFactory.createProcessor(), Simple.REPOSITORY);
|
||||
this.repository = Simple.createContentRepository();
|
||||
this.service = new ConversionService();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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.ObjectFactory;
|
||||
import de.kosit.validationtool.impl.TestObjectFactory;
|
||||
import de.kosit.validationtool.impl.tasks.CheckAction.Bag;
|
||||
|
||||
import net.sf.saxon.s9api.XPathExecutable;
|
||||
|
|
@ -22,6 +22,7 @@ import net.sf.saxon.s9api.XPathExecutable;
|
|||
*/
|
||||
public class ComputeAcceptanceActionTest {
|
||||
|
||||
private static final String DOESNOT_EXIST = "count(//doesnotExist) = 0";
|
||||
private final ComputeAcceptanceAction action = new ComputeAcceptanceAction();
|
||||
|
||||
@Test
|
||||
|
|
@ -49,7 +50,7 @@ public class ComputeAcceptanceActionTest {
|
|||
@Test
|
||||
public void testValidAcceptMatch() {
|
||||
final Bag bag = createBag(true, true);
|
||||
bag.getScenarioSelectionResult().getObject().setAcceptExecutable(createXpath("count(//doesnotExist) = 0"));
|
||||
bag.getScenarioSelectionResult().getObject().setAcceptExecutable(createXpath(DOESNOT_EXIST));
|
||||
this.action.check(bag);
|
||||
assertThat(bag.getAcceptStatus()).isEqualTo(AcceptRecommendation.ACCEPTABLE);
|
||||
}
|
||||
|
|
@ -65,7 +66,7 @@ public class ComputeAcceptanceActionTest {
|
|||
@Test
|
||||
public void testAcceptMatchOverridesSchematronErrors() {
|
||||
final Bag bag = createBag(true, false);
|
||||
bag.getScenarioSelectionResult().getObject().setAcceptExecutable(createXpath("count(//doesnotExist) = 0"));
|
||||
bag.getScenarioSelectionResult().getObject().setAcceptExecutable(createXpath(DOESNOT_EXIST));
|
||||
this.action.check(bag);
|
||||
assertThat(bag.getAcceptStatus()).isEqualTo(AcceptRecommendation.ACCEPTABLE);
|
||||
}
|
||||
|
|
@ -73,7 +74,7 @@ public class ComputeAcceptanceActionTest {
|
|||
@Test
|
||||
public void testValidAcceptMatchOnSchemaFailed() {
|
||||
final Bag bag = createBag(false, true);
|
||||
bag.getScenarioSelectionResult().getObject().setAcceptExecutable(createXpath("count(//doesnotExist) = 0"));
|
||||
bag.getScenarioSelectionResult().getObject().setAcceptExecutable(createXpath(DOESNOT_EXIST));
|
||||
this.action.check(bag);
|
||||
assertThat(bag.getAcceptStatus()).isEqualTo(AcceptRecommendation.REJECT);
|
||||
}
|
||||
|
|
@ -104,6 +105,6 @@ public class ComputeAcceptanceActionTest {
|
|||
|
||||
|
||||
private static XPathExecutable createXpath(final String expression) {
|
||||
return new ContentRepository(ObjectFactory.createProcessor(), null).createXPath(expression, new HashMap<>());
|
||||
return new ContentRepository(TestObjectFactory.createProcessor(), null, null).createXPath(expression, new HashMap<>());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,12 +43,13 @@ import org.xml.sax.SAXException;
|
|||
|
||||
import de.kosit.validationtool.api.Input;
|
||||
import de.kosit.validationtool.api.InputFactory;
|
||||
import de.kosit.validationtool.impl.ContentRepository;
|
||||
import de.kosit.validationtool.impl.Helper;
|
||||
import de.kosit.validationtool.impl.Helper.Simple;
|
||||
import de.kosit.validationtool.impl.ObjectFactory;
|
||||
import de.kosit.validationtool.impl.Scenario;
|
||||
import de.kosit.validationtool.impl.TestObjectFactory;
|
||||
import de.kosit.validationtool.impl.input.SourceInput;
|
||||
import de.kosit.validationtool.impl.tasks.CheckAction.Bag;
|
||||
import de.kosit.validationtool.impl.xml.StrictRelativeResolvingStrategy;
|
||||
|
||||
/**
|
||||
* Tests die {@link SchemaValidationAction}.
|
||||
|
|
@ -63,7 +64,7 @@ public class SchemaValidatorActionTest {
|
|||
|
||||
@Before
|
||||
public void setup() {
|
||||
this.service = new SchemaValidationAction();
|
||||
this.service = new SchemaValidationAction(new StrictRelativeResolvingStrategy(), TestObjectFactory.createProcessor());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -89,7 +90,7 @@ public class SchemaValidatorActionTest {
|
|||
|
||||
@Test
|
||||
public void testSchemaReferences() {
|
||||
final Schema reportInputSchema = new ContentRepository(ObjectFactory.createProcessor(), Simple.REPOSITORY).getReportInputSchema();
|
||||
final Schema reportInputSchema = Simple.createContentRepository().getReportInputSchema();
|
||||
assertThat(reportInputSchema).isNotNull();
|
||||
}
|
||||
|
||||
|
|
@ -98,7 +99,7 @@ public class SchemaValidatorActionTest {
|
|||
try ( final InputStream inputStream = Simple.SIMPLE_VALID.toURL().openStream() ) {
|
||||
final Bag bag = createBag(InputFactory.read(new StreamSource(inputStream)));
|
||||
// don't read the real inputstream here!
|
||||
bag.setParserResult(DocumentParseAction.parseDocument(InputFactory.read(Simple.SIMPLE_VALID.toURL())));
|
||||
bag.setParserResult(Helper.parseDocument(InputFactory.read(Simple.SIMPLE_VALID.toURL())));
|
||||
this.service.check(bag);
|
||||
assertThat(bag.getSchemaValidationResult()).isNotNull();
|
||||
assertThat(bag.getSchemaValidationResult().isValid()).isTrue();
|
||||
|
|
@ -114,7 +115,7 @@ public class SchemaValidatorActionTest {
|
|||
this.service.setInMemoryLimit(5L);
|
||||
input.setLength(6L);
|
||||
|
||||
bag.setParserResult(DocumentParseAction.parseDocument(InputFactory.read(Simple.SIMPLE_VALID.toURL())));
|
||||
bag.setParserResult(Helper.parseDocument(InputFactory.read(Simple.SIMPLE_VALID.toURL())));
|
||||
this.service.check(bag);
|
||||
assertThat(bag.getSchemaValidationResult()).isNotNull();
|
||||
assertThat(bag.getSchemaValidationResult().isValid()).isTrue();
|
||||
|
|
@ -127,7 +128,7 @@ public class SchemaValidatorActionTest {
|
|||
final Reader reader = new InputStreamReader(inputStream) ) {
|
||||
final SourceInput input = (SourceInput) InputFactory.read(new StreamSource(reader));
|
||||
final Bag bag = createBag(input);
|
||||
bag.setParserResult(DocumentParseAction.parseDocument(InputFactory.read(Simple.SIMPLE_VALID.toURL())));
|
||||
bag.setParserResult(Helper.parseDocument(InputFactory.read(Simple.SIMPLE_VALID.toURL())));
|
||||
this.service.check(bag);
|
||||
this.service.check(bag);
|
||||
assertThat(bag.getSchemaValidationResult()).isNotNull();
|
||||
|
|
@ -143,7 +144,7 @@ public class SchemaValidatorActionTest {
|
|||
final Bag bag = createBag(input);
|
||||
// set limit and length for serialization to 5 bytes
|
||||
this.service.setInMemoryLimit(5L);
|
||||
bag.setParserResult(DocumentParseAction.parseDocument(InputFactory.read(Simple.SIMPLE_VALID.toURL())));
|
||||
bag.setParserResult(Helper.parseDocument(InputFactory.read(Simple.SIMPLE_VALID.toURL())));
|
||||
this.service.check(bag);
|
||||
this.service.check(bag);
|
||||
assertThat(bag.getSchemaValidationResult()).isNotNull();
|
||||
|
|
|
|||
|
|
@ -13,12 +13,11 @@ import org.junit.Before;
|
|||
import org.junit.Test;
|
||||
|
||||
import de.kosit.validationtool.api.InputFactory;
|
||||
import de.kosit.validationtool.impl.ContentRepository;
|
||||
import de.kosit.validationtool.impl.ConversionService;
|
||||
import de.kosit.validationtool.impl.Helper.Simple;
|
||||
import de.kosit.validationtool.impl.ObjectFactory;
|
||||
import de.kosit.validationtool.impl.Scenario;
|
||||
import de.kosit.validationtool.impl.Scenario.Transformation;
|
||||
import de.kosit.validationtool.impl.xml.RelativeUriResolver;
|
||||
import de.kosit.validationtool.model.scenarios.ResourceType;
|
||||
|
||||
import net.sf.saxon.s9api.SaxonApiException;
|
||||
|
|
@ -36,8 +35,7 @@ public class SchematronValidationActionTest {
|
|||
|
||||
@Before
|
||||
public void setup() {
|
||||
final ContentRepository repository = new ContentRepository(ObjectFactory.createProcessor(), Simple.REPOSITORY);
|
||||
this.action = new SchematronValidationAction(repository, new ConversionService());
|
||||
this.action = new SchematronValidationAction(new RelativeUriResolver(Simple.REPOSITORY_URI), new ConversionService());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -16,8 +16,9 @@ import de.kosit.validationtool.api.Input;
|
|||
import de.kosit.validationtool.api.InputFactory;
|
||||
import de.kosit.validationtool.impl.ContentRepository;
|
||||
import de.kosit.validationtool.impl.Helper;
|
||||
import de.kosit.validationtool.impl.ObjectFactory;
|
||||
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;
|
||||
|
|
@ -48,7 +49,7 @@ public class TestBagBuilder {
|
|||
public static Bag createBag(final Input input, final boolean parse, final CreateReportInput reportInput) {
|
||||
final Bag bag = new Bag(input, reportInput);
|
||||
if (parse) {
|
||||
bag.setParserResult(DocumentParseAction.parseDocument(bag.getInput()));
|
||||
bag.setParserResult(Helper.parseDocument(bag.getInput()));
|
||||
}
|
||||
bag.setScenarioSelectionResult(new Result<>(createScenario(Helper.Simple.getSchemaLocation())));
|
||||
return bag;
|
||||
|
|
@ -73,11 +74,13 @@ public class TestBagBuilder {
|
|||
}
|
||||
|
||||
private static Schema createSchema(final URL toURL) {
|
||||
return new ContentRepository(ObjectFactory.createProcessor(), null).createSchema(toURL);
|
||||
final ContentRepository contentRepository = new ContentRepository(TestObjectFactory.createProcessor(), null, null);
|
||||
contentRepository.setSchemaFactory(ResolvingMode.STRICT_RELATIVE.getStrategy().createSchemaFactory());
|
||||
return contentRepository.createSchema(toURL);
|
||||
}
|
||||
|
||||
private static XdmNode createReport() {
|
||||
return DocumentParseAction.parseDocument(InputFactory.read("<some>xml</some>".getBytes(), "someXml")).getObject();
|
||||
return Helper.parseDocument(InputFactory.read("<some>xml</some>".getBytes(), "someXml")).getObject();
|
||||
}
|
||||
|
||||
static Bag createBag(final boolean schemaValid, final boolean schematronValid) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue