From 1e5f871d51e9f9d9e2c2981df5bd7cc592acc0e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?James=20Pether=20S=C3=B6rling?= Date: Thu, 23 Jan 2025 00:06:51 +0100 Subject: [PATCH] Add unit test suite and update Java test configuration (#7075) * feat(tests): add unit test suite for CIA application utilities * chore: update Java test configuration and dependencies in POM files --- .vscode/settings.json | 53 ++++++++++++++----- .../src/main/java/module-info.java | 2 +- .../suites/UnitTestSuite.java | 21 ++++++++ parent-pom/pom.xml | 8 +-- service.data.impl/pom.xml | 25 +++++---- 5 files changed, 79 insertions(+), 30 deletions(-) create mode 100644 citizen-intelligence-agency/src/test/java/com/hack23/cia/systemintegrationtest/suites/UnitTestSuite.java diff --git a/.vscode/settings.json b/.vscode/settings.json index bfd3c3a985..855d0788d1 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,25 +1,42 @@ { - "java.compile.nullAnalysis.mode": "automatic", - "java.configuration.updateBuildConfiguration": "automatic", - "java.dependency.packagePresentation": "hierarchical", - "maven.workspace.autoReload": true, - "maven.workspace.resolveFolders": true, - "java.jdt.ls.vmargs": "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 --add-modules=ALL-SYSTEM --add-exports=java.base/sun.nio.ch=ALL-UNNAMED --add-exports=java.base/jdk.internal.ref=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED", "java.test.config": { "vmargs": [ - "--add-modules=ALL-SYSTEM", - "--add-exports=java.base/sun.nio.ch=ALL-UNNAMED", - "--add-exports=java.base/jdk.internal.ref=ALL-UNNAMED", + "-Xmx2048M", + "--add-modules", + "ALL-SYSTEM", + "--add-modules", + "java.xml.bind", "--add-opens=java.base/java.lang=ALL-UNNAMED", + "--add-opens=java.base/java.util=ALL-UNNAMED", "--add-opens=java.base/java.lang.reflect=ALL-UNNAMED", - "--add-opens=java.base/java.util=ALL-UNNAMED" + "--add-exports=java.base/sun.nio.ch=ALL-UNNAMED", + "--add-exports=java.base/jdk.internal.ref=ALL-UNNAMED", + "--add-exports=java.xml/com.sun.org.apache.xerces.internal.dom=ALL-UNNAMED", + "--add-exports=java.xml.bind/javax.xml.bind=ALL-UNNAMED" + ], + "name": "CIA Tests", + "showTestResults": true, + "excludes": [ + "**/module-info.java" ] }, - "java.test.defaultConfig": "default", + "java.test.defaultConfig": "CIA Tests", + "java.project.sourcePaths": [ + "src/main/java" + ], + "java.project.testSourcePaths": [ + "src/test/java" + ], + "java.compile.nullAnalysis.mode": "automatic", + "java.configuration.updateBuildConfiguration": "automatic", + "java.dependency.packagePresentation": "hierarchical", + "maven.workspace.autoReload": true, + "maven.workspace.resolveFolders": true, + "java.jdt.ls.vmargs": "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 --add-modules=ALL-SYSTEM --add-exports=java.base/sun.nio.ch=ALL-UNNAMED --add-exports=java.base/jdk.internal.ref=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED", "maven.terminal.customEnv": [ { "environmentVariable": "MAVEN_OPTS", - "value": "-Xmx8192m -Xms2048m -XX:+UseG1GC" + "value": "-Xmx8192m -Xms2048m -XX:+UseG1GC --add-modules=ALL-MODULE-PATH" } ], "coverage-gutters.showGutterCoverage": true, @@ -30,5 +47,15 @@ "sonarlint.connectedMode.project": { "connectionId": "hack23", "projectKey": "Hack23_cia" - } + }, + "java.debug.settings.onBuildFailureProceed": true, + "java.test.editor.enableShortcuts": true, + "java.test.message.showFullStackTrace": true, + "java.test.message.displayNameFormat": "${className} - ${methodName}", + "maven.dependency.enableConflictDiagnostics": true, + "java.import.exclusions": [ + "**/node_modules/**", + "**/.metadata/**" + ], + "maven.pomfile.autoUpdateEffectivePOM": true } \ No newline at end of file diff --git a/citizen-intelligence-agency/src/main/java/module-info.java b/citizen-intelligence-agency/src/main/java/module-info.java index 1a2649e40c..aa7d6d8cdb 100644 --- a/citizen-intelligence-agency/src/main/java/module-info.java +++ b/citizen-intelligence-agency/src/main/java/module-info.java @@ -217,6 +217,6 @@ requires transitive com.hack23.cia.model.external.val.landstingvalkrets.impl; requires transitive com.hack23.cia.model.external.riksdagen.votering.impl; requires transitive com.hack23.cia.model.external.worldbank.countries.impl; - requires org.apache.commons.beanutils; + requires commons.beanutils; requires static org.eclipse.jetty.jmx; } diff --git a/citizen-intelligence-agency/src/test/java/com/hack23/cia/systemintegrationtest/suites/UnitTestSuite.java b/citizen-intelligence-agency/src/test/java/com/hack23/cia/systemintegrationtest/suites/UnitTestSuite.java new file mode 100644 index 0000000000..74279994c5 --- /dev/null +++ b/citizen-intelligence-agency/src/test/java/com/hack23/cia/systemintegrationtest/suites/UnitTestSuite.java @@ -0,0 +1,21 @@ +package com.hack23.cia.systemintegrationtest.suites; + +import org.junit.jupiter.api.DisplayName; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +import com.hack23.cia.web.impl.ui.application.util.UserContextUtilTest; +import com.hack23.cia.web.impl.ui.application.util.WebBrowserUtilTest; + +/** + * The Class IntegrationTestSuite. + */ +@RunWith(Suite.class) +@DisplayName("CIA Unit Tests") +@Suite.SuiteClasses({ + UserContextUtilTest.class, + WebBrowserUtilTest.class +}) +public class UnitTestSuite { + +} diff --git a/parent-pom/pom.xml b/parent-pom/pom.xml index 44326e6642..ccf4d7ffb7 100644 --- a/parent-pom/pom.xml +++ b/parent-pom/pom.xml @@ -164,7 +164,8 @@ 21 21 21 - -XX:+EnableDynamicAgentLoading --add-exports java.base/sun.nio.ch=ALL-UNNAMED + -XX:+EnableDynamicAgentLoading --add-exports + java.base/sun.nio.ch=ALL-UNNAMED --add-exports java.base/jdk.internal.ref=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED @@ -336,7 +337,7 @@ commons-beanutils commons-beanutils - 1.10.0 + 1.9.0 org.jvnet.jaxb2_commons @@ -1439,7 +1440,8 @@ 21 - -XX:+EnableDynamicAgentLoading --add-exports java.base/sun.nio.ch=ALL-UNNAMED + -XX:+EnableDynamicAgentLoading --add-exports + java.base/sun.nio.ch=ALL-UNNAMED --add-exports java.base/jdk.internal.ref=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED diff --git a/service.data.impl/pom.xml b/service.data.impl/pom.xml index 06e71d9bd3..848cfe1e6c 100644 --- a/service.data.impl/pom.xml +++ b/service.data.impl/pom.xml @@ -34,6 +34,18 @@ ${project.basedir}/target/classes/ + + + + com.amazonaws + aws-java-sdk-bom + ${cia.project.versions.aws} + + pom + import + + + jakarta.activation @@ -61,10 +73,6 @@ com.fasterxml.jackson.dataformat jackson-dataformat-cbor - - software.amazon.ion - ion-java - @@ -92,17 +100,8 @@ com.fasterxml.jackson.dataformat jackson-dataformat-cbor - - software.amazon.ion - ion-java - - - software.amazon.ion - ion-java - 1.5.1 - com.fasterxml.jackson.core jackson-databind