From 6059834dcc66bf6cb17b2d7daebfe6434614b872 Mon Sep 17 00:00:00 2001 From: mihajlov Date: Wed, 2 Oct 2024 08:26:39 +0200 Subject: [PATCH] feat: upgrade dependencies to use Java 17 and jakarta --- pom.xml | 83 ++++++++++++------- .../api/ResolvingConfigurationStrategy.java | 2 +- .../kosit/validationtool/cmd/Validator.java | 8 +- .../validationtool/config/XPathBuilder.java | 2 +- .../impl/CollectingErrorEventHandler.java | 5 +- .../impl/ContentRepository.java | 11 ++- .../impl/ConversionService.java | 16 ++-- .../validationtool/impl/DefaultCheck.java | 4 +- .../impl/input/SourceInput.java | 4 +- .../impl/input/StreamHelper.java | 2 +- .../impl/tasks/CreateReportAction.java | 6 +- .../tasks/SchematronValidationAction.java | 2 +- .../impl/xml/StringTrimAdapter.java | 2 +- src/main/resources/app-info.properties | 4 +- .../impl/tasks/CreateReportActionTest.java | 4 +- .../impl/tasks/SchemaValidatorActionTest.java | 6 +- 16 files changed, 90 insertions(+), 71 deletions(-) diff --git a/pom.xml b/pom.xml index cd1efac..4140778 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ KoSIT XML Prüftool Implementierung de.kosit - 1.5.0 + 1.5.1 validationtool KoSIT XML Validator against XSD and Schematron based on defined scenarios. @@ -58,19 +58,19 @@ 2.11.0 3.12.0 0.8.8 - 2.3.7 + 3.0.1 1.18.24 4.9.0 7.2.0 5.2.0 - 11.4 + 12.5 1.7.36 - project.local - project - file:${project.basedir}/libs + central + Maven Central + https://repo.maven.apache.org/maven2 @@ -122,6 +122,11 @@ ${version.jaxb} true + + jakarta.xml.bind + jakarta.xml.bind-api + ${version.jaxb} + org.assertj assertj-core @@ -218,12 +223,19 @@ maven-compiler-plugin 3.10.1 - 1.8 - 1.8 + 17 + 17 + UTF-8 + + + + org.apache.maven.plugins + maven-resources-plugin + 3.1.0 + UTF-8 - org.apache.maven.plugins maven-shade-plugin @@ -270,8 +282,6 @@ org.glassfish.jaxb:jaxb-runtime com.sun.istack:istack-commons-runtime com.sun.xml.fastinfoset:FastInfoset - jakarta.activation:jakarta.activation-api - jakarta.xml.bind:jakarta.xml.bind-api org.jvnet.staxex:stax-ex org.glassfish.jaxb:txw2 @@ -323,9 +333,9 @@ - org.jvnet.jaxb2.maven2 - maven-jaxb2-plugin - 0.15.1 + org.jvnet.jaxb + jaxb-maven-plugin + 4.0.8 @@ -343,18 +353,27 @@ - org.jvnet.jaxb2_commons - jaxb2-basics - 0.11.1 + org.jvnet.jaxb + jaxb-plugins + 3.0.0 + + com.sun.xml.bind + jaxb-impl + 4.0.5 + org.glassfish.jaxb jaxb-runtime + 4.0.5 + + + jakarta.xml.bind + jakarta.xml.bind-api ${version.jaxb} - true @@ -400,11 +419,11 @@ dump - -
localhost
- ${jacoco.tcp.port} - true -
+ +
localhost
+ ${jacoco.tcp.port} + true +
generateJacocoReport @@ -453,15 +472,15 @@ exec-maven-plugin 3.1.0 - + run - pre-integration-test - + pre-integration-test + exec - + - + java false true @@ -471,7 +490,7 @@ ${jacocoFailsafe} -Xmx128m -classpath - + de.kosit.validationtool.cmd.CommandLineApplication -s ${project.build.testOutputDirectory}/examples/simple/scenarios.xml @@ -492,7 +511,7 @@ - + ${jacoco.tcp.port} @@ -518,8 +537,8 @@ verify - - -Dfile.encoding=UTF-8 -Ddaemon.port=${validator.server.port} + + -Dfile.encoding=UTF-8 -Ddaemon.port=${validator.server.port} diff --git a/src/main/java/de/kosit/validationtool/api/ResolvingConfigurationStrategy.java b/src/main/java/de/kosit/validationtool/api/ResolvingConfigurationStrategy.java index 37be24f..23187a7 100644 --- a/src/main/java/de/kosit/validationtool/api/ResolvingConfigurationStrategy.java +++ b/src/main/java/de/kosit/validationtool/api/ResolvingConfigurationStrategy.java @@ -68,7 +68,7 @@ public interface ResolvingConfigurationStrategy { * function. * * @param scenarioRepository an optional repository, your implementation might not need this - * @return a preconfigured {@link net.sf.saxon.lib.UnparsedTextURIResolver} or null for using saxons default + * @return a preconfigured {@link UnparsedTextURIResolver} or null for using saxons default */ UnparsedTextURIResolver createUnparsedTextURIResolver(URI scenarioRepository); diff --git a/src/main/java/de/kosit/validationtool/cmd/Validator.java b/src/main/java/de/kosit/validationtool/cmd/Validator.java index b5d37fc..144ee54 100644 --- a/src/main/java/de/kosit/validationtool/cmd/Validator.java +++ b/src/main/java/de/kosit/validationtool/cmd/Validator.java @@ -132,7 +132,7 @@ private static ReturnValue processActions(final CommandLineOptions cmd) throws I final Processor processor = ProcessorProvider.getProcessor(); final List config = getConfiguration(cmd); final InternalCheck check = new InternalCheck(processor, config.toArray(new Configuration[0])); - final CommandLineOptions.CliOptions cliOptions = defaultIfNull(cmd.getCliOptions(), new CliOptions()); + final CliOptions cliOptions = defaultIfNull(cmd.getCliOptions(), new CliOptions()); final Path outputDirectory = determineOutputDirectory(cliOptions); if (cliOptions.isExtractHtml()) { check.getCheckSteps().add(new ExtractHtmlContentAction(processor, outputDirectory)); @@ -235,7 +235,7 @@ private static void reportConfiguration(final Configuration configuration) { } - private static NamingStrategy determineNamingStrategy(final CommandLineOptions.CliOptions cmd) { + private static NamingStrategy determineNamingStrategy(final CliOptions cmd) { final DefaultNamingStrategy namingStrategy = new DefaultNamingStrategy(); if (isNotEmpty(cmd.getReportPrefix())) { namingStrategy.setPrefix(cmd.getReportPrefix()); @@ -256,7 +256,7 @@ private static Assertions loadAssertions(final Path p) { return a; } - private static Path determineOutputDirectory(final CommandLineOptions.CliOptions cmd) { + private static Path determineOutputDirectory(final CliOptions cmd) { final Path dir; if (cmd.getOutputPath() != null) { dir = cmd.getOutputPath(); @@ -269,7 +269,7 @@ private static Path determineOutputDirectory(final CommandLineOptions.CliOptions return dir; } - private static Collection determineTestTargets(final CommandLineOptions.CliOptions cmd) throws IOException { + private static Collection determineTestTargets(final CliOptions cmd) throws IOException { final Collection targets = new ArrayList<>(); if (cmd.getFiles() != null && !cmd.getFiles().isEmpty()) { cmd.getFiles().forEach(e -> targets.addAll(determineTestTarget(e))); diff --git a/src/main/java/de/kosit/validationtool/config/XPathBuilder.java b/src/main/java/de/kosit/validationtool/config/XPathBuilder.java index 90b5351..713f951 100644 --- a/src/main/java/de/kosit/validationtool/config/XPathBuilder.java +++ b/src/main/java/de/kosit/validationtool/config/XPathBuilder.java @@ -114,7 +114,7 @@ private void extractNamespaces() { final Iterable iterable = () -> iterator; StreamSupport.stream(iterable.spliterator(), false).filter(e -> !ArrayUtils.contains(IGNORED_PREFIXES, e)) .filter(StringUtils::isNotBlank).forEach(e -> ns.put(e, this.executable.getUnderlyingExpression().getInternalExpression() - .getRetainedStaticContext().getURIForPrefix(e, false))); + .getRetainedStaticContext().getURIForPrefix(e, false).toString())); getNamespaces().putAll(ns); } diff --git a/src/main/java/de/kosit/validationtool/impl/CollectingErrorEventHandler.java b/src/main/java/de/kosit/validationtool/impl/CollectingErrorEventHandler.java index 3897006..df40df4 100644 --- a/src/main/java/de/kosit/validationtool/impl/CollectingErrorEventHandler.java +++ b/src/main/java/de/kosit/validationtool/impl/CollectingErrorEventHandler.java @@ -20,8 +20,9 @@ import java.util.Collection; import java.util.StringJoiner; -import javax.xml.bind.ValidationEvent; -import javax.xml.bind.ValidationEventHandler; +import jakarta.xml.bind.ValidationEvent; +import jakarta.xml.bind.ValidationEventHandler; + import javax.xml.transform.ErrorListener; import javax.xml.transform.SourceLocator; import javax.xml.transform.TransformerException; diff --git a/src/main/java/de/kosit/validationtool/impl/ContentRepository.java b/src/main/java/de/kosit/validationtool/impl/ContentRepository.java index 521e3fc..b549e1f 100644 --- a/src/main/java/de/kosit/validationtool/impl/ContentRepository.java +++ b/src/main/java/de/kosit/validationtool/impl/ContentRepository.java @@ -33,7 +33,11 @@ import javax.xml.transform.stream.StreamSource; import javax.xml.validation.Schema; import javax.xml.validation.SchemaFactory; - +import net.sf.saxon.lib.UnparsedTextURIResolver; +import net.sf.saxon.s9api.Processor; +import net.sf.saxon.s9api.SaxonApiException; +import net.sf.saxon.s9api.XsltCompiler; +import net.sf.saxon.s9api.XsltExecutable; import org.apache.commons.lang3.StringUtils; import org.xml.sax.SAXException; @@ -50,13 +54,8 @@ import de.kosit.validationtool.model.scenarios.ScenarioType; import de.kosit.validationtool.model.scenarios.ValidateWithSchematron; -import net.sf.saxon.lib.UnparsedTextURIResolver; -import net.sf.saxon.s9api.Processor; -import net.sf.saxon.s9api.SaxonApiException; import net.sf.saxon.s9api.XPathCompiler; import net.sf.saxon.s9api.XPathExecutable; -import net.sf.saxon.s9api.XsltCompiler; -import net.sf.saxon.s9api.XsltExecutable; /** * Repository für verschiedene XML Artefakte zur Vearbeitung der Prüfszenarien. diff --git a/src/main/java/de/kosit/validationtool/impl/ConversionService.java b/src/main/java/de/kosit/validationtool/impl/ConversionService.java index 31e4ff7..d2ca2d2 100644 --- a/src/main/java/de/kosit/validationtool/impl/ConversionService.java +++ b/src/main/java/de/kosit/validationtool/impl/ConversionService.java @@ -24,14 +24,14 @@ import java.util.Collection; import java.util.StringJoiner; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBElement; -import javax.xml.bind.JAXBException; -import javax.xml.bind.JAXBIntrospector; -import javax.xml.bind.Marshaller; -import javax.xml.bind.Unmarshaller; -import javax.xml.bind.ValidationEventHandler; -import javax.xml.bind.annotation.XmlRegistry; +import jakarta.xml.bind.JAXBContext; +import jakarta.xml.bind.JAXBElement; +import jakarta.xml.bind.JAXBException; +import jakarta.xml.bind.JAXBIntrospector; +import jakarta.xml.bind.Marshaller; +import jakarta.xml.bind.Unmarshaller; +import jakarta.xml.bind.ValidationEventHandler; +import jakarta.xml.bind.annotation.XmlRegistry; import javax.xml.namespace.QName; import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLOutputFactory; diff --git a/src/main/java/de/kosit/validationtool/impl/DefaultCheck.java b/src/main/java/de/kosit/validationtool/impl/DefaultCheck.java index 66bff80..ef075c6 100644 --- a/src/main/java/de/kosit/validationtool/impl/DefaultCheck.java +++ b/src/main/java/de/kosit/validationtool/impl/DefaultCheck.java @@ -112,11 +112,11 @@ protected boolean isSuccessful(final Map results) { @Override public Result checkInput(final Input input) { - final CheckAction.Bag t = new CheckAction.Bag(input, createReport()); + final Bag t = new Bag(input, createReport()); return runCheckInternal(t); } - protected Result runCheckInternal(final CheckAction.Bag t) { + protected Result runCheckInternal(final Bag t) { final long started = System.currentTimeMillis(); log.info("Checking content of {}", t.getInput().getName()); for (final CheckAction action : this.checkSteps) { diff --git a/src/main/java/de/kosit/validationtool/impl/input/SourceInput.java b/src/main/java/de/kosit/validationtool/impl/input/SourceInput.java index 65cb32d..1eb5afc 100644 --- a/src/main/java/de/kosit/validationtool/impl/input/SourceInput.java +++ b/src/main/java/de/kosit/validationtool/impl/input/SourceInput.java @@ -21,7 +21,7 @@ import java.io.IOException; import java.nio.charset.Charset; -import javax.xml.bind.util.JAXBSource; +import jakarta.xml.bind.util.JAXBSource; import javax.xml.transform.Source; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamSource; @@ -42,7 +42,7 @@ * This class is known to work with: *
    *
  • {@link StreamSource} - both {@link java.io.InputStream} based and {@link java.io.Reader} based
  • - *
  • {@link javax.xml.transform.dom.DOMSource}
  • + *
  • {@link DOMSource}
  • *
  • {@link javax.xml.bind.util.JAXBSource}
  • *
  • {@link TreeInfo}
  • *
diff --git a/src/main/java/de/kosit/validationtool/impl/input/StreamHelper.java b/src/main/java/de/kosit/validationtool/impl/input/StreamHelper.java index 0a49c22..a65954d 100644 --- a/src/main/java/de/kosit/validationtool/impl/input/StreamHelper.java +++ b/src/main/java/de/kosit/validationtool/impl/input/StreamHelper.java @@ -97,7 +97,7 @@ private static class CountInputStream extends FilterInputStream { private final LazyReadInput reference; public CountInputStream(final LazyReadInput input, final InputStream stream) { - super(new org.apache.commons.io.input.CountingInputStream(stream)); + super(new CountingInputStream(stream)); this.reference = input; } diff --git a/src/main/java/de/kosit/validationtool/impl/tasks/CreateReportAction.java b/src/main/java/de/kosit/validationtool/impl/tasks/CreateReportAction.java index 554a47f..4a5d265 100644 --- a/src/main/java/de/kosit/validationtool/impl/tasks/CreateReportAction.java +++ b/src/main/java/de/kosit/validationtool/impl/tasks/CreateReportAction.java @@ -20,9 +20,9 @@ import java.util.Collection; import java.util.stream.Collectors; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Marshaller; -import javax.xml.bind.util.JAXBSource; +import jakarta.xml.bind.JAXBException; +import jakarta.xml.bind.Marshaller; +import jakarta.xml.bind.util.JAXBSource; import org.xml.sax.ContentHandler; import org.xml.sax.DTDHandler; diff --git a/src/main/java/de/kosit/validationtool/impl/tasks/SchematronValidationAction.java b/src/main/java/de/kosit/validationtool/impl/tasks/SchematronValidationAction.java index ae85023..5db7f67 100644 --- a/src/main/java/de/kosit/validationtool/impl/tasks/SchematronValidationAction.java +++ b/src/main/java/de/kosit/validationtool/impl/tasks/SchematronValidationAction.java @@ -64,7 +64,7 @@ private ValidationResultsSchematron validate(final Scenario scenario, final Bag // resolving nur relative zum Repository transformer.setURIResolver(scenario.getUriResolver()); final CollectingErrorEventHandler e = new CollectingErrorEventHandler(); - transformer.setMessageListener(e); + transformer.setErrorListener(e); final XdmDestination result = new XdmDestination(); transformer.setDestination(result); diff --git a/src/main/java/de/kosit/validationtool/impl/xml/StringTrimAdapter.java b/src/main/java/de/kosit/validationtool/impl/xml/StringTrimAdapter.java index f3c3c25..08ef4b1 100644 --- a/src/main/java/de/kosit/validationtool/impl/xml/StringTrimAdapter.java +++ b/src/main/java/de/kosit/validationtool/impl/xml/StringTrimAdapter.java @@ -16,7 +16,7 @@ package de.kosit.validationtool.impl.xml; -import javax.xml.bind.annotation.adapters.XmlAdapter; +import jakarta.xml.bind.annotation.adapters.XmlAdapter; public class StringTrimAdapter extends XmlAdapter { diff --git a/src/main/resources/app-info.properties b/src/main/resources/app-info.properties index d8e3ace..15bc6da 100644 --- a/src/main/resources/app-info.properties +++ b/src/main/resources/app-info.properties @@ -16,7 +16,5 @@ project_version=${project.version} framework_version=1.0.2 engine_name=KoSIT Validator -build_timestamp=${build.timestamp} build_number=${build.number} -build_revision=${build.revision} -build_branch=${build.branch} + diff --git a/src/test/java/de/kosit/validationtool/impl/tasks/CreateReportActionTest.java b/src/test/java/de/kosit/validationtool/impl/tasks/CreateReportActionTest.java index 17f6dfd..0e03375 100644 --- a/src/test/java/de/kosit/validationtool/impl/tasks/CreateReportActionTest.java +++ b/src/test/java/de/kosit/validationtool/impl/tasks/CreateReportActionTest.java @@ -65,6 +65,8 @@ public void testSimpleCreate() { bag.setReport(null); this.action.check(bag); assertThat(bag.getReport()).isNotNull(); + final String reportString = serialize(bag.getReport()); + System.out.println(reportString); } @Test @@ -77,7 +79,7 @@ public void testNoValidParseResult() { this.action.check(bag); assertThat(bag.getReport()).isNotNull(); final String reportString = serialize(bag.getReport()); - assertThat(reportString).contains("SAXParseException"); + assertThat(reportString).contains("IOException"); } @Test diff --git a/src/test/java/de/kosit/validationtool/impl/tasks/SchemaValidatorActionTest.java b/src/test/java/de/kosit/validationtool/impl/tasks/SchemaValidatorActionTest.java index d02d4d4..39fe3fc 100644 --- a/src/test/java/de/kosit/validationtool/impl/tasks/SchemaValidatorActionTest.java +++ b/src/test/java/de/kosit/validationtool/impl/tasks/SchemaValidatorActionTest.java @@ -67,7 +67,7 @@ public void setup() { @Test public void testSimple() throws MalformedURLException { - final CheckAction.Bag bag = createBag(InputFactory.read(Simple.SIMPLE_VALID.toURL())); + final Bag bag = createBag(InputFactory.read(Simple.SIMPLE_VALID.toURL())); this.service.check(bag); assertThat(bag.getSchemaValidationResult().isValid()).isTrue(); assertThat(bag.getSchemaValidationResult()).isNotNull(); @@ -77,7 +77,7 @@ public void testSimple() throws MalformedURLException { @Test public void testValidationFailure() throws MalformedURLException { final Input input = InputFactory.read(Simple.SCHEMA_INVALID.toURL()); - final CheckAction.Bag bag = createBag(input); + final Bag bag = createBag(input); this.service.check(bag); assertThat(bag.getSchemaValidationResult().isValid()).isFalse(); bag.getSchemaValidationResult().getErrors().forEach(e -> { @@ -153,7 +153,7 @@ public void testNoRepeatableReaderInputBigFile() throws Exception { @Test public void testProcessingError() throws IOException, SAXException { - final CheckAction.Bag bag = createBag(InputFactory.read(Simple.SIMPLE_VALID.toURL())); + final Bag bag = createBag(InputFactory.read(Simple.SIMPLE_VALID.toURL())); final Scenario scenario = bag.getScenarioSelectionResult().getObject(); final Schema schema = mock(Schema.class); final Validator validator = mock(Validator.class);