mirror of
https://github.com/itplr-kosit/validator.git
synced 2026-05-25 16:55:39 +00:00
07-FixCompilationWarningsTest
This commit is contained in:
parent
adb4effcf9
commit
d22b03cec1
17 changed files with 95 additions and 161 deletions
7
pom.xml
7
pom.xml
|
|
@ -82,6 +82,7 @@
|
||||||
<version.checkstyle>10.23.0</version.checkstyle>
|
<version.checkstyle>10.23.0</version.checkstyle>
|
||||||
<version.commons-io>2.19.0</version.commons-io>
|
<version.commons-io>2.19.0</version.commons-io>
|
||||||
<version.commons-lang3>3.17.0</version.commons-lang3>
|
<version.commons-lang3>3.17.0</version.commons-lang3>
|
||||||
|
<version.commons-text>1.13.1</version.commons-text>
|
||||||
<version.jakarta.xml.bind-api>4.0.2</version.jakarta.xml.bind-api>
|
<version.jakarta.xml.bind-api>4.0.2</version.jakarta.xml.bind-api>
|
||||||
<version.jansi>2.4.1</version.jansi>
|
<version.jansi>2.4.1</version.jansi>
|
||||||
<version.jaxb-runtime>4.0.5</version.jaxb-runtime>
|
<version.jaxb-runtime>4.0.5</version.jaxb-runtime>
|
||||||
|
|
@ -185,6 +186,12 @@
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- Test -->
|
<!-- Test -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-text</artifactId>
|
||||||
|
<version>${version.commons-text}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>de.kosit.validationtool</groupId>
|
<groupId>de.kosit.validationtool</groupId>
|
||||||
<artifactId>packaged-test-scenarios</artifactId>
|
<artifactId>packaged-test-scenarios</artifactId>
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ package de.kosit.validationtool.api;
|
||||||
import static de.kosit.validationtool.impl.Helper.Simple.SIMPLE_VALID;
|
import static de.kosit.validationtool.impl.Helper.Simple.SIMPLE_VALID;
|
||||||
import static de.kosit.validationtool.impl.input.StreamHelper.drain;
|
import static de.kosit.validationtool.impl.input.StreamHelper.drain;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.junit.Assert.assertThrows;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
@ -32,9 +33,7 @@ import java.nio.file.Paths;
|
||||||
import javax.xml.transform.dom.DOMSource;
|
import javax.xml.transform.dom.DOMSource;
|
||||||
import javax.xml.transform.stream.StreamSource;
|
import javax.xml.transform.stream.StreamSource;
|
||||||
|
|
||||||
import org.junit.Rule;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.ExpectedException;
|
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
import org.xml.sax.helpers.AttributesImpl;
|
import org.xml.sax.helpers.AttributesImpl;
|
||||||
|
|
@ -61,9 +60,6 @@ public class InputFactoryTest {
|
||||||
|
|
||||||
public static final String SOME_VALUE = "some value";
|
public static final String SOME_VALUE = "some value";
|
||||||
|
|
||||||
@Rule
|
|
||||||
public ExpectedException expectedException = ExpectedException.none();
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDefaultDigestAlgorithm() {
|
public void testDefaultDigestAlgorithm() {
|
||||||
assertThat(new InputFactory().getAlgorithm()).isEqualTo(InputFactory.DEFAULT_ALGORITH);
|
assertThat(new InputFactory().getAlgorithm()).isEqualTo(InputFactory.DEFAULT_ALGORITH);
|
||||||
|
|
@ -83,14 +79,12 @@ public class InputFactoryTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWrongAlgorithm() {
|
public void testWrongAlgorithm() {
|
||||||
this.expectedException.expect(IllegalArgumentException.class);
|
assertThrows(IllegalArgumentException.class, () -> new InputFactory("unknown"));
|
||||||
new InputFactory("unknown");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNullInputURL() {
|
public void testNullInputURL() {
|
||||||
this.expectedException.expect(IllegalArgumentException.class);
|
assertThrows(IllegalArgumentException.class, () -> InputFactory.read((URL) null));
|
||||||
InputFactory.read((URL) null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -107,8 +101,7 @@ public class InputFactoryTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNullStream() {
|
public void testNullStream() {
|
||||||
this.expectedException.expect(IllegalArgumentException.class);
|
assertThrows(IllegalArgumentException.class, () -> InputFactory.read((InputStream) null, SOME_VALUE));
|
||||||
final Input input = InputFactory.read((InputStream) null, SOME_VALUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -125,21 +118,20 @@ public class InputFactoryTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNullInput() {
|
public void testNullInput() {
|
||||||
this.expectedException.expect(IllegalArgumentException.class);
|
assertThrows(IllegalArgumentException.class, () -> InputFactory.read((byte[]) null, SOME_VALUE));
|
||||||
InputFactory.read((byte[]) null, SOME_VALUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNullInputName() {
|
public void testNullInputName() {
|
||||||
this.expectedException.expect(IllegalArgumentException.class);
|
assertThrows(IllegalArgumentException.class, () -> InputFactory.read(SOME_VALUE.getBytes(), null));
|
||||||
InputFactory.read(SOME_VALUE.getBytes(), null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEmptyInputName() throws IOException {
|
public void testEmptyInputName() throws IOException {
|
||||||
this.expectedException.expect(IllegalArgumentException.class);
|
assertThrows(IllegalArgumentException.class, () -> {
|
||||||
final Input input = InputFactory.read(SOME_VALUE.getBytes(), "");
|
final Input input = InputFactory.read(SOME_VALUE.getBytes(), "");
|
||||||
drain(input);
|
drain(input);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -150,8 +142,7 @@ public class InputFactoryTest {
|
||||||
drain(input);
|
drain(input);
|
||||||
assertThat(input.getHashCode()).isNotNull();
|
assertThat(input.getHashCode()).isNotNull();
|
||||||
assertThat(input.getLength()).isGreaterThan(0L);
|
assertThat(input.getLength()).isGreaterThan(0L);
|
||||||
this.expectedException.expect(IllegalStateException.class);
|
assertThrows(IllegalStateException.class, input::getSource);
|
||||||
input.getSource();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -164,15 +155,13 @@ public class InputFactoryTest {
|
||||||
drain(input);
|
drain(input);
|
||||||
assertThat(input.getHashCode()).isNotNull();
|
assertThat(input.getHashCode()).isNotNull();
|
||||||
assertThat(input.getLength()).isGreaterThan(0L);
|
assertThat(input.getLength()).isGreaterThan(0L);
|
||||||
this.expectedException.expect(IllegalStateException.class);
|
assertThrows(IllegalStateException.class, input::getSource);
|
||||||
input.getSource();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUnexistingInput() {
|
public void testUnexistingInput() {
|
||||||
this.expectedException.expect(IllegalArgumentException.class);
|
assertThrows(IllegalArgumentException.class, () -> InputFactory.read(Simple.NOT_EXISTING));
|
||||||
InputFactory.read(Simple.NOT_EXISTING);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
|
|
@ -20,15 +20,13 @@ import static de.kosit.validationtool.config.ConfigurationBuilder.report;
|
||||||
import static de.kosit.validationtool.config.ConfigurationBuilder.schematron;
|
import static de.kosit.validationtool.config.ConfigurationBuilder.schematron;
|
||||||
import static de.kosit.validationtool.config.TestConfigurationFactory.createSimpleConfiguration;
|
import static de.kosit.validationtool.config.TestConfigurationFactory.createSimpleConfiguration;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.junit.Assert.assertThrows;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import org.hamcrest.Matchers;
|
|
||||||
import org.junit.Rule;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.ExpectedException;
|
|
||||||
|
|
||||||
import de.kosit.validationtool.impl.Helper;
|
import de.kosit.validationtool.impl.Helper;
|
||||||
|
|
||||||
|
|
@ -41,58 +39,49 @@ public class ConfigurationBuilderTest {
|
||||||
|
|
||||||
public static final LocalDate EPOCH = LocalDate.of(1970, 1, 1);
|
public static final LocalDate EPOCH = LocalDate.of(1970, 1, 1);
|
||||||
|
|
||||||
@Rule
|
|
||||||
public ExpectedException exceptions = ExpectedException.none();
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNoConfiguration() {
|
public void testNoConfiguration() {
|
||||||
this.exceptions.expect(IllegalStateException.class);
|
assertThrows(IllegalStateException.class, () -> new ConfigurationBuilder().build(Helper.getTestProcessor()));
|
||||||
new ConfigurationBuilder().build(Helper.getTestProcessor());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNoFallback() {
|
public void testNoFallback() {
|
||||||
this.exceptions.expect(IllegalStateException.class);
|
|
||||||
this.exceptions.expectMessage(Matchers.containsString("fallback"));
|
|
||||||
final ConfigurationBuilder builder = createSimpleConfiguration();
|
final ConfigurationBuilder builder = createSimpleConfiguration();
|
||||||
builder.with((FallbackBuilder) null);
|
builder.with((FallbackBuilder) null);
|
||||||
builder.build(Helper.getTestProcessor());
|
Throwable e = assertThrows(IllegalStateException.class, () -> builder.build(Helper.getTestProcessor()));
|
||||||
|
assertThat(e).hasMessageContaining("fallback");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNoSchema() {
|
public void testNoSchema() {
|
||||||
this.exceptions.expect(IllegalStateException.class);
|
|
||||||
this.exceptions.expectMessage(Matchers.containsString("schema"));
|
|
||||||
final ConfigurationBuilder builder = createSimpleConfiguration();
|
final ConfigurationBuilder builder = createSimpleConfiguration();
|
||||||
builder.getScenarios().get(0).validate((SchemaBuilder) null);
|
builder.getScenarios().get(0).validate((SchemaBuilder) null);
|
||||||
builder.build(Helper.getTestProcessor());
|
Throwable e = assertThrows(IllegalStateException.class, () -> builder.build(Helper.getTestProcessor()));
|
||||||
|
assertThat(e).hasMessageContaining("schema");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInvalidSchematron() {
|
public void testInvalidSchematron() {
|
||||||
this.exceptions.expect(IllegalStateException.class);
|
|
||||||
this.exceptions.expectMessage(Matchers.containsString("schematron"));
|
|
||||||
final ConfigurationBuilder builder = createSimpleConfiguration();
|
final ConfigurationBuilder builder = createSimpleConfiguration();
|
||||||
builder.getScenarios().get(0).validate(schematron("invalid").source(URI.create("DoesNotExist")));
|
builder.getScenarios().get(0).validate(schematron("invalid").source(URI.create("DoesNotExist")));
|
||||||
builder.build(Helper.getTestProcessor());
|
Throwable e = assertThrows(IllegalStateException.class, () -> builder.build(Helper.getTestProcessor()));
|
||||||
|
assertThat(e).hasMessageContaining("schematron");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInsufficientSchematron() {
|
public void testInsufficientSchematron() {
|
||||||
this.exceptions.expect(IllegalStateException.class);
|
|
||||||
this.exceptions.expectMessage(Matchers.containsString("schematron"));
|
|
||||||
final ConfigurationBuilder builder = createSimpleConfiguration();
|
final ConfigurationBuilder builder = createSimpleConfiguration();
|
||||||
builder.getScenarios().get(0).validate(schematron("invalid"));
|
builder.getScenarios().get(0).validate(schematron("invalid"));
|
||||||
builder.build(Helper.getTestProcessor());
|
Throwable e = assertThrows(IllegalStateException.class, () -> builder.build(Helper.getTestProcessor()));
|
||||||
|
assertThat(e).hasMessageContaining("schematron");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNoReport() {
|
public void testNoReport() {
|
||||||
this.exceptions.expect(IllegalStateException.class);
|
|
||||||
this.exceptions.expectMessage(Matchers.containsString("report"));
|
|
||||||
final ConfigurationBuilder builder = createSimpleConfiguration();
|
final ConfigurationBuilder builder = createSimpleConfiguration();
|
||||||
builder.getScenarios().get(0).with(report("invalid"));
|
builder.getScenarios().get(0).with(report("invalid"));
|
||||||
builder.build(Helper.getTestProcessor());
|
Throwable e = assertThrows(IllegalStateException.class, () -> builder.build(Helper.getTestProcessor()));
|
||||||
|
assertThat(e).hasMessageContaining("report");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
|
|
@ -23,10 +23,9 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.commons.lang3.RandomStringUtils;
|
import org.apache.commons.text.RandomStringGenerator;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.ExpectedException;
|
|
||||||
|
|
||||||
import de.kosit.validationtool.impl.ContentRepository;
|
import de.kosit.validationtool.impl.ContentRepository;
|
||||||
import de.kosit.validationtool.impl.Helper.Simple;
|
import de.kosit.validationtool.impl.Helper.Simple;
|
||||||
|
|
@ -44,9 +43,6 @@ import net.sf.saxon.s9api.XPathExecutable;
|
||||||
*/
|
*/
|
||||||
public class ScenarioBuilderTest {
|
public class ScenarioBuilderTest {
|
||||||
|
|
||||||
@Rule
|
|
||||||
public ExpectedException exceptions = ExpectedException.none();
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void simpleValid() {
|
public void simpleValid() {
|
||||||
final Result<Scenario, String> result = createScenario().build(Simple.createContentRepository());
|
final Result<Scenario, String> result = createScenario().build(Simple.createContentRepository());
|
||||||
|
|
@ -143,7 +139,7 @@ public class ScenarioBuilderTest {
|
||||||
@Test
|
@Test
|
||||||
public void testBasicAttributes() {
|
public void testBasicAttributes() {
|
||||||
final ContentRepository repository = Simple.createContentRepository();
|
final ContentRepository repository = Simple.createContentRepository();
|
||||||
final String random = RandomStringUtils.random(5);
|
final String random = getRandomString(5);
|
||||||
final ScenarioBuilder builder = createScenario();
|
final ScenarioBuilder builder = createScenario();
|
||||||
builder.name(random).description(random);
|
builder.name(random).description(random);
|
||||||
final Result<Scenario, String> result = builder.build(repository);
|
final Result<Scenario, String> result = builder.build(repository);
|
||||||
|
|
@ -166,4 +162,10 @@ public class ScenarioBuilderTest {
|
||||||
assertThat(config.getDescription()).isNotNull();
|
assertThat(config.getDescription()).isNotNull();
|
||||||
assertThat(config.getDescription().getPOrOlOrUl()).isNotEmpty();
|
assertThat(config.getDescription().getPOrOlOrUl()).isNotEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("SameParameterValue")
|
||||||
|
private String getRandomString(final int length) {
|
||||||
|
RandomStringGenerator rsg = new RandomStringGenerator.Builder().filteredBy(Character::isLetterOrDigit).get();
|
||||||
|
return rsg.generate(length);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.commons.lang3.RandomStringUtils;
|
import org.apache.commons.text.RandomStringGenerator;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import de.kosit.validationtool.impl.ContentRepository;
|
import de.kosit.validationtool.impl.ContentRepository;
|
||||||
|
|
@ -40,7 +40,7 @@ public class XPathBuilderTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSimpleString() {
|
public void testSimpleString() {
|
||||||
final String name = RandomStringUtils.randomAlphanumeric(5);
|
final String name = getRandomString(5);
|
||||||
final XPathBuilder b = new XPathBuilder(name);
|
final XPathBuilder b = new XPathBuilder(name);
|
||||||
b.setXpath("//*");
|
b.setXpath("//*");
|
||||||
final Result<XPathExecutable, String> result = b.build(Simple.createContentRepository());
|
final Result<XPathExecutable, String> result = b.build(Simple.createContentRepository());
|
||||||
|
|
@ -54,7 +54,7 @@ public class XPathBuilderTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStringWithNamespace() {
|
public void testStringWithNamespace() {
|
||||||
final String name = RandomStringUtils.randomAlphanumeric(5);
|
final String name = getRandomString(5);
|
||||||
final XPathBuilder b = new XPathBuilder(name);
|
final XPathBuilder b = new XPathBuilder(name);
|
||||||
final Map<String, String> ns = new HashMap<>();
|
final Map<String, String> ns = new HashMap<>();
|
||||||
ns.put("p", "http://somens");
|
ns.put("p", "http://somens");
|
||||||
|
|
@ -69,7 +69,7 @@ public class XPathBuilderTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStringWithUnknownNamespace() {
|
public void testStringWithUnknownNamespace() {
|
||||||
final String name = RandomStringUtils.randomAlphanumeric(5);
|
final String name = getRandomString(5);
|
||||||
final XPathBuilder b = new XPathBuilder(name);
|
final XPathBuilder b = new XPathBuilder(name);
|
||||||
final Map<String, String> ns = new HashMap<>();
|
final Map<String, String> ns = new HashMap<>();
|
||||||
ns.put("p", "http://somens");
|
ns.put("p", "http://somens");
|
||||||
|
|
@ -82,7 +82,7 @@ public class XPathBuilderTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExecutable() {
|
public void testExecutable() {
|
||||||
final String name = RandomStringUtils.randomAlphanumeric(5);
|
final String name = getRandomString(5);
|
||||||
final ContentRepository repository = Simple.createContentRepository();
|
final ContentRepository repository = Simple.createContentRepository();
|
||||||
final XPathExecutable xpath = repository.createXPath("//*", Collections.emptyMap());
|
final XPathExecutable xpath = repository.createXPath("//*", Collections.emptyMap());
|
||||||
final XPathBuilder b = new XPathBuilder(name);
|
final XPathBuilder b = new XPathBuilder(name);
|
||||||
|
|
@ -96,7 +96,7 @@ public class XPathBuilderTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExecutableWithNamespace() {
|
public void testExecutableWithNamespace() {
|
||||||
final String name = RandomStringUtils.randomAlphanumeric(5);
|
final String name = getRandomString(5);
|
||||||
final ContentRepository repository = Simple.createContentRepository();
|
final ContentRepository repository = Simple.createContentRepository();
|
||||||
final Map<String, String> ns = new HashMap<>();
|
final Map<String, String> ns = new HashMap<>();
|
||||||
ns.put("p", "http://somens");
|
ns.put("p", "http://somens");
|
||||||
|
|
@ -123,10 +123,16 @@ public class XPathBuilderTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNoConfig() {
|
public void testNoConfig() {
|
||||||
final String name = RandomStringUtils.randomAlphanumeric(5);
|
final String name = getRandomString(5);
|
||||||
final XPathBuilder b = new XPathBuilder(name);
|
final XPathBuilder b = new XPathBuilder(name);
|
||||||
final Result<XPathExecutable, String> result = b.build(Simple.createContentRepository());
|
final Result<XPathExecutable, String> result = b.build(Simple.createContentRepository());
|
||||||
assertThat(result).isNotNull();
|
assertThat(result).isNotNull();
|
||||||
assertThat(result.isValid()).isFalse();
|
assertThat(result.isValid()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("SameParameterValue")
|
||||||
|
private String getRandomString(final int length) {
|
||||||
|
RandomStringGenerator rsg = new RandomStringGenerator.Builder().filteredBy(Character::isLetterOrDigit).get();
|
||||||
|
return rsg.generate(length);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
package de.kosit.validationtool.impl;
|
package de.kosit.validationtool.impl;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.junit.Assert.assertThrows;
|
||||||
|
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
@ -28,9 +29,7 @@ import java.util.Map;
|
||||||
import javax.xml.validation.Schema;
|
import javax.xml.validation.Schema;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.ExpectedException;
|
|
||||||
|
|
||||||
import de.kosit.validationtool.impl.Helper.Simple;
|
import de.kosit.validationtool.impl.Helper.Simple;
|
||||||
|
|
||||||
|
|
@ -46,9 +45,6 @@ public class ContentRepositoryTest {
|
||||||
|
|
||||||
private ContentRepository repository;
|
private ContentRepository repository;
|
||||||
|
|
||||||
@Rule
|
|
||||||
public ExpectedException exception = ExpectedException.none();
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
this.repository = Simple.createContentRepository();
|
this.repository = Simple.createContentRepository();
|
||||||
|
|
@ -62,8 +58,7 @@ public class ContentRepositoryTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateSchemaNotExisting() throws Exception {
|
public void testCreateSchemaNotExisting() throws Exception {
|
||||||
this.exception.expect(IllegalStateException.class);
|
assertThrows(IllegalStateException.class, () -> this.repository.createSchema(Simple.NOT_EXISTING.toURL()));
|
||||||
this.repository.createSchema(Simple.NOT_EXISTING.toURL());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -74,8 +69,7 @@ public class ContentRepositoryTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLoadXSLTNotExisting() {
|
public void testLoadXSLTNotExisting() {
|
||||||
this.exception.expect(IllegalStateException.class);
|
assertThrows(IllegalStateException.class, () -> this.repository.loadXsltScript(Simple.NOT_EXISTING));
|
||||||
this.repository.loadXsltScript(Simple.NOT_EXISTING);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -92,14 +86,12 @@ public class ContentRepositoryTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testXpathCreationWithoutNamespace() {
|
public void testXpathCreationWithoutNamespace() {
|
||||||
this.exception.expect(IllegalStateException.class);
|
assertThrows(IllegalStateException.class, () -> this.repository.createXPath("//html:html", null));
|
||||||
this.repository.createXPath("//html:html", null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIllegalXpath() {
|
public void testIllegalXpath() {
|
||||||
this.exception.expect(IllegalStateException.class);
|
assertThrows(IllegalStateException.class, () -> this.repository.createXPath("kein Xpath Ausdruck", null));
|
||||||
this.repository.createXPath("kein Xpath Ausdruck", null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
|
|
@ -16,16 +16,15 @@
|
||||||
|
|
||||||
package de.kosit.validationtool.impl;
|
package de.kosit.validationtool.impl;
|
||||||
|
|
||||||
import static org.assertj.core.api.Java6Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.junit.Assert.assertThrows;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.ExpectedException;
|
|
||||||
|
|
||||||
import de.kosit.validationtool.impl.Helper.Invalid;
|
import de.kosit.validationtool.impl.Helper.Invalid;
|
||||||
import de.kosit.validationtool.impl.Helper.Simple;
|
import de.kosit.validationtool.impl.Helper.Simple;
|
||||||
|
|
@ -40,9 +39,6 @@ public class ConversionServiceTest {
|
||||||
|
|
||||||
private static final URL SCHEMA = ConversionServiceTest.class.getResource("/xsd/scenarios.xsd");
|
private static final URL SCHEMA = ConversionServiceTest.class.getResource("/xsd/scenarios.xsd");
|
||||||
|
|
||||||
@Rule
|
|
||||||
public ExpectedException exception = ExpectedException.none();
|
|
||||||
|
|
||||||
private ConversionService service;
|
private ConversionService service;
|
||||||
|
|
||||||
private ContentRepository repository;
|
private ContentRepository repository;
|
||||||
|
|
@ -55,15 +51,15 @@ public class ConversionServiceTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMarshalNull() {
|
public void testMarshalNull() {
|
||||||
this.exception.expect(ConversionService.ConversionException.class);
|
assertThrows(ConversionService.ConversionException.class, () -> this.service.writeXml(null));
|
||||||
this.service.writeXml(null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMarshalUnknown() {
|
public void testMarshalUnknown() {
|
||||||
this.exception.expect(ConversionService.ConversionException.class);
|
assertThrows(ConversionService.ConversionException.class, () -> this.service.writeXml(new Serializable() {
|
||||||
this.service.writeXml(new Serializable() {
|
|
||||||
});
|
private static final long serialVersionUID = 8745690876369610705L;
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -82,32 +78,29 @@ public class ConversionServiceTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUnmarshalInvalidXml() {
|
public void testUnmarshalInvalidXml() {
|
||||||
this.exception.expect(ConversionService.ConversionException.class);
|
assertThrows(ConversionService.ConversionException.class,
|
||||||
this.service.readXml(Invalid.SCENARIOS, Scenarios.class, this.repository.createSchema(SCHEMA));
|
() -> this.service.readXml(Invalid.SCENARIOS, Scenarios.class, this.repository.createSchema(SCHEMA)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUnmarshalIllFormed() {
|
public void testUnmarshalIllFormed() {
|
||||||
this.exception.expect(ConversionService.ConversionException.class);
|
assertThrows(ConversionService.ConversionException.class,
|
||||||
this.service.readXml(Invalid.SCENARIOS_ILLFORMED, Scenarios.class, this.repository.createSchema(SCHEMA));
|
() -> this.service.readXml(Invalid.SCENARIOS_ILLFORMED, Scenarios.class, this.repository.createSchema(SCHEMA)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUnmarshalEmpty() {
|
public void testUnmarshalEmpty() {
|
||||||
this.exception.expect(ConversionService.ConversionException.class);
|
assertThrows(ConversionService.ConversionException.class, () -> this.service.readXml(null, Scenarios.class));
|
||||||
this.service.readXml(null, Scenarios.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUnmarshalUnknownType() throws URISyntaxException {
|
public void testUnmarshalUnknownType() throws URISyntaxException {
|
||||||
this.exception.expect(ConversionService.ConversionException.class);
|
assertThrows(ConversionService.ConversionException.class, () -> this.service.readXml(Simple.SCENARIOS, ConversionService.class));
|
||||||
this.service.readXml(Simple.SCENARIOS, ConversionService.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUnmarshalWithoutType() throws URISyntaxException {
|
public void testUnmarshalWithoutType() throws URISyntaxException {
|
||||||
this.exception.expect(ConversionService.ConversionException.class);
|
assertThrows(ConversionService.ConversionException.class, () -> this.service.readXml(Simple.SCENARIOS, null));
|
||||||
this.service.readXml(Simple.SCENARIOS, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
package de.kosit.validationtool.impl;
|
package de.kosit.validationtool.impl;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.junit.Assert.assertThrows;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
|
|
@ -26,9 +27,7 @@ import javax.xml.transform.Source;
|
||||||
import javax.xml.transform.TransformerException;
|
import javax.xml.transform.TransformerException;
|
||||||
import javax.xml.transform.URIResolver;
|
import javax.xml.transform.URIResolver;
|
||||||
|
|
||||||
import org.junit.Rule;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.ExpectedException;
|
|
||||||
|
|
||||||
import de.kosit.validationtool.impl.xml.RelativeUriResolver;
|
import de.kosit.validationtool.impl.xml.RelativeUriResolver;
|
||||||
|
|
||||||
|
|
@ -49,9 +48,6 @@ public class RelativeUriResolverTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Rule
|
|
||||||
public ExpectedException exception = ExpectedException.none();
|
|
||||||
|
|
||||||
private URIResolver resolver = new RelativeUriResolver(BASE);
|
private URIResolver resolver = new RelativeUriResolver(BASE);
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -62,14 +58,12 @@ public class RelativeUriResolverTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNotExisting() throws TransformerException {
|
public void testNotExisting() throws TransformerException {
|
||||||
this.exception.expect(TransformerException.class);
|
assertThrows(TransformerException.class, () -> this.resolver.resolve("ubl-0001", BASE.toASCIIString()));
|
||||||
this.resolver.resolve("ubl-0001", BASE.toASCIIString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOutOfPath() throws TransformerException {
|
public void testOutOfPath() throws TransformerException {
|
||||||
this.exception.expect(TransformerException.class);
|
assertThrows(TransformerException.class, () -> this.resolver.resolve("../results/report.xml", BASE.toASCIIString()));
|
||||||
this.resolver.resolve("../results/report.xml", BASE.toASCIIString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ package de.kosit.validationtool.impl;
|
||||||
|
|
||||||
import static de.kosit.validationtool.api.InputFactory.read;
|
import static de.kosit.validationtool.api.InputFactory.read;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.junit.Assert.assertThrows;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
@ -25,9 +26,7 @@ import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.ExpectedException;
|
|
||||||
|
|
||||||
import de.kosit.validationtool.config.TestConfiguration;
|
import de.kosit.validationtool.config.TestConfiguration;
|
||||||
import de.kosit.validationtool.impl.Helper.Simple;
|
import de.kosit.validationtool.impl.Helper.Simple;
|
||||||
|
|
@ -45,9 +44,6 @@ import net.sf.saxon.s9api.XdmNode;
|
||||||
|
|
||||||
public class ScenarioRepositoryTest {
|
public class ScenarioRepositoryTest {
|
||||||
|
|
||||||
@Rule
|
|
||||||
public ExpectedException expectedException = ExpectedException.none();
|
|
||||||
|
|
||||||
private ScenarioRepository repository;
|
private ScenarioRepository repository;
|
||||||
|
|
||||||
private TestConfiguration configInstance;
|
private TestConfiguration configInstance;
|
||||||
|
|
@ -109,8 +105,7 @@ public class ScenarioRepositoryTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNoConfiguration() {
|
public void testNoConfiguration() {
|
||||||
this.expectedException.expect(IllegalArgumentException.class);
|
assertThrows(IllegalArgumentException.class, () -> this.repository = new ScenarioRepository());
|
||||||
this.repository = new ScenarioRepository();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
|
|
@ -17,14 +17,13 @@
|
||||||
package de.kosit.validationtool.impl;
|
package de.kosit.validationtool.impl;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.junit.Assert.assertThrows;
|
||||||
|
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.ExpectedException;
|
|
||||||
|
|
||||||
import de.kosit.validationtool.impl.Helper.Simple;
|
import de.kosit.validationtool.impl.Helper.Simple;
|
||||||
import de.kosit.validationtool.model.scenarios.Scenarios;
|
import de.kosit.validationtool.model.scenarios.Scenarios;
|
||||||
|
|
@ -44,9 +43,6 @@ public class VersioningTest {
|
||||||
|
|
||||||
private static final URL NEW_VERSION = VersioningTest.class.getResource("/examples/versioning/scenarios-newversion.xml");
|
private static final URL NEW_VERSION = VersioningTest.class.getResource("/examples/versioning/scenarios-newversion.xml");
|
||||||
|
|
||||||
@Rule
|
|
||||||
public ExpectedException exception = ExpectedException.none();
|
|
||||||
|
|
||||||
private ConversionService service;
|
private ConversionService service;
|
||||||
|
|
||||||
private ContentRepository repository;
|
private ContentRepository repository;
|
||||||
|
|
@ -71,13 +67,13 @@ public class VersioningTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNewFeature() throws URISyntaxException {
|
public void testNewFeature() throws URISyntaxException {
|
||||||
this.exception.expect(ConversionService.ConversionException.class);
|
assertThrows(ConversionService.ConversionException.class,
|
||||||
this.service.readXml(NEW_FEATURE.toURI(), Scenarios.class, SchemaProvider.getScenarioSchema());
|
() -> this.service.readXml(NEW_FEATURE.toURI(), Scenarios.class, SchemaProvider.getScenarioSchema()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNewVersion() throws URISyntaxException {
|
public void testNewVersion() throws URISyntaxException {
|
||||||
this.exception.expect(ConversionService.ConversionException.class);
|
assertThrows(ConversionService.ConversionException.class,
|
||||||
this.service.readXml(NEW_VERSION.toURI(), Scenarios.class, SchemaProvider.getScenarioSchema());
|
() -> this.service.readXml(NEW_VERSION.toURI(), Scenarios.class, SchemaProvider.getScenarioSchema()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,11 +18,10 @@ package de.kosit.validationtool.impl.tasks;
|
||||||
|
|
||||||
import static de.kosit.validationtool.api.InputFactory.read;
|
import static de.kosit.validationtool.api.InputFactory.read;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.junit.Assert.assertThrows;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.ExpectedException;
|
|
||||||
|
|
||||||
import de.kosit.validationtool.impl.Helper;
|
import de.kosit.validationtool.impl.Helper;
|
||||||
import de.kosit.validationtool.impl.Helper.Simple;
|
import de.kosit.validationtool.impl.Helper.Simple;
|
||||||
|
|
@ -38,9 +37,6 @@ import net.sf.saxon.s9api.XdmNode;
|
||||||
*/
|
*/
|
||||||
public class DocumentParseActionTest {
|
public class DocumentParseActionTest {
|
||||||
|
|
||||||
@Rule
|
|
||||||
public ExpectedException exception = ExpectedException.none();
|
|
||||||
|
|
||||||
private DocumentParseAction action;
|
private DocumentParseAction action;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
|
|
@ -68,9 +64,6 @@ public class DocumentParseActionTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNullInput() {
|
public void testNullInput() {
|
||||||
this.exception.expect(IllegalArgumentException.class);
|
assertThrows(IllegalArgumentException.class, () -> this.action.parseDocument(null));
|
||||||
this.action.parseDocument(null);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,6 @@ import javax.xml.validation.Validator;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.ExpectedException;
|
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
import de.kosit.validationtool.api.Input;
|
import de.kosit.validationtool.api.Input;
|
||||||
|
|
@ -56,8 +55,6 @@ import de.kosit.validationtool.impl.tasks.CheckAction.Bag;
|
||||||
*/
|
*/
|
||||||
public class SchemaValidatorActionTest {
|
public class SchemaValidatorActionTest {
|
||||||
|
|
||||||
public ExpectedException expectedException = ExpectedException.none();
|
|
||||||
|
|
||||||
private SchemaValidationAction service;
|
private SchemaValidationAction service;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package de.kosit.validationtool.impl.xml;
|
package de.kosit.validationtool.impl.xml;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertThrows;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Mockito.doThrow;
|
import static org.mockito.Mockito.doThrow;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
@ -25,9 +26,7 @@ import static org.mockito.Mockito.verify;
|
||||||
import javax.xml.XMLConstants;
|
import javax.xml.XMLConstants;
|
||||||
import javax.xml.validation.SchemaFactory;
|
import javax.xml.validation.SchemaFactory;
|
||||||
|
|
||||||
import org.junit.Rule;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.ExpectedException;
|
|
||||||
import org.xml.sax.SAXNotRecognizedException;
|
import org.xml.sax.SAXNotRecognizedException;
|
||||||
import org.xml.sax.SAXNotSupportedException;
|
import org.xml.sax.SAXNotSupportedException;
|
||||||
|
|
||||||
|
|
@ -51,9 +50,6 @@ public class BaseResolverConfigurationTest {
|
||||||
|
|
||||||
public static final String NOT_EXISTING_SCHEME = "not-existing-scheme";
|
public static final String NOT_EXISTING_SCHEME = "not-existing-scheme";
|
||||||
|
|
||||||
@Rule
|
|
||||||
public ExpectedException expectedException = ExpectedException.none();
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIgnoreUnsupportedProperty() throws SAXNotRecognizedException, SAXNotSupportedException {
|
public void testIgnoreUnsupportedProperty() throws SAXNotRecognizedException, SAXNotSupportedException {
|
||||||
final SchemaFactory sf = mock(SchemaFactory.class);
|
final SchemaFactory sf = mock(SchemaFactory.class);
|
||||||
|
|
@ -64,11 +60,10 @@ public class BaseResolverConfigurationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFailOnUnsupportedProperty() throws SAXNotRecognizedException, SAXNotSupportedException {
|
public void testFailOnUnsupportedProperty() throws SAXNotRecognizedException, SAXNotSupportedException {
|
||||||
this.expectedException.expect(IllegalStateException.class);
|
|
||||||
final SchemaFactory sf = mock(SchemaFactory.class);
|
final SchemaFactory sf = mock(SchemaFactory.class);
|
||||||
final TestResolvingStrategy s = new TestResolvingStrategy();
|
final TestResolvingStrategy s = new TestResolvingStrategy();
|
||||||
doThrow(new SAXNotRecognizedException("not supported")).when(sf).setProperty(any(), any());
|
doThrow(new SAXNotRecognizedException("not supported")).when(sf).setProperty(any(), any());
|
||||||
s.setInternalProperty(sf, false);
|
assertThrows(IllegalStateException.class, () -> s.setInternalProperty(sf, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import javax.xml.validation.Schema;
|
import javax.xml.validation.Schema;
|
||||||
import javax.xml.validation.SchemaFactory;
|
import javax.xml.validation.SchemaFactory;
|
||||||
|
|
||||||
import org.junit.Rule;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.ExpectedException;
|
|
||||||
|
|
||||||
import de.kosit.validationtool.api.ResolvingConfigurationStrategy;
|
import de.kosit.validationtool.api.ResolvingConfigurationStrategy;
|
||||||
import de.kosit.validationtool.impl.Helper.Resolving;
|
import de.kosit.validationtool.impl.Helper.Resolving;
|
||||||
|
|
@ -35,9 +33,6 @@ import de.kosit.validationtool.impl.Helper.Resolving;
|
||||||
*/
|
*/
|
||||||
public class RemoteResolvingStrategyTest {
|
public class RemoteResolvingStrategyTest {
|
||||||
|
|
||||||
@Rule
|
|
||||||
public ExpectedException expectedException = ExpectedException.none();
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRemoteSchemaResolving() throws Exception {
|
public void testRemoteSchemaResolving() throws Exception {
|
||||||
final ResolvingConfigurationStrategy s = new RemoteResolvingStrategy();
|
final ResolvingConfigurationStrategy s = new RemoteResolvingStrategy();
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,7 @@ import net.sf.saxon.s9api.XsltTransformer;
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class SaxonSecurityTest {
|
public class SaxonSecurityTest {
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Test
|
@Test
|
||||||
public void testEvilStylesheets() throws IOException {
|
public void testEvilStylesheets() throws IOException {
|
||||||
final Processor p = TestObjectFactory.createProcessor();
|
final Processor p = TestObjectFactory.createProcessor();
|
||||||
|
|
@ -62,11 +63,13 @@ public class SaxonSecurityTest {
|
||||||
final URL resource = SaxonSecurityTest.class.getResource(String.format("/evil/evil%s.xsl", i));
|
final URL resource = SaxonSecurityTest.class.getResource(String.format("/evil/evil%s.xsl", i));
|
||||||
final XsltCompiler compiler = p.newXsltCompiler();
|
final XsltCompiler compiler = p.newXsltCompiler();
|
||||||
final RelativeUriResolver resolver = new RelativeUriResolver(Simple.REPOSITORY_URI);
|
final RelativeUriResolver resolver = new RelativeUriResolver(Simple.REPOSITORY_URI);
|
||||||
|
// TODO: Replace call to deprecated method.
|
||||||
compiler.setURIResolver(resolver);
|
compiler.setURIResolver(resolver);
|
||||||
final XsltExecutable executable = compiler.compile(new StreamSource(resource.openStream()));
|
final XsltExecutable executable = compiler.compile(new StreamSource(resource.openStream()));
|
||||||
final XsltTransformer transformer = executable.load();
|
final XsltTransformer transformer = executable.load();
|
||||||
final Source document = InputFactory.read("<root/>".getBytes(), "dummy").getSource();
|
final Source document = InputFactory.read("<root/>".getBytes(), "dummy").getSource();
|
||||||
// transformer.getUnderlyingController().setUnparsedTextURIResolver(resolver);
|
// transformer.getUnderlyingController().setUnparsedTextURIResolver(resolver);
|
||||||
|
// TODO: Replace call to deprecated method.
|
||||||
transformer.setURIResolver(resolver);
|
transformer.setURIResolver(resolver);
|
||||||
transformer.setSource(document);
|
transformer.setSource(document);
|
||||||
final XdmDestination result = new XdmDestination();
|
final XdmDestination result = new XdmDestination();
|
||||||
|
|
|
||||||
|
|
@ -17,14 +17,12 @@
|
||||||
package de.kosit.validationtool.impl.xml;
|
package de.kosit.validationtool.impl.xml;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.junit.Assert.assertThrows;
|
||||||
|
|
||||||
import javax.xml.validation.Schema;
|
import javax.xml.validation.Schema;
|
||||||
import javax.xml.validation.SchemaFactory;
|
import javax.xml.validation.SchemaFactory;
|
||||||
|
|
||||||
import org.hamcrest.Matchers;
|
|
||||||
import org.junit.Rule;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.ExpectedException;
|
|
||||||
import org.xml.sax.SAXParseException;
|
import org.xml.sax.SAXParseException;
|
||||||
|
|
||||||
import de.kosit.validationtool.api.ResolvingConfigurationStrategy;
|
import de.kosit.validationtool.api.ResolvingConfigurationStrategy;
|
||||||
|
|
@ -37,16 +35,12 @@ import de.kosit.validationtool.impl.Helper.Resolving;
|
||||||
*/
|
*/
|
||||||
public class StrictLocalResolvingTest {
|
public class StrictLocalResolvingTest {
|
||||||
|
|
||||||
@Rule
|
|
||||||
public ExpectedException expectedException = ExpectedException.none();
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRemoteSchemaResolving() throws Exception {
|
public void testRemoteSchemaResolving() throws Exception {
|
||||||
this.expectedException.expect(SAXParseException.class);
|
|
||||||
this.expectedException.expectMessage(Matchers.containsString("schema_reference"));
|
|
||||||
final ResolvingConfigurationStrategy s = new StrictLocalResolvingStrategy();
|
final ResolvingConfigurationStrategy s = new StrictLocalResolvingStrategy();
|
||||||
final SchemaFactory schemaFactory = s.createSchemaFactory();
|
final SchemaFactory schemaFactory = s.createSchemaFactory();
|
||||||
schemaFactory.newSchema(Resolving.SCHEMA_WITH_REMOTE_REFERENCE.toURL());
|
Throwable e = assertThrows(SAXParseException.class, () -> schemaFactory.newSchema(Resolving.SCHEMA_WITH_REMOTE_REFERENCE.toURL()));
|
||||||
|
assertThat(e).hasMessageContaining("schema_reference");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
|
|
@ -17,14 +17,12 @@
|
||||||
package de.kosit.validationtool.impl.xml;
|
package de.kosit.validationtool.impl.xml;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.junit.Assert.assertThrows;
|
||||||
|
|
||||||
import javax.xml.validation.Schema;
|
import javax.xml.validation.Schema;
|
||||||
import javax.xml.validation.SchemaFactory;
|
import javax.xml.validation.SchemaFactory;
|
||||||
|
|
||||||
import org.hamcrest.Matchers;
|
|
||||||
import org.junit.Rule;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.ExpectedException;
|
|
||||||
import org.xml.sax.SAXParseException;
|
import org.xml.sax.SAXParseException;
|
||||||
|
|
||||||
import de.kosit.validationtool.api.ResolvingConfigurationStrategy;
|
import de.kosit.validationtool.api.ResolvingConfigurationStrategy;
|
||||||
|
|
@ -37,16 +35,12 @@ import de.kosit.validationtool.impl.Helper.Resolving;
|
||||||
*/
|
*/
|
||||||
public class StrictRelativeResolvingTest {
|
public class StrictRelativeResolvingTest {
|
||||||
|
|
||||||
@Rule
|
|
||||||
public ExpectedException expectedException = ExpectedException.none();
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRemoteSchemaResolving() throws Exception {
|
public void testRemoteSchemaResolving() throws Exception {
|
||||||
this.expectedException.expect(SAXParseException.class);
|
|
||||||
this.expectedException.expectMessage(Matchers.containsString("schema_reference"));
|
|
||||||
final ResolvingConfigurationStrategy s = new StrictLocalResolvingStrategy();
|
final ResolvingConfigurationStrategy s = new StrictLocalResolvingStrategy();
|
||||||
final SchemaFactory schemaFactory = s.createSchemaFactory();
|
final SchemaFactory schemaFactory = s.createSchemaFactory();
|
||||||
schemaFactory.newSchema(Resolving.SCHEMA_WITH_REMOTE_REFERENCE.toURL());
|
Throwable e = assertThrows(SAXParseException.class, () -> schemaFactory.newSchema(Resolving.SCHEMA_WITH_REMOTE_REFERENCE.toURL()));
|
||||||
|
assertThat(e).hasMessageContaining("schema_reference");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue