diff options
author | Lukasz Rajewski <lukasz.rajewski@t-mobile.pl> | 2024-01-10 13:13:39 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2024-01-10 13:13:39 +0000 |
commit | 09fd390a6f265419edcc8d1225a43b9a85dcd76a (patch) | |
tree | cd616ffcaa5ec79a19b057faff6858acde3fe8e9 /aai-els-onap-logging | |
parent | 60eea4e2fdf10204147a22e78a165ed087fddbef (diff) | |
parent | dc7a552c80013fdf7701705890c70674271fd7da (diff) |
Merge "Update spring boot to 2.2"
Diffstat (limited to 'aai-els-onap-logging')
3 files changed, 41 insertions, 51 deletions
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 @@ <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> - <dependency> - <groupId>org.testng</groupId> - <artifactId>testng</artifactId> - <version>6.8.5</version> - <scope>test</scope> - <exclusions> - <exclusion> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - </exclusion> - </exclusions> - </dependency> </dependencies> + + <!-- <build> + <plugins> + <plugin> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + </plugin> + </plugins> + </build> --> </project> 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(); } } |