From dc7a552c80013fdf7701705890c70674271fd7da Mon Sep 17 00:00:00 2001 From: Fiete Ostkamp Date: Tue, 2 Jan 2024 13:02:39 +0100 Subject: [PATCH] Update spring boot to 2.2 - update spring dependency to 2.2.13 - remove profile based switch between spring versions 1.5.22 and 2.1.12 - migrate testng based tests in aai-els-onap-logging to junit 4 - rely more on boms for dependencyManagement by removing separate declarations (of spring and jackson) - resolve some build warnings by adding dependency + plugin versions - resolve some build warnings by removing duplicate declarations of dependencies - resolve build warning about ambiguous reference to JsonObject.addProperty() Issue-ID: AAI-3711 Change-Id: I7559e90ffb65199ee46bc5b7cdf5d9e73b7d87bc Signed-off-by: Fiete Ostkamp --- aai-core/pom.xml | 31 ++-- .../serialization/queryformats/StateFormat.java | 2 +- aai-els-onap-logging/pom.xml | 25 ++-- .../onap/logging/ref/slf4j/ONAPLogAdapterTest.java | 18 +-- .../logging/ref/slf4j/ONAPLogConstantsTest.java | 49 +++---- aai-parent/pom.xml | 163 ++++++--------------- aai-schema-abstraction/pom.xml | 1 + .../src/test/resources/edgerequests.json | 18 +-- .../src/test/resources/mockrequests.json | 18 +-- aai-utils/pom.xml | 4 - pom.xml | 2 +- version.properties | 2 +- 12 files changed, 121 insertions(+), 212 deletions(-) diff --git a/aai-core/pom.xml b/aai-core/pom.xml index 3b653924..79f8aade 100644 --- a/aai-core/pom.xml +++ b/aai-core/pom.xml @@ -256,22 +256,10 @@ limitations under the License. org.slf4j slf4j-api - - com.fasterxml.jackson.core - jackson-annotations - - - - com.fasterxml.jackson.dataformat - jackson-dataformat-yaml - xml-apis xml-apis - - - commons-cli - commons-cli + 1.4.01 com.beust @@ -280,7 +268,6 @@ limitations under the License. org.json json - com.bazaarvoice.jolt @@ -394,12 +381,16 @@ limitations under the License. com.fasterxml.jackson.core jackson-annotations - - org.apache.logging.log4j - log4j - ${log4j.version} - pom - + + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml + + + org.apache.logging.log4j + log4j + ${log4j.version} + pom + diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/StateFormat.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/StateFormat.java index 24405953..b010b19b 100644 --- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/StateFormat.java +++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/StateFormat.java @@ -104,7 +104,7 @@ public class StateFormat extends HistoryFormat { json.addProperty("uri", "NA"); } json.addProperty(TIMESTAMP, - e.property(AAIProperties.START_TS).isPresent() ? e.value(AAIProperties.START_TS) : 0); + e.property(AAIProperties.START_TS).isPresent() ? (String) e.value(AAIProperties.START_TS) : String.valueOf(0)); json.addProperty(SOT, e.property(AAIProperties.SOURCE_OF_TRUTH).isPresent() ? e.value(AAIProperties.SOURCE_OF_TRUTH) : ""); json.addProperty(TX_ID, diff --git a/aai-els-onap-logging/pom.xml b/aai-els-onap-logging/pom.xml index 38b3e05e..9ae986ff 100644 --- a/aai-els-onap-logging/pom.xml +++ b/aai-els-onap-logging/pom.xml @@ -140,17 +140,18 @@ spring-boot-starter-test test - - org.testng - testng - 6.8.5 - test - - - junit - junit - - - + + diff --git a/aai-els-onap-logging/src/test/java/org/onap/logging/ref/slf4j/ONAPLogAdapterTest.java b/aai-els-onap-logging/src/test/java/org/onap/logging/ref/slf4j/ONAPLogAdapterTest.java index f6ed9614..f0553603 100644 --- a/aai-els-onap-logging/src/test/java/org/onap/logging/ref/slf4j/ONAPLogAdapterTest.java +++ b/aai-els-onap-logging/src/test/java/org/onap/logging/ref/slf4j/ONAPLogAdapterTest.java @@ -36,14 +36,13 @@ import java.util.UUID; import javax.xml.bind.DatatypeConverter; +import org.junit.After; +import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.slf4j.MDC; import org.slf4j.event.Level; import org.springframework.mock.web.MockHttpServletRequest; -import org.testng.Assert; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.Test; /** * Tests for {@link ONAPLogAdapter}. @@ -53,7 +52,7 @@ public class ONAPLogAdapterTest { /** * Ensure that MDCs are cleared after each testcase. */ - @AfterMethod + @After public void resetMDCs() { MDC.clear(); } @@ -61,17 +60,10 @@ public class ONAPLogAdapterTest { /** * Test nullcheck. */ - @Test + @Test(expected = NullPointerException.class) public void testCheckNotNull() { - ONAPLogAdapter.checkNotNull(""); - - try { - ONAPLogAdapter.checkNotNull(null); - Assert.fail("Should throw NullPointerException"); - } catch (final NullPointerException e) { - - } + ONAPLogAdapter.checkNotNull(null); } /** diff --git a/aai-els-onap-logging/src/test/java/org/onap/logging/ref/slf4j/ONAPLogConstantsTest.java b/aai-els-onap-logging/src/test/java/org/onap/logging/ref/slf4j/ONAPLogConstantsTest.java index 6dc5e59c..dee07a4a 100644 --- a/aai-els-onap-logging/src/test/java/org/onap/logging/ref/slf4j/ONAPLogConstantsTest.java +++ b/aai-els-onap-logging/src/test/java/org/onap/logging/ref/slf4j/ONAPLogConstantsTest.java @@ -28,14 +28,18 @@ import static org.hamcrest.core.IsInstanceOf.instanceOf; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; -import org.testng.Assert; -import org.testng.annotations.Test; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; /** * Tests for {@link ONAPLogConstants}. */ public class ONAPLogConstantsTest { + @Rule + public ExpectedException exceptionRule = ExpectedException.none(); + @Test public void testConstructors() throws Exception { assertInaccessibleConstructor(ONAPLogConstants.class); @@ -46,14 +50,11 @@ public class ONAPLogConstantsTest { @Test public void testConstructorUnsupported() throws Exception { - try { - Constructor c = ONAPLogConstants.class.getDeclaredConstructors()[0]; - c.setAccessible(true); - c.newInstance(); - Assert.fail("Should fail for hidden constructor."); - } catch (final InvocationTargetException e) { - assertThat(e.getCause(), instanceOf(UnsupportedOperationException.class)); - } + exceptionRule.expect(InvocationTargetException.class); + exceptionRule.expectCause(instanceOf(UnsupportedOperationException.class)); + Constructor c = ONAPLogConstants.class.getDeclaredConstructors()[0]; + c.setAccessible(true); + c.newInstance(); } @Test @@ -108,21 +109,17 @@ public class ONAPLogConstantsTest { } - static void assertInaccessibleConstructor(final Class c) throws Exception { - try { - c.getDeclaredConstructors()[0].newInstance(); - Assert.fail("Should fail for hidden constructor."); - } catch (final IllegalAccessException e) { - - } - - try { - final Constructor constructor = c.getDeclaredConstructors()[0]; - constructor.setAccessible(true); - constructor.newInstance(); - Assert.fail("Should fail even when invoked."); - } catch (final InvocationTargetException e) { - assertThat(e.getCause(), instanceOf(UnsupportedOperationException.class)); - } + + void assertInaccessibleConstructor(final Class c) throws Exception { + exceptionRule.expect(IllegalAccessException.class); + // Should fail for hidden constructor. + c.getDeclaredConstructors()[0].newInstance(); + + + exceptionRule.expect(InvocationTargetException.class); + exceptionRule.expectCause(instanceOf(UnsupportedOperationException.class)); + final Constructor constructor = c.getDeclaredConstructors()[0]; + constructor.setAccessible(true); + constructor.newInstance(); } } diff --git a/aai-parent/pom.xml b/aai-parent/pom.xml index 0a496851..4c047895 100644 --- a/aai-parent/pom.xml +++ b/aai-parent/pom.xml @@ -91,7 +91,11 @@ limitations under the License. and would take some time to refactor Please don't upgrade to 2.3.0 or above for nexus iq or security scans as it could potentially break our code - --> + --> + 2.2.13.RELEASE + 5.2.12.RELEASE + 5.2.25.RELEASE + ${spring.version} 2.2.0 20190722 4.12 @@ -110,7 +114,6 @@ limitations under the License. 0.9.10 1.29 - 2.1.12.RELEASE 3.1.0 1.2 @@ -129,9 +132,6 @@ limitations under the License. 3.7.0.1746 - 5.1.13.RELEASE - 5.1.13.RELEASE - 5.1.13.RELEASE 1.0.8.RELEASE 1.1.1 2.0.4 @@ -139,23 +139,49 @@ limitations under the License. 1.5.1 - - - spring-boot-2-1 - - 2.1.12.RELEASE - - - - spring-boot-1-5 - - 1.5.22.RELEASE - - - - + + com.fasterxml.jackson + jackson-bom + ${jackson.bom.version} + pom + import + + + org.springframework.boot + spring-boot-dependencies + ${spring.boot.version} + pom + import + + + org.springframework + spring-framework-bom + ${spring.version} + pom + import + + + org.springframework.boot + spring-boot-starter-parent + ${spring.boot.version} + pom + import + + + + org.springframework.security + spring-security-rsa + ${spring.security.rsa.version} + + + org.springframework + spring-jms + ${spring.jms.version} + + + com.googlecode.json-simple @@ -199,49 +225,6 @@ limitations under the License. ${aai.release.version} - - com.fasterxml.jackson - jackson-bom - ${jackson.bom.version} - pom - import - - - - org.springframework.boot - spring-boot-starter-web - ${spring.boot.version} - - - - org.springframework.boot - spring-boot-starter-parent - ${spring.boot.version} - pom - import - - - - org.springframework.boot - spring-boot-dependencies - ${spring.boot.version} - pom - import - - - - org.springframework.boot - spring-boot-test - test - ${spring.boot.version} - - - - org.springframework - spring-test - ${spring.test.version} - - commons-configuration commons-configuration @@ -618,59 +601,7 @@ limitations under the License. ${commons.io.version} - - org.springframework - spring-web - ${spring.version} - - - org.springframework - spring-context - ${spring.version} - - - org.springframework - spring-core - ${spring.version} - - - org.springframework - spring-orm - ${spring.version} - - - org.springframework - spring-oxm - ${spring.version} - - - org.springframework - spring-aspects - ${spring.version} - - - org.springframework - spring-tx - ${spring.version} - - - org.springframework - spring-webmvc - ${spring.version} - - - - org.springframework.security - spring-security-rsa - ${spring.security.rsa.version} - - - - org.springframework - spring-jms - ${spring.jms.version} - - + org.onap.aai.logging-service common-logging diff --git a/aai-schema-abstraction/pom.xml b/aai-schema-abstraction/pom.xml index 8d332f17..44744754 100644 --- a/aai-schema-abstraction/pom.xml +++ b/aai-schema-abstraction/pom.xml @@ -119,6 +119,7 @@ org.sonatype.plugins nexus-staging-maven-plugin + 1.6.13 diff --git a/aai-schema-ingest/src/test/resources/edgerequests.json b/aai-schema-ingest/src/test/resources/edgerequests.json index 0878686f..28f5da79 100644 --- a/aai-schema-ingest/src/test/resources/edgerequests.json +++ b/aai-schema-ingest/src/test/resources/edgerequests.json @@ -4,47 +4,47 @@ { "aai-uri": "/versions", "response-file": "payload/versions.json", - "content": "application/json;charset=UTF-8" + "content": "application/json" }, { "aai-uri": "/edgerules?version=v8", "response-file": "edgeRules/test_v8.json", - "content": "application/json;charset=UTF-8" + "content": "application/json" }, { "aai-uri": "/edgerules?version=v9", "response-file": "edgeRules/test_v9.json", - "content": "application/json;charset=UTF-8" + "content": "application/json" }, { "aai-uri": "/edgerules?version=v10", "response-file": "edgeRules/test_v10.json", - "content": "application/json;charset=UTF-8" + "content": "application/json" }, { "aai-uri": "/edgerules?version=v11", "response-file": "edgeRules/test_v11.json", - "content": "application/json;charset=UTF-8" + "content": "application/json" }, { "aai-uri": "/edgerules?version=v12", "response-file": "edgeRules/test_v12.json", - "content": "application/json;charset=UTF-8" + "content": "application/json" }, { "aai-uri": "/edgerules?version=v13", "response-file": "edgeRules/test_v13.json", - "content": "application/json;charset=UTF-8" + "content": "application/json" }, { "aai-uri": "/edgerules?version=v14", "response-file": "edgeRules/test_v14.json", - "content": "application/json;charset=UTF-8" + "content": "application/json" }, { "aai-uri": "/edgerules?version=v15", "response-file": "edgeRules/test_v15.json", - "content": "application/json;charset=UTF-8" + "content": "application/json" } ] } diff --git a/aai-schema-ingest/src/test/resources/mockrequests.json b/aai-schema-ingest/src/test/resources/mockrequests.json index 7d669007..db7c6e66 100644 --- a/aai-schema-ingest/src/test/resources/mockrequests.json +++ b/aai-schema-ingest/src/test/resources/mockrequests.json @@ -4,47 +4,47 @@ { "aai-uri": "/versions", "response-file": "payload/versions.json", - "content": "application/json;charset=UTF-8" + "content": "application/json" }, { "aai-uri": "/nodes?version=v8", "response-file": "oxm/test_combined_network_business_v8.xml", - "content": "application/json;charset=UTF-8" + "content": "application/json" }, { "aai-uri": "/nodes?version=v9", "response-file": "oxm/test_combined_network_business_v9.xml", - "content": "application/json;charset=UTF-8" + "content": "application/json" }, { "aai-uri": "/nodes?version=v10", "response-file": "oxm/test_combined_network_business_v10.xml", - "content": "application/json;charset=UTF-8" + "content": "application/json" }, { "aai-uri": "/nodes?version=v11", "response-file": "oxm/test_combined_network_business_v11.xml", - "content": "application/json;charset=UTF-8" + "content": "application/json" }, { "aai-uri": "/nodes?version=v12", "response-file": "oxm/test_combined_network_business_v12.xml", - "content": "application/json;charset=UTF-8" + "content": "application/json" }, { "aai-uri": "/nodes?version=v13", "response-file": "oxm/test_combined_v13.xml", - "content": "application/json;charset=UTF-8" + "content": "application/json" }, { "aai-uri": "/nodes?version=v14", "response-file": "oxm/test_combined_network_business_v14.xml", - "content": "application/json;charset=UTF-8" + "content": "application/json" }, { "aai-uri": "/nodes?version=v15", "response-file": "oxm/test_combined_network_business_v15.xml", - "content": "application/json;charset=UTF-8" + "content": "application/json" } ] diff --git a/aai-utils/pom.xml b/aai-utils/pom.xml index 7126e147..2b605281 100644 --- a/aai-utils/pom.xml +++ b/aai-utils/pom.xml @@ -44,10 +44,6 @@ eelf-core 1.0.1-oss - - com.fasterxml.jackson.core - jackson-databind - org.apache.httpcomponents httpclient diff --git a/pom.xml b/pom.xml index 4f84bcf4..3e0d59ee 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ org.onap.aai.aai-common aai-common - 1.13.0-SNAPSHOT + 1.13.1-SNAPSHOT pom aai-aai-common Contains all of the common code for resources and traversal repos diff --git a/version.properties b/version.properties index 39cb3bf4..0c0fa8e9 100644 --- a/version.properties +++ b/version.properties @@ -5,7 +5,7 @@ major_version=1 minor_version=13 -patch_version=0 +patch_version=1 base_version=${major_version}.${minor_version}.${patch_version} -- 2.16.6