diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ad6c9052374e4c653552efdcf216bd73d11e0aa3..44a4ebb8032ef61a6444c238cb03bf292ccce1ff 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -70,6 +70,14 @@ snapshot-gitlab: only: - main +snapshot-custom-gitlab: + stage: publish + script: + - mvn versions:set -DnewVersion=0.3.0-KOP-3139-SNAPSHOT $MAVEN_CLI_OPTS + - mvn deploy -Pgitlab-deploy $MAVEN_DEPLOY_CLI_OPTS $MAVEN_CLI_OPTS + only: + - KOP-3139-ozgcloud-Abhaengigkeit-entfernen + snapshot-nexus: stage: publish script: diff --git a/pom.xml b/pom.xml index a2bd7bb906b2a7569b8cac431354aaa708472f57..0abda8917c0598ed6cd25a77be0930a6e89e34df 100644 --- a/pom.xml +++ b/pom.xml @@ -1,23 +1,55 @@ <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>de.ozgcloud.common</groupId> - <artifactId>ozgcloud-common-parent</artifactId> - <version>4.3.0</version> - <relativePath/> - </parent> <groupId>de.ozgcloud.xta</groupId> <artifactId>xta-client-lib</artifactId> <version>0.3.0-SNAPSHOT</version> <properties> + <java.version>21</java.version> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> + + <!-- plugins --> + <maven-surefire-plugin.version>3.5.2</maven-surefire-plugin.version> + <maven-failsafe-plugin.version>3.5.2</maven-failsafe-plugin.version> + <maven-compiler-plugin.version>3.13.0</maven-compiler-plugin.version> + <maven-source-plugin.version>3.3.1</maven-source-plugin.version> + <maven-jar-plugin.version>3.4.2</maven-jar-plugin.version> + <jacoco.plugin.version>0.8.12</jacoco.plugin.version> + + <sonarqube.version>3.9.1.2184</sonarqube.version> + <license.plugin.version>4.6</license.plugin.version> + <rewrite.plugin.version>4.38.2</rewrite.plugin.version> + + <dependency-track-maven-plugin.version>1.7.0</dependency-track-maven-plugin.version> + <git-commit-id-maven-plugin.version>7.0.0</git-commit-id-maven-plugin.version> + <cyclonedx-maven-plugin.version>2.7.11</cyclonedx-maven-plugin.version> + + <!-- test --> + <httpclient5.version>5.4.1</httpclient5.version> + <mockito.version>5.14.2</mockito.version> + <assertj.version>3.26.3</assertj.version> + <snakeyaml.version>2.3</snakeyaml.version> + <junit-jupiter.version>5.11.4</junit-jupiter.version> + <testcontainers.version>1.20.6</testcontainers.version> + <!-- build versions --> - <cxf.version>4.0.5</cxf.version> - <cxf-xjc.version>4.0.0</cxf-xjc.version> + <mapstruct.version>1.6.3</mapstruct.version> + <log4j2.version>2.24.3</log4j2.version> + <lombok.version>1.18.36</lombok.version> + + <cxf.version>4.0.7</cxf.version> + <cxf-xjc.version>4.0.2</cxf-xjc.version> <jsr305.version>3.0.2</jsr305.version> + <bouncycastle.version>1.80</bouncycastle.version> + <commons-io.version>2.19.0</commons-io.version> + <commons-lang3.version>3.17.0</commons-lang3.version> + <jakarta-validation.version>3.0.2</jakarta-validation.version> + <hibernate-validator.version>8.0.2.Final</hibernate-validator.version> + <expressly.version>5.0.0</expressly.version> <!-- Build settings --> <timestamp>${maven.build.timestamp}</timestamp> @@ -27,13 +59,34 @@ <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> </properties> + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-bom</artifactId> + <version>${log4j2.version}</version> + <scope>import</scope> + <type>pom</type> + </dependency> + <dependency> + <groupId>org.junit</groupId> + <artifactId>junit-bom</artifactId> + <version>${junit-jupiter.version}</version> + <scope>import</scope> + <type>pom</type> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-bom</artifactId> + <version>${cxf.version}</version> + <scope>import</scope> + <type>pom</type> + </dependency> + </dependencies> + </dependencyManagement> + <dependencies> <!-- CXF--> - <dependency> - <groupId>org.apache.cxf</groupId> - <artifactId>cxf-spring-boot-starter-jaxws</artifactId> - <version>${cxf.version}</version> - </dependency> <dependency> <groupId>org.apache.cxf.xjcplugins</groupId> <artifactId>cxf-xjc-ts</artifactId> @@ -54,19 +107,34 @@ <artifactId>cxf-xjc-runtime</artifactId> <version>${cxf-xjc.version}</version> </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-frontend-jaxws</artifactId> + </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-features-logging</artifactId> - <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-ws-security</artifactId> - <version>${cxf.version}</version> + </dependency> + + <!-- Other apache --> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-lang3</artifactId> + <version>${commons-lang3.version}</version> + </dependency> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <version>${commons-io.version}</version> </dependency> <dependency> <groupId>org.apache.httpcomponents.client5</groupId> <artifactId>httpclient5</artifactId> + <version>${httpclient5.version}</version> </dependency> <dependency> <groupId>org.apache.cxf.services.xkms</groupId> @@ -79,6 +147,23 @@ <version>${cxf.version}</version> </dependency> + <!-- Validation https://docs.jboss.org/hibernate/stable/validator/reference/en-US/html_single/ --> + <dependency> + <groupId>jakarta.validation</groupId> + <artifactId>jakarta.validation-api</artifactId> + <version>${jakarta-validation.version}</version> + </dependency> + <dependency> + <groupId>org.hibernate</groupId> + <artifactId>hibernate-validator</artifactId> + <version>${hibernate-validator.version}</version> + </dependency> + <dependency> + <groupId>org.glassfish.expressly</groupId> + <artifactId>expressly</artifactId> + <version>${expressly.version}</version> + </dependency> + <dependency> <groupId>com.google.code.findbugs</groupId> <artifactId>jsr305</artifactId> @@ -88,11 +173,13 @@ <dependency> <groupId>org.mapstruct</groupId> <artifactId>mapstruct</artifactId> + <version>${mapstruct.version}</version> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> + <version>${lombok.version}</version> <scope>provided</scope> </dependency> @@ -100,25 +187,38 @@ <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-core</artifactId> </dependency> - - <!-- Test --> <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-collections4</artifactId> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-api</artifactId> </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-slf4j2-impl</artifactId> + <scope>runtime</scope> + </dependency> + + <!-- Test --> <dependency> <groupId>org.assertj</groupId> <artifactId>assertj-core</artifactId> + <version>${assertj.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>org.bouncycastle</groupId> <artifactId>bcprov-jdk18on</artifactId> + <version>${bouncycastle.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>org.bouncycastle</groupId> <artifactId>bcpkix-jdk18on</artifactId> + <version>${bouncycastle.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-params</artifactId> <scope>test</scope> </dependency> <dependency> @@ -129,25 +229,138 @@ <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-core</artifactId> + <version>${mockito.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-junit-jupiter</artifactId> + <version>${mockito.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>org.yaml</groupId> <artifactId>snakeyaml</artifactId> + <version>${snakeyaml.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.testcontainers</groupId> + <artifactId>testcontainers</artifactId> + <version>${testcontainers.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.testcontainers</groupId> + <artifactId>junit-jupiter</artifactId> + <version>${testcontainers.version}</version> <scope>test</scope> </dependency> </dependencies> <build> <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <version>${maven-jar-plugin.version}</version> + </plugin> + + <plugin> + <groupId>org.sonarsource.scanner.maven</groupId> + <artifactId>sonar-maven-plugin</artifactId> + <version>${sonarqube.version}</version> + </plugin> + + + <plugin> + <groupId>io.github.git-commit-id</groupId> + <artifactId>git-commit-id-maven-plugin</artifactId> + <version>${git-commit-id-maven-plugin.version}</version> + <configuration> + <offline>true</offline> + </configuration> + <executions> + <execution> + <id>get-the-git-infos</id> + <goals> + <goal>revision</goal> + </goals> + <phase>initialize</phase> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.jacoco</groupId> + <artifactId>jacoco-maven-plugin</artifactId> + <version>${jacoco.plugin.version}</version> + <executions> + <execution> + <id>start-agent</id> + <goals> + <goal>prepare-agent</goal> + </goals> + <configuration> + <propertyName>surefire.jacoco.args</propertyName> + </configuration> + </execution> + <execution> + <id>generate-report</id> + <phase>package</phase> + <goals> + <goal>report</goal> + </goals> + </execution> + </executions> + </plugin> + + <plugin> + <groupId>org.openrewrite.maven</groupId> + <artifactId>rewrite-maven-plugin</artifactId> + <version>${rewrite.plugin.version}</version> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-source-plugin</artifactId> + <version>${maven-source-plugin.version}</version> + <executions> + <execution> + <id>attach-sources</id> + <goals> + <goal>jar-no-fork</goal> + </goals> + </execution> + </executions> + </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> + <version>${maven-compiler-plugin.version}</version> + <configuration> + <parameters>true</parameters> + <source>${java.version}</source> + <target>${java.version}</target> + <fork>true</fork> + <annotationProcessorPaths> + <path> + <groupId>org.projectlombok</groupId> + <artifactId>lombok</artifactId> + <version>${lombok.version}</version> + </path> + <path> + <groupId>org.mapstruct</groupId> + <artifactId>mapstruct-processor</artifactId> + <version>${mapstruct.version}</version> + </path> + </annotationProcessorPaths> + <showWarnings>true</showWarnings> + <compilerArgs> + <compilerArg> + -Amapstruct.unmappedTargetPolicy=WARN + </compilerArg> + </compilerArgs> + </configuration> <executions> <execution> <id>log4j2-plugin-processor</id> @@ -165,15 +378,26 @@ </path> </annotationProcessorPaths> <annotationProcessors> - <processor>org.apache.logging.log4j.core.config.plugins.processor.PluginProcessor</processor> + <processor> + org.apache.logging.log4j.core.config.plugins.processor.PluginProcessor + </processor> </annotationProcessors> </configuration> </execution> </executions> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>${maven-surefire-plugin.version}</version> + </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-failsafe-plugin</artifactId> + <version>${maven-failsafe-plugin.version}</version> + <configuration> + <classesDirectory>${project.build.outputDirectory}</classesDirectory> + </configuration> <executions> <execution> <goals> @@ -183,14 +407,6 @@ </execution> </executions> </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-surefire-plugin</artifactId> - </plugin> - <plugin> - <groupId>org.jacoco</groupId> - <artifactId>jacoco-maven-plugin</artifactId> - </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> diff --git a/src/test/java/de/ozgcloud/xta/client/XtaTestServerContainer.java b/src/test/java/de/ozgcloud/xta/client/XtaTestServerContainer.java index 5642170c9da97c68b2ebd86f9374cefe2992d012..c68e60ebe1a89e3f792e9e7bef5eae4402d5edd8 100644 --- a/src/test/java/de/ozgcloud/xta/client/XtaTestServerContainer.java +++ b/src/test/java/de/ozgcloud/xta/client/XtaTestServerContainer.java @@ -7,8 +7,8 @@ import org.testcontainers.utility.DockerImageName; public class XtaTestServerContainer extends GenericContainer<XtaTestServerContainer> { - private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse("docker.ozg-sh.de/xta-test-server"); - private static final String DEFAULT_TAG = "latest"; + private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse("code.schleswig-holstein.de:5050/ozg-cloud/lib/xta-test-server"); + private static final String DEFAULT_TAG = "1.9.0"; public static final int PORT = 8443; public XtaTestServerContainer() { diff --git a/src/test/java/de/ozgcloud/xta/client/extension/XtaMessageExampleLoader.java b/src/test/java/de/ozgcloud/xta/client/extension/XtaMessageExampleLoader.java index 740edbdac1a200372d4acb7dad963d9529b29b56..aa61f23b976c90a942542ab519d7f22479753699 100644 --- a/src/test/java/de/ozgcloud/xta/client/extension/XtaMessageExampleLoader.java +++ b/src/test/java/de/ozgcloud/xta/client/extension/XtaMessageExampleLoader.java @@ -22,7 +22,6 @@ import jakarta.mail.util.ByteArrayDataSource; import jakarta.validation.constraints.NotBlank; import org.apache.commons.codec.Resources; -import org.apache.commons.collections4.MapUtils; import org.apache.commons.io.IOUtils; import org.yaml.snakeyaml.Yaml; @@ -104,17 +103,12 @@ public class XtaMessageExampleLoader { @Nullable XtaIdentifier reader) { } - @SuppressWarnings("unchecked") - private static Map<String, Object> getChild(Map<String, Object> parent, String key) { - return Objects.requireNonNull((Map<String, Object>) MapUtils.getMap(parent, key), "Missing key: %s".formatted(key)); - } - private static XtaFile mapXtaFile( Map<String, Object> messageFile, String resourcePrefix, MessageFileProcessor messageFileProcessor) { Function<String, String> getString = key -> Objects.requireNonNull( - MapUtils.getString(messageFile, key), "[Failed mapping for %s] Missing key: %s".formatted(resourcePrefix, key)); + getChildString(messageFile, key), "[Failed mapping for %s] Missing key: %s".formatted(resourcePrefix, key)); var name = getString.apply("name"); var path = getMessageResourcePath(resourcePrefix, name); @@ -126,7 +120,7 @@ public class XtaMessageExampleLoader { .name(name) .contentType(getString.apply("contentType")) .content(createContentDataHandler(data)) - .id(MapUtils.getString(messageFile, "id")) + .id(getChildString(messageFile, "id")) .build(); } @@ -138,7 +132,7 @@ public class XtaMessageExampleLoader { private static XtaMessageMetaData mapXtaMessageMetadata(Map<String, Object> metaData, MessageExampleConfig config) { Function<String, String> getString = key -> Objects.requireNonNull( - MapUtils.getString(metaData, key), "metaData key missing: %s".formatted(key)); + getChildString(metaData, key), "metaData key missing: %s".formatted(key)); return XtaMessageMetaData.builder() .service(getString.apply("service")) .businessScenarioCode(getString.apply("businessScenarioCode")) @@ -147,7 +141,7 @@ public class XtaMessageExampleLoader { .messageTypeCode(getString.apply("messageTypeCode")) .messageTypePayloadSchema(getString.apply("messageTypePayloadSchema")) .messageId(getIfConfigNull( - config.messageId, () -> MapUtils.getString(metaData, "messageId"))) + config.messageId, () -> getChildString(metaData, "messageId"))) .authorIdentifier(getIfConfigNull( config.author, () -> mapIdentifier(getChild(metaData, "authorIdentifier")))) @@ -157,6 +151,17 @@ public class XtaMessageExampleLoader { .build(); } + @SuppressWarnings("unchecked") + private static Map<String, Object> getChild(Map<String, Object> parent, String key) { + return Objects.requireNonNull((Map<String, Object>) parent.get(key), "Missing key: %s".formatted(key)); + } + + private static String getChildString(Map<String, Object> parent, String key) { + return Optional.ofNullable(parent.get(key)) + .map(Object::toString) + .orElse(null); + } + private static <T> T getIfConfigNull(T configValue, Supplier<T> supplier) { return configValue != null ? configValue : supplier.get(); } diff --git a/src/test/java/de/ozgcloud/xta/client/extension/XtaTestServerSetupExtension.java b/src/test/java/de/ozgcloud/xta/client/extension/XtaTestServerSetupExtension.java index 6a5f489728be403a341252720d84e921ddc415fe..f5feb6bf3005e443b3d0f3c2be5abad64300f21f 100644 --- a/src/test/java/de/ozgcloud/xta/client/extension/XtaTestServerSetupExtension.java +++ b/src/test/java/de/ozgcloud/xta/client/extension/XtaTestServerSetupExtension.java @@ -23,9 +23,6 @@ import lombok.extern.slf4j.Slf4j; @Slf4j public class XtaTestServerSetupExtension implements BeforeAllCallback, AfterAllCallback { - private static final DockerImageName XTA_TEST_SERVER_IMAGE = DockerImageName.parse("docker.ozg-sh.de/xta-test-server") - .withTag("1.9.0"); - private static final String XTA_TEST_CLIENT_KEYSTORE_PATH = "store/xta-test-client-john-smith_keystore.p12"; private static final String XTA_TEST_CLIENT_KEYSTORE_PASSWORD = "password"; @@ -69,7 +66,7 @@ public class XtaTestServerSetupExtension implements BeforeAllCallback, AfterAllC } private void setupServer() { - xtaServerContainer = new XtaTestServerContainer(XTA_TEST_SERVER_IMAGE) + xtaServerContainer = new XtaTestServerContainer() .withLogConsumer(outputFrame -> log.info(outputFrame.getUtf8String().strip())); xtaServerContainer.start();