diff options
author | 2024-01-02 13:02:39 +0100 | |
---|---|---|
committer | 2024-01-10 11:37:13 +0100 | |
commit | dc7a552c80013fdf7701705890c70674271fd7da (patch) | |
tree | d499b12d0b8311a734096bdbf01a12cb86a0208b /aai-els-onap-logging/src/test/java/org/onap/logging/ref/slf4j/ONAPLogConstantsTest.java | |
parent | d21a7599963ae8e094eecd62cb80ed1d83d6d767 (diff) |
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 <Fiete.Ostkamp@telekom.de>
Diffstat (limited to 'aai-els-onap-logging/src/test/java/org/onap/logging/ref/slf4j/ONAPLogConstantsTest.java')
-rw-r--r-- | aai-els-onap-logging/src/test/java/org/onap/logging/ref/slf4j/ONAPLogConstantsTest.java | 49 |
1 files changed, 23 insertions, 26 deletions
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(); } } |