mirror of
https://github.com/itplr-kosit/validator.git
synced 2026-05-26 01:05:38 +00:00
(wip) Umsetzung OHNE Nutzung eines java.nio.Filesystem
This commit is contained in:
parent
7af9b1fdbd
commit
99930a2b0a
14 changed files with 312 additions and 188 deletions
|
|
@ -22,6 +22,9 @@ package de.kosit.validationtool.impl;
|
|||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
|
@ -48,64 +51,85 @@ public class ContentRepositoryTest {
|
|||
@Rule
|
||||
public ExpectedException exception = ExpectedException.none();
|
||||
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
repository = new ContentRepository(ObjectFactory.createProcessor(), Helper.REPOSITORY);
|
||||
this.repository = new ContentRepository(ObjectFactory.createProcessor(), Helper.REPOSITORY);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testCreateSchema() throws MalformedURLException {
|
||||
final Schema schema = repository.createSchema(Helper.ASSERTION_SCHEMA.toURL());
|
||||
final Schema schema = ContentRepository.createSchema(Helper.ASSERTION_SCHEMA.toURL());
|
||||
assertThat(schema).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSchemaCaching() throws MalformedURLException {
|
||||
final Schema schema = repository.getReportInputSchema();
|
||||
assertThat(repository.getReportInputSchema()).isSameAs(schema);
|
||||
public void testSchemaCaching() {
|
||||
final Schema schema = this.repository.getReportInputSchema();
|
||||
assertThat(this.repository.getReportInputSchema()).isSameAs(schema);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateSchemaNotExisting()throws Exception {
|
||||
exception.expect(IllegalStateException.class);
|
||||
repository.createSchema(Helper.ASSERTION_SCHEMA.resolve("noexisting").toURL());
|
||||
public void testCreateSchemaNotExisting() throws Exception {
|
||||
this.exception.expect(IllegalStateException.class);
|
||||
ContentRepository.createSchema(Helper.ASSERTION_SCHEMA.resolve("noexisting").toURL());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLoadXSLT() throws MalformedURLException {
|
||||
final XsltExecutable executable = repository.loadXsltScript(Helper.SAMPLE_XSLT);
|
||||
public void testLoadXSLT() {
|
||||
final XsltExecutable executable = this.repository.loadXsltScript(Helper.SAMPLE_XSLT);
|
||||
assertThat(executable).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLoadXSLTNotExisting() throws MalformedURLException {
|
||||
exception.expect(IllegalStateException.class);
|
||||
repository.loadXsltScript(Helper.SAMPLE_XSLT.resolve("notexisting"));
|
||||
public void testLoadXSLTNotExisting() {
|
||||
this.exception.expect(IllegalStateException.class);
|
||||
this.repository.loadXsltScript(Helper.SAMPLE_XSLT.resolve("notexisting"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testXpathCreation() throws MalformedURLException {
|
||||
XPathExecutable xPath = repository.createXPath("//html", null);
|
||||
public void testXpathCreation() {
|
||||
XPathExecutable xPath = this.repository.createXPath("//html", null);
|
||||
assertThat(xPath).isNotNull();
|
||||
xPath = repository.createXPath("//html", Collections.emptyMap());
|
||||
xPath = this.repository.createXPath("//html", Collections.emptyMap());
|
||||
assertThat(xPath).isNotNull();
|
||||
Map<String,String> namespace = new HashMap<>();
|
||||
final Map<String, String> namespace = new HashMap<>();
|
||||
namespace.put("html", "http://www.w3.org/1999/xhtml");
|
||||
xPath = repository.createXPath("//html:html", namespace );
|
||||
xPath = this.repository.createXPath("//html:html", namespace);
|
||||
assertThat(xPath).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testXpathCreationWithoutNamespace(){
|
||||
exception.expect(IllegalStateException.class);
|
||||
repository.createXPath("//html:html", null );
|
||||
public void testXpathCreationWithoutNamespace() {
|
||||
this.exception.expect(IllegalStateException.class);
|
||||
this.repository.createXPath("//html:html", null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIllegalXpath(){
|
||||
exception.expect(IllegalStateException.class);
|
||||
repository.createXPath("kein Xpath Ausdruck", null );
|
||||
public void testIllegalXpath() {
|
||||
this.exception.expect(IllegalStateException.class);
|
||||
this.repository.createXPath("kein Xpath Ausdruck", null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void loadFromJar() throws URISyntaxException {
|
||||
this.repository = new ContentRepository(ObjectFactory.createProcessor(), Helper.JAR_REPOSITORY.toURI());
|
||||
final XsltExecutable xsltExecutable = this.repository.loadXsltScript(URI.create("resources/eRechnung/report.xsl"));
|
||||
assertThat(xsltExecutable).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLoadSchema() {
|
||||
final URL main = RelativeUriResolverTest.class.getClassLoader().getResource("simple/main.xsd");
|
||||
final Schema schema = ContentRepository.createSchema(main, new ClassPathResourceResolver("/simple"));
|
||||
assertThat(schema).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLoadSchemaPackaged() throws URISyntaxException {
|
||||
final URL main = RelativeUriResolverTest.class.getClassLoader().getResource("packaged/main.xsd");
|
||||
final Schema schema = ContentRepository.createSchema(main,
|
||||
new ClassPathResourceResolver(RelativeUriResolverTest.class.getClassLoader().getResource("packaged/").toURI()));
|
||||
assertThat(schema).isNotNull();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,65 +57,66 @@ public class ConversionServiceTest {
|
|||
|
||||
@Before
|
||||
public void setup() {
|
||||
service = new ConversionService();
|
||||
repository = new ContentRepository(ObjectFactory.createProcessor(), new File("src/test/resources/examples/repository").toURI());
|
||||
this.service = new ConversionService();
|
||||
this.repository = new ContentRepository(ObjectFactory.createProcessor(),
|
||||
new File("src/test/resources/examples/repository").toURI());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMarshalNull() {
|
||||
exception.expect(ConversionService.ConversionExeption.class);
|
||||
service.writeXml(null);
|
||||
this.exception.expect(ConversionService.ConversionExeption.class);
|
||||
this.service.writeXml(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMarshalUnknown() {
|
||||
exception.expect(ConversionService.ConversionExeption.class);
|
||||
service.writeXml(new Serializable() {
|
||||
this.exception.expect(ConversionService.ConversionExeption.class);
|
||||
this.service.writeXml(new Serializable() {
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnmarshal() throws URISyntaxException {
|
||||
final Scenarios s = service.readXml(VALID_XML.toURI(), Scenarios.class);
|
||||
final Scenarios s = this.service.readXml(VALID_XML.toURI(), Scenarios.class);
|
||||
assertThat(s).isNotNull();
|
||||
assertThat(s.getName()).isEqualToIgnoringCase("XInneres");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnmarshalWithSchema() throws URISyntaxException {
|
||||
final Scenarios s = service.readXml(VALID_XML.toURI(), Scenarios.class, repository.createSchema(SCHEMA));
|
||||
final Scenarios s = this.service.readXml(VALID_XML.toURI(), Scenarios.class, ContentRepository.createSchema(SCHEMA));
|
||||
assertThat(s).isNotNull();
|
||||
assertThat(s.getName()).isEqualToIgnoringCase("XInneres");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnmarshalInvalidXml() throws URISyntaxException {
|
||||
exception.expect(ConversionService.ConversionExeption.class);
|
||||
service.readXml(INVALID_XML.toURI(), Scenarios.class, repository.createSchema(SCHEMA));
|
||||
this.exception.expect(ConversionService.ConversionExeption.class);
|
||||
this.service.readXml(INVALID_XML.toURI(), Scenarios.class, ContentRepository.createSchema(SCHEMA));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnmarshalIllFormed() throws URISyntaxException {
|
||||
exception.expect(ConversionService.ConversionExeption.class);
|
||||
service.readXml(ILLFORMED_XML.toURI(), Scenarios.class, repository.createSchema(SCHEMA));
|
||||
this.exception.expect(ConversionService.ConversionExeption.class);
|
||||
this.service.readXml(ILLFORMED_XML.toURI(), Scenarios.class, ContentRepository.createSchema(SCHEMA));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnmarshalEmpty() {
|
||||
exception.expect(ConversionService.ConversionExeption.class);
|
||||
service.readXml(null, Scenarios.class);
|
||||
this.exception.expect(ConversionService.ConversionExeption.class);
|
||||
this.service.readXml(null, Scenarios.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnmarshalUnknownType() throws URISyntaxException {
|
||||
exception.expect(ConversionService.ConversionExeption.class);
|
||||
service.readXml(VALID_XML.toURI(), ConversionService.class);
|
||||
this.exception.expect(ConversionService.ConversionExeption.class);
|
||||
this.service.readXml(VALID_XML.toURI(), ConversionService.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnmarshalWithoutType() throws URISyntaxException {
|
||||
exception.expect(ConversionService.ConversionExeption.class);
|
||||
service.readXml(VALID_XML.toURI(), null);
|
||||
this.exception.expect(ConversionService.ConversionExeption.class);
|
||||
this.service.readXml(VALID_XML.toURI(), null);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,27 +56,27 @@ public class DefaultCheckTest {
|
|||
|
||||
@Before
|
||||
public void setup() throws URISyntaxException {
|
||||
CheckConfiguration d = new CheckConfiguration(SCENARIO_DEFINITION.toURI());
|
||||
final CheckConfiguration d = new CheckConfiguration(SCENARIO_DEFINITION.toURI());
|
||||
d.setScenarioRepository(new File("src/test/resources/examples/repository").toURI());
|
||||
implementation = new DefaultCheck(d);
|
||||
this.implementation = new DefaultCheck(d);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHappyCase() throws Exception {
|
||||
final XdmNode doc = implementation.checkInput(read(VALID_EXAMPLE));
|
||||
final XdmNode doc = this.implementation.checkInput(read(VALID_EXAMPLE));
|
||||
assertThat(doc).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHappyCaseDocument() throws Exception {
|
||||
final Document doc = implementation.check(read(VALID_EXAMPLE));
|
||||
final Document doc = this.implementation.check(read(VALID_EXAMPLE));
|
||||
assertThat(doc).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultipleCase() throws Exception {
|
||||
final List<Input> input = IntStream.range(0, MULTI_COUNT).mapToObj(i -> read(VALID_EXAMPLE)).collect(Collectors.toList());
|
||||
final List<XdmNode> docs = implementation.checkInput(input);
|
||||
final List<XdmNode> docs = this.implementation.checkInput(input);
|
||||
assertThat(docs).isNotNull();
|
||||
assertThat(docs).hasSize(MULTI_COUNT);
|
||||
}
|
||||
|
|
@ -84,7 +84,7 @@ public class DefaultCheckTest {
|
|||
@Test
|
||||
public void testMultipleCaseDocument() throws Exception {
|
||||
final List<Input> input = IntStream.range(0, MULTI_COUNT).mapToObj(i -> read(VALID_EXAMPLE)).collect(Collectors.toList());
|
||||
final List<Document> docs = implementation.check(input);
|
||||
final List<Document> docs = this.implementation.check(input);
|
||||
assertThat(docs).isNotNull();
|
||||
assertThat(docs).hasSize(MULTI_COUNT);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ package de.kosit.validationtool.impl;
|
|||
import static de.kosit.validationtool.api.InputFactory.read;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
import org.junit.Before;
|
||||
|
|
@ -37,6 +36,8 @@ import de.kosit.validationtool.model.reportInput.XMLSyntaxError;
|
|||
import net.sf.saxon.s9api.XdmNode;
|
||||
|
||||
/**
|
||||
* Testet die Document Parsing-Funktionalitäten.
|
||||
*
|
||||
* @author Andreas Penski
|
||||
*/
|
||||
public class DocumentParserTest {
|
||||
|
|
@ -47,8 +48,6 @@ public class DocumentParserTest {
|
|||
|
||||
private static final URL NOT_EXISTING = ConversionServiceTest.class.getResource("/does not exist.xml");
|
||||
|
||||
|
||||
|
||||
@Rule
|
||||
public ExpectedException exception = ExpectedException.none();
|
||||
|
||||
|
|
@ -56,22 +55,21 @@ public class DocumentParserTest {
|
|||
|
||||
@Before
|
||||
public void setup() {
|
||||
parser = new DocumentParseAction();
|
||||
this.parser = new DocumentParseAction();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimple() throws IOException {
|
||||
final Result<XdmNode, XMLSyntaxError> result = parser.parseDocument(read(CONTENT));
|
||||
public void testSimple() {
|
||||
final Result<XdmNode, XMLSyntaxError> result = this.parser.parseDocument(read(CONTENT));
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.getObject()).isNotNull();
|
||||
assertThat(result.getErrors()).isEmpty();
|
||||
assertThat(result.isValid()).isTrue();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testIllformed() throws IOException {
|
||||
final Result<XdmNode, XMLSyntaxError> result = parser.parseDocument(read(ILLFORMED));
|
||||
public void testIllformed() {
|
||||
final Result<XdmNode, XMLSyntaxError> result = this.parser.parseDocument(read(ILLFORMED));
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.getErrors()).isNotEmpty();
|
||||
assertThat(result.getObject()).isNull();
|
||||
|
|
@ -80,10 +78,9 @@ public class DocumentParserTest {
|
|||
|
||||
@Test
|
||||
public void testNullInput() {
|
||||
exception.expect(IllegalArgumentException.class);
|
||||
parser.parseDocument(null);
|
||||
this.exception.expect(IllegalArgumentException.class);
|
||||
this.parser.parseDocument(null);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,6 +57,8 @@ public class Helper {
|
|||
|
||||
public static final URI REPOSITORY = EXAMPLES_DIR.resolve("repository/");
|
||||
|
||||
public static final URL JAR_REPOSITORY = Helper.class.getClassLoader().getResource("xrechnung/repository/");
|
||||
|
||||
public static final URI NOT_EXISTING = EXAMPLES_DIR.resolve("doesnotexist");
|
||||
|
||||
public static final URI SAMPLE_DIR = EXAMPLES_DIR.resolve("UBLReady/");
|
||||
|
|
@ -73,18 +75,18 @@ public class Helper {
|
|||
* @param url die url die geladen werden soll
|
||||
* @return ein result objekt mit Dokument
|
||||
*/
|
||||
public static XdmNode load(URL url) {
|
||||
try ( InputStream input = url.openStream() ) {
|
||||
public static XdmNode load(final URL url) {
|
||||
try ( final InputStream input = url.openStream() ) {
|
||||
return ObjectFactory.createProcessor().newDocumentBuilder().build(new StreamSource(input));
|
||||
} catch (SaxonApiException | IOException e) {
|
||||
} catch (final SaxonApiException | IOException e) {
|
||||
throw new IllegalStateException("Fehler beim Laden der XML-Datei", e);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static <T> T load(URL url, Class<T> type) throws URISyntaxException {
|
||||
ConversionService c = new ConversionService();
|
||||
public static <T> T load(final URL url, final Class<T> type) throws URISyntaxException {
|
||||
final ConversionService c = new ConversionService();
|
||||
c.initialize(de.kosit.validationtool.model.reportInput.ObjectFactory.class.getPackage(),
|
||||
de.kosit.validationtool.cmd.assertions.ObjectFactory.class.getPackage(),
|
||||
de.kosit.validationtool.model.scenarios.ObjectFactory.class.getPackage());
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.transform.TransformerException;
|
||||
|
|
@ -44,7 +45,7 @@ public class RelativeUriResolverTest {
|
|||
static {
|
||||
try {
|
||||
BASE = RelativeUriResolver.class.getResource("/examples/assertions/").toURI();
|
||||
} catch (URISyntaxException e) {
|
||||
} catch (final URISyntaxException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
|
|
@ -56,19 +57,35 @@ public class RelativeUriResolverTest {
|
|||
|
||||
@Test
|
||||
public void testSucces() throws TransformerException {
|
||||
final Source resource = resolver.resolve("ubl-0001.xml", BASE.toASCIIString());
|
||||
final Source resource = this.resolver.resolve("ubl-0001.xml", BASE.toASCIIString());
|
||||
assertThat(resource).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotExisting() throws TransformerException {
|
||||
exception.expect(IllegalStateException.class);
|
||||
resolver.resolve("ubl-0001", BASE.toASCIIString());
|
||||
this.exception.expect(IllegalStateException.class);
|
||||
this.resolver.resolve("ubl-0001", BASE.toASCIIString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOutOfPath() throws TransformerException {
|
||||
exception.expect(IllegalStateException.class);
|
||||
resolver.resolve("../results/report.xml", BASE.toASCIIString());
|
||||
this.exception.expect(IllegalStateException.class);
|
||||
this.resolver.resolve("../results/report.xml", BASE.toASCIIString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClasspathLocal() throws URISyntaxException, TransformerException {
|
||||
this.resolver = new RelativeUriResolver(RelativeUriResolver.class.getClassLoader().getResource("simple").toURI());
|
||||
final URL moz = RelativeUriResolverTest.class.getClassLoader().getResource("simple/main.xsd");
|
||||
final Source resolved = this.resolver.resolve("./resources/reference.xsd", moz.toURI().toASCIIString());
|
||||
assertThat(resolved).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClasspathJAR() throws URISyntaxException, TransformerException {
|
||||
this.resolver = new RelativeUriResolver(RelativeUriResolver.class.getClassLoader().getResource("packaged").toURI());
|
||||
final URL moz = RelativeUriResolverTest.class.getClassLoader().getResource("packaged/main.xsd");
|
||||
final Source resolved = this.resolver.resolve("./resources/reference.xsd", moz.toURI().toASCIIString());
|
||||
assertThat(resolved).isNotNull();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
|
||||
import org.junit.Before;
|
||||
|
|
@ -31,6 +32,7 @@ import org.junit.Rule;
|
|||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import de.kosit.validationtool.api.CheckConfiguration;
|
||||
import de.kosit.validationtool.impl.model.Result;
|
||||
import de.kosit.validationtool.impl.tasks.DocumentParseAction;
|
||||
import de.kosit.validationtool.model.scenarios.ScenarioType;
|
||||
|
|
@ -57,46 +59,57 @@ public class ScenarioRepositoryTest {
|
|||
|
||||
@Before
|
||||
public void setup() {
|
||||
content = new ContentRepository(ObjectFactory.createProcessor(), new File("src/test/resources/examples/repository").toURI());
|
||||
Scenarios def = new Scenarios();
|
||||
ScenarioType t = new ScenarioType();
|
||||
this.content = new ContentRepository(ObjectFactory.createProcessor(), new File("src/test/resources/examples/repository").toURI());
|
||||
final Scenarios def = new Scenarios();
|
||||
final ScenarioType t = new ScenarioType();
|
||||
t.setMatch("//*:name");
|
||||
t.setName("Test");
|
||||
t.initialize(content, true);
|
||||
t.initialize(this.content, true);
|
||||
def.getScenario().add(t);
|
||||
repository = new ScenarioRepository(ObjectFactory.createProcessor(), content);
|
||||
repository.initialize(def);
|
||||
this.repository = new ScenarioRepository(ObjectFactory.createProcessor(), this.content);
|
||||
this.repository.initialize(def);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHappyCase() throws Exception {
|
||||
final Result<ScenarioType, String> scenario = repository.selectScenario(load(SAMPLE));
|
||||
final Result<ScenarioType, String> scenario = this.repository.selectScenario(load(SAMPLE));
|
||||
assertThat(scenario).isNotNull();
|
||||
assertThat(scenario.isValid()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNonMatch() throws Exception {
|
||||
repository.getScenarios().getScenario().clear();
|
||||
final Result<ScenarioType, String> scenario = repository.selectScenario(load(SAMPLE));
|
||||
this.repository.getScenarios().getScenario().clear();
|
||||
final Result<ScenarioType, String> scenario = this.repository.selectScenario(load(SAMPLE));
|
||||
assertThat(scenario).isNotNull();
|
||||
assertThat(scenario.isValid()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiMatch() throws Exception {
|
||||
ScenarioType t = new ScenarioType();
|
||||
final ScenarioType t = new ScenarioType();
|
||||
t.setMatch("//*:name");
|
||||
t.setName("Test");
|
||||
t.initialize(content, true);
|
||||
repository.getScenarios().getScenario().add(t);
|
||||
final Result<ScenarioType, String> scenario = repository.selectScenario(load(SAMPLE));
|
||||
t.initialize(this.content, true);
|
||||
this.repository.getScenarios().getScenario().add(t);
|
||||
final Result<ScenarioType, String> scenario = this.repository.selectScenario(load(SAMPLE));
|
||||
assertThat(scenario).isNotNull();
|
||||
assertThat(scenario.isValid()).isFalse();
|
||||
}
|
||||
|
||||
private XdmNode load(URL url) throws IOException {
|
||||
DocumentParseAction p = new DocumentParseAction();
|
||||
private static XdmNode load(final URL url) throws IOException {
|
||||
final DocumentParseAction p = new DocumentParseAction();
|
||||
return p.parseDocument(read(url)).getObject();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void loadFromJar() throws URISyntaxException {
|
||||
this.content = new ContentRepository(ObjectFactory.createProcessor(), Helper.JAR_REPOSITORY.toURI());
|
||||
this.repository = new ScenarioRepository(ObjectFactory.createProcessor(), this.content);
|
||||
final CheckConfiguration conf = new CheckConfiguration(
|
||||
ScenarioRepository.class.getClassLoader().getResource("xrechnung/scenarios.xml").toURI());
|
||||
this.repository.initialize(conf);
|
||||
assertThat(this.repository.getScenarios()).isNotNull();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ package de.kosit.validationtool.impl;
|
|||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
|
||||
|
|
@ -52,35 +51,33 @@ public class VersioningTest {
|
|||
|
||||
private ConversionService service;
|
||||
|
||||
private ContentRepository repository;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
service = new ConversionService();
|
||||
repository = new ContentRepository(ObjectFactory.createProcessor(), new File("src/test/resources/examples/repository").toURI());
|
||||
this.service = new ConversionService();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBase() throws URISyntaxException {
|
||||
final Scenarios result = service.readXml(BASE.toURI(), Scenarios.class, repository.getScenarioSchema());
|
||||
final Scenarios result = this.service.readXml(BASE.toURI(), Scenarios.class, ContentRepository.getScenarioSchema());
|
||||
assertThat(result).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFrameworkIncrement() throws URISyntaxException {
|
||||
final Scenarios result = service.readXml(INCREMENT.toURI(), Scenarios.class, repository.getScenarioSchema());
|
||||
final Scenarios result = this.service.readXml(INCREMENT.toURI(), Scenarios.class, ContentRepository.getScenarioSchema());
|
||||
assertThat(result).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNewFeature() throws URISyntaxException {
|
||||
exception.expect(ConversionService.ConversionExeption.class);
|
||||
service.readXml(NEW_FEATURE.toURI(), Scenarios.class, repository.getScenarioSchema());
|
||||
this.exception.expect(ConversionService.ConversionExeption.class);
|
||||
this.service.readXml(NEW_FEATURE.toURI(), Scenarios.class, ContentRepository.getScenarioSchema());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNewVersion() throws URISyntaxException {
|
||||
exception.expect(ConversionService.ConversionExeption.class);
|
||||
service.readXml(NEW_VERSION.toURI(), Scenarios.class, repository.getScenarioSchema());
|
||||
this.exception.expect(ConversionService.ConversionExeption.class);
|
||||
this.service.readXml(NEW_VERSION.toURI(), Scenarios.class, ContentRepository.getScenarioSchema());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
12
src/test/resources/simple/main.xsd
Normal file
12
src/test/resources/simple/main.xsd
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<schema xmlns:ref="http://www.example.org/reference" xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/main"
|
||||
elementFormDefault="qualified">
|
||||
|
||||
<import namespace="http://www.example.org/reference" schemaLocation="./resources/reference.xsd" />
|
||||
|
||||
<complexType name="MainType">
|
||||
<sequence>
|
||||
<element name="ref" type="ref:ReferenzTyp"></element>
|
||||
</sequence>
|
||||
</complexType>
|
||||
</schema>
|
||||
9
src/test/resources/simple/resources/reference.xsd
Normal file
9
src/test/resources/simple/resources/reference.xsd
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/reference" xmlns:tns="http://www.example.org/reference" elementFormDefault="qualified">
|
||||
|
||||
<complexType name="ReferenzTyp">
|
||||
<sequence>
|
||||
<element name="some" type="string"></element>
|
||||
</sequence>
|
||||
</complexType>
|
||||
</schema>
|
||||
Loading…
Add table
Add a link
Reference in a new issue