Compare commits

..

3 commits

Author SHA1 Message Date
Renzo Kottmann
edde0f5134 Merge branch '104-backwards-incompatibility-problem-from-1-4-2-to-1-5-0' into 'release/1.5.x'
Resolve "Backwards incompatibility problem from 1.4.2 to 1.5.0"

See merge request kosit/validator!66
2025-08-19 18:05:54 +02:00
Philip Helger
e4d4ee44e5 Resolve "Backwards incompatibility problem from 1.4.2 to 1.5.0" 2025-08-19 18:05:54 +02:00
Renzo Kottmann
a45563e41a [maven-release-plugin] rollback the release of v1.5.1 2025-08-19 16:12:50 +02:00
5 changed files with 170 additions and 85 deletions

30
pom.xml
View file

@ -612,6 +612,12 @@
<profiles> <profiles>
<profile> <profile>
<id>release-sign-artifacts</id> <id>release-sign-artifacts</id>
<activation>
<property>
<name>performRelease</name>
<value>true</value>
</property>
</activation>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
@ -630,30 +636,6 @@
</plugins> </plugins>
</build> </build>
</profile> </profile>
<profile>
<id>release-central</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
<profile> <profile>
<id>owasp-check</id> <id>owasp-check</id>
<build> <build>

View file

@ -16,7 +16,7 @@
package de.kosit.validationtool.cmd; package de.kosit.validationtool.cmd;
import static org.apache.commons.lang3.ObjectUtils.defaultIfNull; import static org.apache.commons.lang3.ObjectUtils.getIfNull;
import static org.apache.commons.lang3.StringUtils.EMPTY; import static org.apache.commons.lang3.StringUtils.EMPTY;
import static org.apache.commons.lang3.StringUtils.isNotEmpty; import static org.apache.commons.lang3.StringUtils.isNotEmpty;
@ -37,14 +37,11 @@ import java.util.stream.Stream;
import org.fusesource.jansi.AnsiRenderer.Code; import org.fusesource.jansi.AnsiRenderer.Code;
import lombok.extern.slf4j.Slf4j;
import de.kosit.validationtool.api.Configuration; import de.kosit.validationtool.api.Configuration;
import de.kosit.validationtool.api.Input; import de.kosit.validationtool.api.Input;
import de.kosit.validationtool.api.InputFactory; import de.kosit.validationtool.api.InputFactory;
import de.kosit.validationtool.api.Result; import de.kosit.validationtool.api.Result;
import de.kosit.validationtool.cmd.CommandLineOptions.CliOptions; import de.kosit.validationtool.cmd.CommandLineOptions.CliOptions;
import de.kosit.validationtool.cmd.CommandLineOptions.Definition;
import de.kosit.validationtool.cmd.CommandLineOptions.RepositoryDefinition; import de.kosit.validationtool.cmd.CommandLineOptions.RepositoryDefinition;
import de.kosit.validationtool.cmd.CommandLineOptions.ScenarioDefinition; import de.kosit.validationtool.cmd.CommandLineOptions.ScenarioDefinition;
import de.kosit.validationtool.cmd.assertions.Assertions; import de.kosit.validationtool.cmd.assertions.Assertions;
@ -55,7 +52,7 @@ import de.kosit.validationtool.impl.EngineInformation;
import de.kosit.validationtool.impl.Printer; import de.kosit.validationtool.impl.Printer;
import de.kosit.validationtool.impl.ScenarioRepository; import de.kosit.validationtool.impl.ScenarioRepository;
import de.kosit.validationtool.impl.xml.ProcessorProvider; import de.kosit.validationtool.impl.xml.ProcessorProvider;
import lombok.extern.slf4j.Slf4j;
import net.sf.saxon.s9api.Processor; import net.sf.saxon.s9api.Processor;
/** /**
@ -132,7 +129,7 @@ public class Validator {
final Processor processor = ProcessorProvider.getProcessor(); final Processor processor = ProcessorProvider.getProcessor();
final List<Configuration> config = getConfiguration(cmd); final List<Configuration> config = getConfiguration(cmd);
final InternalCheck check = new InternalCheck(processor, config.toArray(new Configuration[0])); final InternalCheck check = new InternalCheck(processor, config.toArray(new Configuration[0]));
final CommandLineOptions.CliOptions cliOptions = defaultIfNull(cmd.getCliOptions(), new CliOptions()); final CommandLineOptions.CliOptions cliOptions = getIfNull(cmd.getCliOptions(), new CliOptions());
final Path outputDirectory = determineOutputDirectory(cliOptions); final Path outputDirectory = determineOutputDirectory(cliOptions);
if (cliOptions.isExtractHtml()) { if (cliOptions.isExtractHtml()) {
check.getCheckSteps().add(new ExtractHtmlContentAction(processor, outputDirectory)); check.getCheckSteps().add(new ExtractHtmlContentAction(processor, outputDirectory));
@ -180,17 +177,19 @@ public class Validator {
* @return a list of configurations of the scenarios and repositories passed in cmd * @return a list of configurations of the scenarios and repositories passed in cmd
*/ */
private static List<Configuration> getConfiguration(final CommandLineOptions cmd) { private static List<Configuration> getConfiguration(final CommandLineOptions cmd) {
final List<ScenarioDefinition> scenarios = defaultIfNull(cmd.getScenarios(), Collections.emptyList()); final List<ScenarioDefinition> scenarios = getIfNull(cmd.getScenarios(), Collections.emptyList());
// Map from scenario name to scenario path
final Map<String, Path> mappedScenarios = scenarios.stream() final Map<String, Path> mappedScenarios = scenarios.stream()
.collect(Collectors.toMap(ScenarioDefinition::getName, ScenarioDefinition::getPath)); .collect(Collectors.toMap(ScenarioDefinition::getName, ScenarioDefinition::getPath));
final List<RepositoryDefinition> repos = defaultIfNull(cmd.getRepositories(), Collections.emptyList()); final List<RepositoryDefinition> repos = getIfNull(cmd.getRepositories(), Collections.emptyList());
final Map<String, Path> mappedRepos = repos.stream().collect(Collectors.toMap(Definition::getName, Definition::getPath)); final Map<String, Path> mappedRepos = repos.stream()
.collect(Collectors.toMap(RepositoryDefinition::getName, RepositoryDefinition::getPath));
checkUnused(mappedScenarios, mappedRepos); checkUnused(mappedScenarios, mappedRepos);
return mappedScenarios.entrySet().stream().map(e -> { return mappedScenarios.entrySet().stream().map(e -> {
assertFileExistance(e.getValue(), "scenario"); assertFileExistance(e.getValue(), "scenario");
final URI scenarioLocation = e.getValue().toUri(); final URI scenarioLocation = e.getValue().toUri();
final URI repositoryLocation = findRepository(e.getKey(), mappedRepos); final URI repositoryLocation = findRepository(scenarioLocation, e.getKey(), mappedRepos);
reportLoading(scenarioLocation, repositoryLocation); reportLoading(scenarioLocation, repositoryLocation);
final Configuration configuration = Configuration.load(scenarioLocation, repositoryLocation) final Configuration configuration = Configuration.load(scenarioLocation, repositoryLocation)
@ -208,9 +207,14 @@ public class Validator {
unused.forEach(e -> Printer.writeErr("Warning: repository definition \"{0}\" is not used", e.getKey())); unused.forEach(e -> Printer.writeErr("Warning: repository definition \"{0}\" is not used", e.getKey()));
} }
private static URI findRepository(final String key, final Map<String, Path> repositories) { private static URI findRepository(final URI scenarioLocation, final String key, final Map<String, Path> repositories) {
final Path path = repositories.getOrDefault(key, repositories.get(ScenarioRepository.DEFAULT_ID)); final Path path = repositories.getOrDefault(key, repositories.get(ScenarioRepository.DEFAULT_ID));
if (path == null) { if (path == null) {
// If it is an unnamed scenario, use the CWD instead
if (key.startsWith(ScenarioRepository.DEFAULT)) {
// Assume directory of scenario location instead
return Paths.get(scenarioLocation).getParent().toUri();
}
throw new IllegalArgumentException(String.format("No repository location for scenario definition '%s' specified", key)); throw new IllegalArgumentException(String.format("No repository location for scenario definition '%s' specified", key));
} }
return determineRepository(path); return determineRepository(path);

View file

@ -32,9 +32,8 @@ import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import lombok.extern.slf4j.Slf4j;
import de.kosit.validationtool.impl.Helper.Simple; import de.kosit.validationtool.impl.Helper.Simple;
import lombok.extern.slf4j.Slf4j;
/** /**
* Testet die Parameter des Kommandozeilen-Tools. * Testet die Parameter des Kommandozeilen-Tools.
@ -74,7 +73,7 @@ public class CommandlineApplicationTest {
@Test @Test
public void testHelp() { public void testHelp() {
final String[] args = new String[] { "-?" }; final String[] args = { "-?" };
CommandLineApplication.mainProgram(args); CommandLineApplication.mainProgram(args);
assertThat(CommandLine.getErrorOutput()).isEmpty(); assertThat(CommandLine.getErrorOutput()).isEmpty();
checkForHelp(CommandLine.getOutputLines()); checkForHelp(CommandLine.getOutputLines());
@ -87,7 +86,7 @@ public class CommandlineApplicationTest {
@Test @Test
public void testRequiredScenarioFile() { public void testRequiredScenarioFile() {
final String[] args = new String[] { "arguments", "egal welche", "argumente drin sind" }; final String[] args = { "arguments", "egal welche", "argumente drin sind" };
CommandLineApplication.mainProgram(args); CommandLineApplication.mainProgram(args);
assertThat(CommandLine.getErrorOutput()).isNotEmpty(); assertThat(CommandLine.getErrorOutput()).isNotEmpty();
assertThat(CommandLine.getErrorOutput()).contains("Missing required option: '--scenarios"); assertThat(CommandLine.getErrorOutput()).contains("Missing required option: '--scenarios");
@ -95,7 +94,7 @@ public class CommandlineApplicationTest {
@Test @Test
public void testNotExistingScenarioFile() { public void testNotExistingScenarioFile() {
final String[] args = new String[] { "-s", Paths.get(Simple.NOT_EXISTING).toString(), Paths.get(Simple.NOT_EXISTING).toString() }; final String[] args = { "-s", Paths.get(Simple.NOT_EXISTING).toString(), Paths.get(Simple.NOT_EXISTING).toString() };
CommandLineApplication.mainProgram(args); CommandLineApplication.mainProgram(args);
assertThat(CommandLine.getErrorOutput()).isNotEmpty(); assertThat(CommandLine.getErrorOutput()).isNotEmpty();
assertThat(CommandLine.getErrorOutput()).contains("Not a valid path for scenario definition specified"); assertThat(CommandLine.getErrorOutput()).contains("Not a valid path for scenario definition specified");
@ -103,7 +102,7 @@ public class CommandlineApplicationTest {
@Test @Test
public void testIncorrectRepository() { public void testIncorrectRepository() {
final String[] args = new String[] { "-s", Paths.get(Simple.SCENARIOS).toString(), "-r", Paths.get(Simple.NOT_EXISTING).toString(), final String[] args = { "-s", Paths.get(Simple.SCENARIOS).toString(), "-r", Paths.get(Simple.NOT_EXISTING).toString(),
Paths.get(Simple.SIMPLE_VALID).toString() }; Paths.get(Simple.SIMPLE_VALID).toString() };
CommandLineApplication.mainProgram(args); CommandLineApplication.mainProgram(args);
assertThat(CommandLine.getErrorOutput()).isNotEmpty(); assertThat(CommandLine.getErrorOutput()).isNotEmpty();
@ -112,8 +111,8 @@ public class CommandlineApplicationTest {
@Test @Test
public void testNotExistingTestTarget() { public void testNotExistingTestTarget() {
final String[] args = new String[] { "-s", Paths.get(Simple.SCENARIOS).toString(), "-r", final String[] args = { "-s", Paths.get(Simple.SCENARIOS).toString(), "-r", Paths.get(Simple.REPOSITORY_URI).toString(),
Paths.get(Simple.REPOSITORY_URI).toString(), Paths.get(Simple.NOT_EXISTING).toString() }; Paths.get(Simple.NOT_EXISTING).toString() };
CommandLineApplication.mainProgram(args); CommandLineApplication.mainProgram(args);
assertThat(CommandLine.getErrorOutput()).isNotEmpty(); assertThat(CommandLine.getErrorOutput()).isNotEmpty();
assertThat(CommandLine.getErrorOutput()).contains("No test targets found"); assertThat(CommandLine.getErrorOutput()).contains("No test targets found");
@ -121,17 +120,24 @@ public class CommandlineApplicationTest {
@Test @Test
public void testValidMinimalConfiguration() { public void testValidMinimalConfiguration() {
final String[] args = new String[] { "-s", Paths.get(Simple.SCENARIOS).toString(), "-r", final String[] args = { "-s", Paths.get(Simple.SCENARIOS).toString(), "-r", Paths.get(Simple.REPOSITORY_URI).toString(),
Paths.get(Simple.REPOSITORY_URI).toString(), Paths.get(Simple.SIMPLE_VALID).toString() }; Paths.get(Simple.SIMPLE_VALID).toString() };
CommandLineApplication.mainProgram(args);
assertThat(CommandLine.getErrorOutput()).contains(RESULT_OUTPUT);
}
@Test
public void testValidMinimalConfigurationWithoutRepositoryPath() {
final String[] args = { "-s", Paths.get(Simple.SCENARIOS_WITH_RELATIVE_PATHS).toString(),
Paths.get(Simple.SIMPLE_VALID).toString() };
CommandLineApplication.mainProgram(args); CommandLineApplication.mainProgram(args);
assertThat(CommandLine.getErrorOutput()).contains(RESULT_OUTPUT); assertThat(CommandLine.getErrorOutput()).contains(RESULT_OUTPUT);
} }
@Test @Test
public void testValidNamingConfiguration() { public void testValidNamingConfiguration() {
final String[] args = new String[] { "-s", Paths.get(Simple.SCENARIOS).toString(), "-r", final String[] args = { "-s", Paths.get(Simple.SCENARIOS).toString(), "-r", Paths.get(Simple.REPOSITORY_URI).toString(),
Paths.get(Simple.REPOSITORY_URI).toString(), Paths.get(Simple.SIMPLE_VALID).toString(), "--report-prefix", "somePrefix", Paths.get(Simple.SIMPLE_VALID).toString(), "--report-prefix", "somePrefix", "--report-postfix", "somePostfix" };
"--report-postfix", "somePostfix" };
CommandLineApplication.mainProgram(args); CommandLineApplication.mainProgram(args);
assertThat(CommandLine.getErrorOutput()).contains(RESULT_OUTPUT); assertThat(CommandLine.getErrorOutput()).contains(RESULT_OUTPUT);
assertThat(CommandLine.getErrorOutput()).contains("somePrefix-simple-somePostfix"); assertThat(CommandLine.getErrorOutput()).contains("somePrefix-simple-somePostfix");
@ -139,7 +145,7 @@ public class CommandlineApplicationTest {
@Test @Test
public void testValidMultipleInput() { public void testValidMultipleInput() {
final String[] args = new String[] { "-s", Paths.get(Simple.SCENARIOS).toString(), "-o", this.output.toString(), "-r", final String[] args = { "-s", Paths.get(Simple.SCENARIOS).toString(), "-o", this.output.toString(), "-r",
Paths.get(Simple.REPOSITORY_URI).toString(), Paths.get(Simple.SIMPLE_VALID).toString(), Paths.get(Simple.FOO).toString() }; Paths.get(Simple.REPOSITORY_URI).toString(), Paths.get(Simple.SIMPLE_VALID).toString(), Paths.get(Simple.FOO).toString() };
CommandLineApplication.mainProgram(args); CommandLineApplication.mainProgram(args);
assertThat(CommandLine.getErrorOutput()).contains("Processing 2 object(s) completed"); assertThat(CommandLine.getErrorOutput()).contains("Processing 2 object(s) completed");
@ -147,7 +153,7 @@ public class CommandlineApplicationTest {
@Test @Test
public void testValidDirectoryInput() { public void testValidDirectoryInput() {
final String[] args = new String[] { "-s", Paths.get(Simple.SCENARIOS).toString(), "-o", this.output.toString(), "-r", final String[] args = { "-s", Paths.get(Simple.SCENARIOS).toString(), "-o", this.output.toString(), "-r",
Paths.get(Simple.REPOSITORY_URI).toString(), Paths.get(Simple.EXAMPLES).toString() }; Paths.get(Simple.REPOSITORY_URI).toString(), Paths.get(Simple.EXAMPLES).toString() };
CommandLineApplication.mainProgram(args); CommandLineApplication.mainProgram(args);
assertThat(CommandLine.getErrorOutput()).contains("Processing 8 object(s) completed"); assertThat(CommandLine.getErrorOutput()).contains("Processing 8 object(s) completed");
@ -156,7 +162,7 @@ public class CommandlineApplicationTest {
@Test @Test
public void testValidOutputConfiguration() throws IOException { public void testValidOutputConfiguration() throws IOException {
final String[] args = new String[] { "-s", Paths.get(Simple.SCENARIOS).toString(), "-o", this.output.toString(), "-r", final String[] args = { "-s", Paths.get(Simple.SCENARIOS).toString(), "-o", this.output.toString(), "-r",
Paths.get(Simple.REPOSITORY_URI).toString(), Paths.get(Simple.SIMPLE_VALID).toString() }; Paths.get(Simple.REPOSITORY_URI).toString(), Paths.get(Simple.SIMPLE_VALID).toString() };
CommandLineApplication.mainProgram(args); CommandLineApplication.mainProgram(args);
assertThat(CommandLine.getErrorOutput()).contains(RESULT_OUTPUT); assertThat(CommandLine.getErrorOutput()).contains(RESULT_OUTPUT);
@ -167,8 +173,7 @@ public class CommandlineApplicationTest {
@Test @Test
public void testNoInput() { public void testNoInput() {
// assertThat(output).doesNotExist(); // assertThat(output).doesNotExist();
final String[] args = new String[] { "-s", Paths.get(Simple.SCENARIOS).toString(), "-r", final String[] args = { "-s", Paths.get(Simple.SCENARIOS).toString(), "-r", Paths.get(Simple.REPOSITORY_URI).toString(), };
Paths.get(Simple.REPOSITORY_URI).toString(), };
CommandLineApplication.mainProgram(args); CommandLineApplication.mainProgram(args);
checkForHelp(CommandLine.getOutputLines()); checkForHelp(CommandLine.getOutputLines());
} }
@ -176,8 +181,8 @@ public class CommandlineApplicationTest {
@Test @Test
public void testPrint() { public void testPrint() {
final String[] args = new String[] { "-s", Paths.get(Simple.SCENARIOS).toString(), "-p", "-r", final String[] args = { "-s", Paths.get(Simple.SCENARIOS).toString(), "-p", "-r", Paths.get(Simple.REPOSITORY_URI).toString(), "-o",
Paths.get(Simple.REPOSITORY_URI).toString(), "-o", this.output.toString(), Paths.get(Simple.SIMPLE_VALID).toString() }; this.output.toString(), Paths.get(Simple.SIMPLE_VALID).toString() };
CommandLineApplication.mainProgram(args); CommandLineApplication.mainProgram(args);
assertThat(CommandLine.getErrorOutput()).contains(RESULT_OUTPUT); assertThat(CommandLine.getErrorOutput()).contains(RESULT_OUTPUT);
assertThat(CommandLine.getOutputLines()).haveAtLeastOne(new Condition<>( assertThat(CommandLine.getOutputLines()).haveAtLeastOne(new Condition<>(
@ -186,9 +191,8 @@ public class CommandlineApplicationTest {
@Test @Test
public void testHtmlExtraktion() throws IOException { public void testHtmlExtraktion() throws IOException {
final String[] args = new String[] { "-s", Paths.get(Simple.SCENARIOS).toString(), "-h", "-o", final String[] args = { "-s", Paths.get(Simple.SCENARIOS).toString(), "-h", "-o", this.output.toAbsolutePath().toString(), "-r",
this.output.toAbsolutePath().toString(), "-r", Paths.get(Simple.REPOSITORY_URI).toString(), Paths.get(Simple.REPOSITORY_URI).toString(), Paths.get(Simple.SIMPLE_VALID).toString() };
Paths.get(Simple.SIMPLE_VALID).toString() };
CommandLineApplication.mainProgram(args); CommandLineApplication.mainProgram(args);
assertThat(CommandLine.getErrorOutput()).contains(RESULT_OUTPUT); assertThat(CommandLine.getErrorOutput()).contains(RESULT_OUTPUT);
assertThat(Files.list(this.output).filter(f -> f.toString().endsWith(".html")).count()).isPositive(); assertThat(Files.list(this.output).filter(f -> f.toString().endsWith(".html")).count()).isPositive();
@ -196,9 +200,9 @@ public class CommandlineApplicationTest {
@Test @Test
public void testAssertionsExtraktion() { public void testAssertionsExtraktion() {
final String[] args = new String[] { "-d", "-s", Paths.get(Simple.SCENARIOS).toString(), "-r", final String[] args = { "-d", "-s", Paths.get(Simple.SCENARIOS).toString(), "-r", Paths.get(Simple.REPOSITORY_URI).toString(), "-o",
Paths.get(Simple.REPOSITORY_URI).toString(), "-o", this.output.toString(), "-c", Paths.get(ASSERTIONS).toString(), this.output.toString(), "-c", Paths.get(ASSERTIONS).toString(), Paths.get(Simple.REPOSITORY_URI).toString(),
Paths.get(Simple.REPOSITORY_URI).toString(), Paths.get(Simple.SIMPLE_VALID).toString() }; Paths.get(Simple.SIMPLE_VALID).toString() };
CommandLineApplication.mainProgram(args); CommandLineApplication.mainProgram(args);
assertThat(CommandLine.getErrorOutput()).contains(RESULT_OUTPUT); assertThat(CommandLine.getErrorOutput()).contains(RESULT_OUTPUT);
assertThat(CommandLine.getErrorOutput()).contains("Can not find assertions for "); assertThat(CommandLine.getErrorOutput()).contains("Can not find assertions for ");
@ -206,16 +210,16 @@ public class CommandlineApplicationTest {
@Test @Test
public void testDebugFlag() { public void testDebugFlag() {
final String[] args = new String[] { "-s", Paths.get(Simple.SCENARIOS).toString(), "-r", "unknown", "-o", this.output.toString(), final String[] args = { "-s", Paths.get(Simple.SCENARIOS).toString(), "-r", "unknown", "-o", this.output.toString(), "-d",
"-d", Paths.get(ASSERTIONS).toString() }; Paths.get(ASSERTIONS).toString() };
CommandLineApplication.mainProgram(args); CommandLineApplication.mainProgram(args);
assertThat(CommandLine.getErrorOutput()).contains("at de.kosit.validationtool"); assertThat(CommandLine.getErrorOutput()).contains("at de.kosit.validationtool");
} }
@Test @Test
public void testPrintMemoryStats() { public void testPrintMemoryStats() {
final String[] args = new String[] { "-m", "-s", Paths.get(Simple.SCENARIOS).toString(), "-r", final String[] args = { "-m", "-s", Paths.get(Simple.SCENARIOS).toString(), "-r", Paths.get(Simple.REPOSITORY_URI).toString(),
Paths.get(Simple.REPOSITORY_URI).toString(), Paths.get(Simple.SIMPLE_VALID).toString() }; Paths.get(Simple.SIMPLE_VALID).toString() };
CommandLineApplication.mainProgram(args); CommandLineApplication.mainProgram(args);
assertThat(CommandLine.getErrorOutput()).contains(RESULT_OUTPUT); assertThat(CommandLine.getErrorOutput()).contains(RESULT_OUTPUT);
assertThat(CommandLine.getErrorOutput()).contains("total"); assertThat(CommandLine.getErrorOutput()).contains("total");
@ -223,8 +227,7 @@ public class CommandlineApplicationTest {
@Test @Test
public void testReadFromPipe() throws IOException { public void testReadFromPipe() throws IOException {
final String[] args = new String[] { "-s", Paths.get(Simple.SCENARIOS).toString(), "-r", final String[] args = { "-s", Paths.get(Simple.SCENARIOS).toString(), "-r", Paths.get(Simple.REPOSITORY_URI).toString() };
Paths.get(Simple.REPOSITORY_URI).toString() };
CommandLine.setStandardInput(Files.newInputStream(Paths.get(Simple.SIMPLE_VALID))); CommandLine.setStandardInput(Files.newInputStream(Paths.get(Simple.SIMPLE_VALID)));
CommandLineApplication.mainProgram(args); CommandLineApplication.mainProgram(args);
assertThat(CommandLine.getErrorOutput()).contains(RESULT_OUTPUT); assertThat(CommandLine.getErrorOutput()).contains(RESULT_OUTPUT);
@ -232,31 +235,30 @@ public class CommandlineApplicationTest {
@Test @Test
public void testAndre() throws IOException { public void testAndre() throws IOException {
final String[] args = new String[] { "-s", Paths.get(Simple.SCENARIOS).toString(), "-r", final String[] args = { "-s", Paths.get(Simple.SCENARIOS).toString(), "-r", Paths.get(Simple.REPOSITORY_URI).toString(),
Paths.get(Simple.REPOSITORY_URI).toString(), Paths.get(Simple.SIMPLE_VALID).toString(), "--report-prefix", "andre1" }; Paths.get(Simple.SIMPLE_VALID).toString(), "--report-prefix", "andre1" };
CommandLineApplication.mainProgram(args); CommandLineApplication.mainProgram(args);
assertThat(CommandLine.getErrorOutput()).contains(RESULT_OUTPUT); assertThat(CommandLine.getErrorOutput()).contains(RESULT_OUTPUT);
} }
@Test @Test
public void testUnexpectedDaemonFlag() { public void testUnexpectedDaemonFlag() {
final String[] args = new String[] { "-D", "-s", Paths.get(Simple.SCENARIOS).toString(), "-r", final String[] args = { "-D", "-s", Paths.get(Simple.SCENARIOS).toString(), "-r", Paths.get(Simple.REPOSITORY_URI).toString(),
Paths.get(Simple.REPOSITORY_URI).toString(), Paths.get(Simple.SIMPLE_VALID).toString() }; Paths.get(Simple.SIMPLE_VALID).toString() };
CommandLineApplication.mainProgram(args); CommandLineApplication.mainProgram(args);
assertThat(CommandLine.getErrorOutput()).contains("Will ignore cli mode options"); assertThat(CommandLine.getErrorOutput()).contains("Will ignore cli mode options");
} }
@Test @Test
public void testParsingError() { public void testParsingError() {
final String[] args = new String[] { "-s", "-r", Paths.get(Simple.REPOSITORY_URI).toString(), final String[] args = { "-s", "-r", Paths.get(Simple.REPOSITORY_URI).toString(), Paths.get(Simple.SIMPLE_VALID).toString() };
Paths.get(Simple.SIMPLE_VALID).toString() };
CommandLineApplication.mainProgram(args); CommandLineApplication.mainProgram(args);
assertThat(CommandLine.getErrorOutput()).contains("Expected parameter for option"); assertThat(CommandLine.getErrorOutput()).contains("Expected parameter for option");
} }
@Test @Test
public void loadMultipleScenarios() { public void loadMultipleScenarios() {
final String[] args = new String[] { "-s", "s1=" + Paths.get(Simple.SCENARIOS).toString(), "-s", final String[] args = { "-s", "s1=" + Paths.get(Simple.SCENARIOS).toString(), "-s",
"s2=" + Paths.get(Simple.OTHER_SCENARIOS).toString(), "-r", "s1=" + Paths.get(Simple.REPOSITORY_URI).toString(), "-r", "s2=" + Paths.get(Simple.OTHER_SCENARIOS).toString(), "-r", "s1=" + Paths.get(Simple.REPOSITORY_URI).toString(), "-r",
"s2=" + Paths.get(Simple.REPOSITORY_URI).toString(), Paths.get(Simple.SIMPLE_VALID).toString() }; "s2=" + Paths.get(Simple.REPOSITORY_URI).toString(), Paths.get(Simple.SIMPLE_VALID).toString() };
CommandLineApplication.mainProgram(args); CommandLineApplication.mainProgram(args);
@ -265,7 +267,7 @@ public class CommandlineApplicationTest {
@Test @Test
public void loadMultipleScenariosSingleRepository() { public void loadMultipleScenariosSingleRepository() {
final String[] args = new String[] { "-s", "s1=" + Paths.get(Simple.SCENARIOS).toString(), "-s", final String[] args = { "-s", "s1=" + Paths.get(Simple.SCENARIOS).toString(), "-s",
"s2=" + Paths.get(Simple.OTHER_SCENARIOS).toString(), "-r", Paths.get(Simple.REPOSITORY_URI).toString(), "s2=" + Paths.get(Simple.OTHER_SCENARIOS).toString(), "-r", Paths.get(Simple.REPOSITORY_URI).toString(),
Paths.get(Simple.SIMPLE_VALID).toString() }; Paths.get(Simple.SIMPLE_VALID).toString() };
CommandLineApplication.mainProgram(args); CommandLineApplication.mainProgram(args);
@ -274,7 +276,7 @@ public class CommandlineApplicationTest {
@Test @Test
public void loadMultipleScenariosMissingRepository() { public void loadMultipleScenariosMissingRepository() {
final String[] args = new String[] { "-s", "s1=" + Paths.get(Simple.SCENARIOS).toString(), "-s", final String[] args = { "-s", "s1=" + Paths.get(Simple.SCENARIOS).toString(), "-s",
"s2=" + Paths.get(Simple.OTHER_SCENARIOS).toString(), "-r", "s1=" + Paths.get(Simple.REPOSITORY_URI).toString(), "-r", "s2=" + Paths.get(Simple.OTHER_SCENARIOS).toString(), "-r", "s1=" + Paths.get(Simple.REPOSITORY_URI).toString(), "-r",
"typo=" + Paths.get(Simple.REPOSITORY_URI).toString(), Paths.get(Simple.SIMPLE_VALID).toString() }; "typo=" + Paths.get(Simple.REPOSITORY_URI).toString(), Paths.get(Simple.SIMPLE_VALID).toString() };
CommandLineApplication.mainProgram(args); CommandLineApplication.mainProgram(args);
@ -283,16 +285,16 @@ public class CommandlineApplicationTest {
@Test @Test
public void loadMultipleOrderedScenarios() { public void loadMultipleOrderedScenarios() {
final String[] args = new String[] { "-s", Paths.get(Simple.SCENARIOS).toString(), "-s", final String[] args = { "-s", Paths.get(Simple.SCENARIOS).toString(), "-s", Paths.get(Simple.OTHER_SCENARIOS).toString(), "-r",
Paths.get(Simple.OTHER_SCENARIOS).toString(), "-r", Paths.get(Simple.REPOSITORY_URI).toString(), "-r", Paths.get(Simple.REPOSITORY_URI).toString(), "-r", Paths.get(Simple.REPOSITORY_URI).toString(),
Paths.get(Simple.REPOSITORY_URI).toString(), Paths.get(Simple.SIMPLE_VALID).toString() }; Paths.get(Simple.SIMPLE_VALID).toString() };
CommandLineApplication.mainProgram(args); CommandLineApplication.mainProgram(args);
assertThat(CommandLine.getOutput()).contains("Processing of 1 objects completed"); assertThat(CommandLine.getOutput()).contains("Processing of 1 objects completed");
} }
@Test @Test
public void checkUnusedRepository() { public void checkUnusedRepository() {
final String[] args = new String[] { "-s", "s1=" + Paths.get(Simple.SCENARIOS).toString(), "-r", final String[] args = { "-s", "s1=" + Paths.get(Simple.SCENARIOS).toString(), "-r",
"s1=" + Paths.get(Simple.REPOSITORY_URI).toString(), "-r", "unused=" + Paths.get(Simple.REPOSITORY_URI).toString(), "s1=" + Paths.get(Simple.REPOSITORY_URI).toString(), "-r", "unused=" + Paths.get(Simple.REPOSITORY_URI).toString(),
Paths.get(Simple.SIMPLE_VALID).toString() }; Paths.get(Simple.SIMPLE_VALID).toString() };
CommandLineApplication.mainProgram(args); CommandLineApplication.mainProgram(args);
@ -302,7 +304,7 @@ public class CommandlineApplicationTest {
@Test @Test
public void checkDuplicationScenarioDefinition() { public void checkDuplicationScenarioDefinition() {
final String[] args = new String[] { "-s", "s1=" + Paths.get(Simple.SCENARIOS).toString(), "-r", final String[] args = { "-s", "s1=" + Paths.get(Simple.SCENARIOS).toString(), "-r",
"s1=" + Paths.get(Simple.REPOSITORY_URI).toString(), "-r", "unused=" + Paths.get(Simple.REPOSITORY_URI).toString(), "s1=" + Paths.get(Simple.REPOSITORY_URI).toString(), "-r", "unused=" + Paths.get(Simple.REPOSITORY_URI).toString(),
Paths.get(Simple.SIMPLE_VALID).toString() }; Paths.get(Simple.SIMPLE_VALID).toString() };
CommandLineApplication.mainProgram(args); CommandLineApplication.mainProgram(args);

View file

@ -51,16 +51,18 @@ public class Helper {
public static final URI EXAMPLES = ROOT.resolve("input/"); public static final URI EXAMPLES = ROOT.resolve("input/");
public static final URI SIMPLE_VALID = Simple.ROOT.resolve("input/simple.xml"); public static final URI SIMPLE_VALID = ROOT.resolve("input/simple.xml");
public static final URI FOO = Simple.ROOT.resolve("input/foo.xml"); public static final URI FOO = ROOT.resolve("input/foo.xml");
public static final URI FOO_SCHEMATRON_INVALID = EXAMPLES.resolve("foo-schematron-invalid.xml"); public static final URI FOO_SCHEMATRON_INVALID = EXAMPLES.resolve("foo-schematron-invalid.xml");
public static final URI REJECTED = Simple.ROOT.resolve("input/withManualReject.xml"); public static final URI REJECTED = ROOT.resolve("input/withManualReject.xml");
public static final URI SCENARIOS = ROOT.resolve("scenarios.xml"); public static final URI SCENARIOS = ROOT.resolve("scenarios.xml");
public static final URI SCENARIOS_WITH_RELATIVE_PATHS = ROOT.resolve("scenarios-with-relative-paths.xml");
public static final URI OTHER_SCENARIOS = ROOT.resolve("otherScenarios.xml"); public static final URI OTHER_SCENARIOS = ROOT.resolve("otherScenarios.xml");
public static final URI ERROR_SCENARIOS = ROOT.resolve("scenarios-with-errors.xml"); public static final URI ERROR_SCENARIOS = ROOT.resolve("scenarios-with-errors.xml");

View file

@ -0,0 +1,95 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2017-2022 Koordinierungsstelle für IT-Standards (KoSIT)
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<scenarios xmlns="http://www.xoev.de/de/validator/framework/1/scenarios" frameworkVersion="1.1.2">
<name>HTML-TestSuite</name>
<author>QA</author>
<date>2025-08-19</date>
<description>
<p>Szenario für Tests</p>
</description>
<scenario>
<name>Simple</name>
<description>
<p>Nur Schemaprüfung.</p>
</description>
<namespace prefix="cri">http://www.xoev.de/de/validator/framework/1/createreportinput
</namespace>
<namespace prefix="test">
http://validator.kosit.de/test-sample</namespace>
<namespace prefix="rpt">http://validator.kosit.de/test-report</namespace>
<match>/test:simple</match>
<validateWithXmlSchema>
<resource>
<name>Sample Schema</name>
<location>repository/simple.xsd</location>
</resource>
</validateWithXmlSchema>
<validateWithSchematron>
<resource>
<name>Sample Schematron</name>
<location>repository/simple.xsl</location>
</resource>
</validateWithSchematron>
<createReport>
<resource>
<name>Report für eRechnung</name>
<location>repository/report.xsl</location>
</resource>
</createReport>
<acceptMatch>count(//test:rejected) = 0</acceptMatch>
</scenario>
<scenario>
<name>NoAcceptMatch</name>
<description>
<p>Nur Schemaprüfung. Keine AcceptMatch deklaration</p>
<p>Testen, ob auch alte Konfiguration funktionioeren</p>
</description>
<namespace prefix="test">http://validator.kosit.de/test-sample</namespace>
<match>/test:foo</match>
<validateWithXmlSchema>
<resource>
<name>Sample Schema</name>
<location>repository/simple.xsd</location>
</resource>
</validateWithXmlSchema>
<validateWithSchematron>
<resource>
<name>Sample Schematron</name>
<location>repository/simple.xsl</location>
</resource>
</validateWithSchematron>
<createReport>
<resource>
<name>Report für eRechnung</name>
<location>repository/report.xsl</location>
</resource>
</createReport>
</scenario>
<noScenarioReport>
<resource>
<name>default</name>
<location>repository/report.xsl</location>
</resource>
</noScenarioReport>
</scenarios>