You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ma...@apache.org on 2020/09/19 20:04:46 UTC

[logging-log4j2] branch master updated: Revert "Migrate more tests to JUnit 5"

This is an automated email from the ASF dual-hosted git repository.

mattsicker pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git


The following commit(s) were added to refs/heads/master by this push:
     new bf16de8  Revert "Migrate more tests to JUnit 5"
bf16de8 is described below

commit bf16de8cde9eb1da0554e670f1864708a7822c8c
Author: Matt Sicker <bo...@gmail.com>
AuthorDate: Sat Sep 19 15:04:30 2020 -0500

    Revert "Migrate more tests to JUnit 5"
    
    This reverts commit 16838a7155384fc253f4a22ef80989d70e36ffa5.
---
 .../appender/db/AbstractDatabaseAppenderTest.java  |  38 +--
 .../appender/db/AbstractDatabaseManagerTest.java   |  26 +-
 .../core/appender/nosql/NoSqlAppenderTest.java     |  24 +-
 .../appender/nosql/NoSqlDatabaseManagerTest.java   | 293 +++++++++++----------
 .../RandomRollingAppenderOnStartupTest.java        |  58 ++--
 5 files changed, 245 insertions(+), 194 deletions(-)

diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/AbstractDatabaseAppenderTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/AbstractDatabaseAppenderTest.java
index ea84899..6b5d7ef 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/AbstractDatabaseAppenderTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/AbstractDatabaseAppenderTest.java
@@ -16,18 +16,9 @@
  */
 package org.apache.logging.log4j.core.appender.db;
 
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.Property;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.mockito.Mock;
-import org.mockito.junit.jupiter.MockitoExtension;
-
-import java.io.Serializable;
-import java.util.concurrent.TimeUnit;
-
-import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
 import static org.mockito.ArgumentMatchers.isNull;
 import static org.mockito.ArgumentMatchers.same;
 import static org.mockito.BDDMockito.given;
@@ -35,7 +26,18 @@ import static org.mockito.BDDMockito.then;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.reset;
 
-@ExtendWith(MockitoExtension.class)
+import java.io.Serializable;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.logging.log4j.core.Filter;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.config.Property;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+
+@RunWith(MockitoJUnitRunner.class)
 public class AbstractDatabaseAppenderTest {
     private static class LocalAbstractDatabaseAppender extends AbstractDatabaseAppender<LocalAbstractDatabaseManager> {
 
@@ -82,16 +84,16 @@ public class AbstractDatabaseAppenderTest {
     public void testNameAndGetLayout01() {
         setUp("testName01");
 
-        assertEquals("testName01", appender.getName(), "The name is not correct.");
-        assertNull(appender.getLayout(), "The layout should always be null.");
+        assertEquals("The name is not correct.", "testName01", appender.getName());
+        assertNull("The layout should always be null.", appender.getLayout());
     }
 
     @Test
     public void testNameAndGetLayout02() {
         setUp("anotherName02");
 
-        assertEquals("anotherName02", appender.getName(), "The name is not correct.");
-        assertNull(appender.getLayout(), "The layout should always be null.");
+        assertEquals("The name is not correct.", "anotherName02", appender.getName());
+        assertNull("The layout should always be null.", appender.getLayout());
     }
 
     @Test
@@ -99,7 +101,7 @@ public class AbstractDatabaseAppenderTest {
         setUp("name");
 
         final LocalAbstractDatabaseManager oldManager = appender.getManager();
-        assertSame(manager, oldManager, "The manager should be the same.");
+        assertSame("The manager should be the same.", manager, oldManager);
 
         final LocalAbstractDatabaseManager newManager = mock(LocalAbstractDatabaseManager.class);
         appender.replaceManager(newManager);
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/AbstractDatabaseManagerTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/AbstractDatabaseManagerTest.java
index f3005ef..dfb498e 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/AbstractDatabaseManagerTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/AbstractDatabaseManagerTest.java
@@ -16,7 +16,9 @@
  */
 package org.apache.logging.log4j.core.appender.db;
 
-import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 import static org.mockito.ArgumentMatchers.isNull;
 import static org.mockito.ArgumentMatchers.same;
 import static org.mockito.BDDMockito.then;
@@ -30,7 +32,7 @@ import static org.mockito.Mockito.when;
 import java.io.Serializable;
 
 import org.apache.logging.log4j.core.LogEvent;
-import org.junit.jupiter.api.Test;
+import org.junit.Test;
 
 public class AbstractDatabaseManagerTest {
     // this stub is provided because mocking constructors is hard
@@ -231,45 +233,45 @@ public class AbstractDatabaseManagerTest {
     public void testStartupShutdown01() throws Exception {
         setUp("testName01", 0);
 
-        assertEquals("testName01", manager.getName(), "The name is not correct.");
-        assertFalse(manager.isRunning(), "The manager should not have started.");
+        assertEquals("The name is not correct.", "testName01", manager.getName());
+        assertFalse("The manager should not have started.", manager.isRunning());
 
         manager.startup();
         then(manager).should().startupInternal();
-        assertTrue(manager.isRunning(), "The manager should be running now.");
+        assertTrue("The manager should be running now.", manager.isRunning());
 
         manager.shutdown();
         then(manager).should().shutdownInternal();
-        assertFalse(manager.isRunning(), "The manager should not be running anymore.");
+        assertFalse("The manager should not be running anymore.", manager.isRunning());
     }
 
     @Test
     public void testStartupShutdown02() throws Exception {
         setUp("anotherName02", 0);
 
-        assertEquals("anotherName02", manager.getName(), "The name is not correct.");
-        assertFalse(manager.isRunning(), "The manager should not have started.");
+        assertEquals("The name is not correct.", "anotherName02", manager.getName());
+        assertFalse("The manager should not have started.", manager.isRunning());
 
         manager.startup();
         then(manager).should().startupInternal();
-        assertTrue(manager.isRunning(), "The manager should be running now.");
+        assertTrue("The manager should be running now.", manager.isRunning());
 
         manager.releaseSub(-1, null);
         then(manager).should().shutdownInternal();
-        assertFalse(manager.isRunning(), "The manager should not be running anymore.");
+        assertFalse("The manager should not be running anymore.", manager.isRunning());
     }
 
     @Test
     public void testToString01() {
         setUp("someName01", 0);
 
-        assertEquals("someName01", manager.toString(), "The string is not correct.");
+        assertEquals("The string is not correct.", "someName01", manager.toString());
     }
 
     @Test
     public void testToString02() {
         setUp("bufferSize=12, anotherKey02=coolValue02", 12);
 
-        assertEquals("bufferSize=12, anotherKey02=coolValue02", manager.toString(), "The string is not correct.");
+        assertEquals("The string is not correct.", "bufferSize=12, anotherKey02=coolValue02", manager.toString());
     }
 }
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/nosql/NoSqlAppenderTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/nosql/NoSqlAppenderTest.java
index fd3e4b9..24e01ac 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/nosql/NoSqlAppenderTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/nosql/NoSqlAppenderTest.java
@@ -16,14 +16,14 @@
  */
 package org.apache.logging.log4j.core.appender.nosql;
 
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.Test;
+import org.junit.runner.RunWith;
 import org.mockito.Mock;
-import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.runners.MockitoJUnitRunner;
 
-import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.Assert.*;
 
-@ExtendWith(MockitoExtension.class)
+@RunWith(MockitoJUnitRunner.class)
 public class NoSqlAppenderTest {
 
     @Mock
@@ -33,17 +33,17 @@ public class NoSqlAppenderTest {
     public void testNoProvider() {
         final NoSqlAppender appender = NoSqlAppender.newBuilder().setName("myName01").build();
 
-        assertNull(appender, "The appender should be null.");
+        assertNull("The appender should be null.", appender);
     }
 
     @Test
     public void testProvider() {
         final NoSqlAppender appender = NoSqlAppender.newBuilder().setName("myName01").setProvider(provider).build();
 
-        assertNotNull(appender, "The appender should not be null.");
-        assertEquals(
+        assertNotNull("The appender should not be null.", appender);
+        assertEquals("The toString value is not correct.",
                 "myName01{ manager=noSqlManager{ description=myName01, bufferSize=0, provider=" + provider + " } }",
-                appender.toString(), "The toString value is not correct.");
+                appender.toString());
 
         appender.stop();
     }
@@ -53,11 +53,11 @@ public class NoSqlAppenderTest {
         final NoSqlAppender appender = NoSqlAppender.newBuilder().setName("anotherName02").setProvider(provider)
                 .setBufferSize(25).build();
 
-        assertNotNull(appender, "The appender should not be null.");
-        assertEquals(
+        assertNotNull("The appender should not be null.", appender);
+        assertEquals("The toString value is not correct.",
                 "anotherName02{ manager=noSqlManager{ description=anotherName02, bufferSize=25, provider=" + provider
                         + " } }",
-                appender.toString(), "The toString value is not correct.");
+                appender.toString());
 
         appender.stop();
     }
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/nosql/NoSqlDatabaseManagerTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/nosql/NoSqlDatabaseManagerTest.java
index 84e969c..63ae624 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/nosql/NoSqlDatabaseManagerTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/nosql/NoSqlDatabaseManagerTest.java
@@ -16,6 +16,22 @@
  */
 package org.apache.logging.log4j.core.appender.nosql;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.BDDMockito.given;
+import static org.mockito.BDDMockito.then;
+import static org.mockito.Mockito.mock;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 import org.apache.logging.log4j.Level;
 import org.apache.logging.log4j.MarkerManager;
 import org.apache.logging.log4j.ThreadContext;
@@ -23,31 +39,21 @@ import org.apache.logging.log4j.core.LogEvent;
 import org.apache.logging.log4j.core.appender.AppenderLoggingException;
 import org.apache.logging.log4j.core.impl.ContextDataFactory;
 import org.apache.logging.log4j.core.impl.Log4jLogEvent;
-import org.apache.logging.log4j.junit.UsingThreadContextStack;
+import org.apache.logging.log4j.junit.ThreadContextStackRule;
 import org.apache.logging.log4j.message.Message;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Captor;
 import org.mockito.Mock;
-import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.stubbing.Answer;
 
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static org.junit.jupiter.api.Assertions.*;
-import static org.mockito.ArgumentMatchers.anyInt;
-import static org.mockito.BDDMockito.given;
-import static org.mockito.BDDMockito.then;
-import static org.mockito.Mockito.mock;
-
-@ExtendWith(MockitoExtension.class)
-@UsingThreadContextStack
+@RunWith(MockitoJUnitRunner.class)
 public class NoSqlDatabaseManagerTest {
     @Mock
     private NoSqlConnection<Map<String, Object>, DefaultNoSqlObject> connection;
@@ -58,11 +64,26 @@ public class NoSqlDatabaseManagerTest {
     @Captor
     private ArgumentCaptor<NoSqlObject<Map<String, Object>>> captor;
 
-    @BeforeEach
+    @Rule
+    public final ThreadContextStackRule threadContextRule = new ThreadContextStackRule();
+    @Rule
+    public final ExpectedException expectedException = ExpectedException.none();
+
+    @Before
     public void setUp() {
         given(provider.getConnection()).willReturn(connection);
-        given(connection.createObject()).willAnswer(invocation -> new DefaultNoSqlObject());
-        given(connection.createList(anyInt())).willAnswer(invocation -> new DefaultNoSqlObject[invocation.<Integer>getArgument(0)]);
+        given(connection.createObject()).willAnswer(new Answer<DefaultNoSqlObject>() {
+            @Override
+            public DefaultNoSqlObject answer(final InvocationOnMock invocation) throws Throwable {
+                return new DefaultNoSqlObject();
+            }
+        });
+        given(connection.createList(anyInt())).willAnswer(new Answer<DefaultNoSqlObject[]>() {
+            @Override
+            public DefaultNoSqlObject[] answer(final InvocationOnMock invocation) throws Throwable {
+                return new DefaultNoSqlObject[invocation.<Integer>getArgument(0)];
+            }
+        });
     }
 
     @Test
@@ -70,7 +91,7 @@ public class NoSqlDatabaseManagerTest {
         try (final NoSqlDatabaseManager<?> manager = NoSqlDatabaseManager.getNoSqlDatabaseManager("name", 0,
             provider)) {
 
-            assertNotNull(manager, "The manager should not be null.");
+            assertNotNull("The manager should not be null.", manager);
 
             manager.connectAndStart();
             then(provider).should().getConnection();
@@ -82,7 +103,8 @@ public class NoSqlDatabaseManagerTest {
     public void testWriteInternalNotConnected01() {
         try (final NoSqlDatabaseManager<?> manager = NoSqlDatabaseManager.getNoSqlDatabaseManager("name", 0,
             provider)) {
-            assertThrows(AppenderLoggingException.class, () -> manager.writeInternal(mock(LogEvent.class), null));
+            expectedException.expect(AppenderLoggingException.class);
+            manager.writeInternal(mock(LogEvent.class), null);
         }
     }
 
@@ -97,7 +119,8 @@ public class NoSqlDatabaseManagerTest {
             manager.connectAndStart();
             then(provider).should().getConnection();
 
-            assertThrows(AppenderLoggingException.class, () -> manager.writeInternal(mock(LogEvent.class), null));
+            expectedException.expect(AppenderLoggingException.class);
+            manager.writeInternal(mock(LogEvent.class), null);
         }
     }
 
@@ -128,33 +151,33 @@ public class NoSqlDatabaseManagerTest {
             then(connection).should().insertObject(captor.capture());
 
             final NoSqlObject<Map<String, Object>> inserted = captor.getValue();
-            assertNotNull(inserted, "The inserted value should not be null.");
+            assertNotNull("The inserted value should not be null.", inserted);
             final Map<String, Object> object = inserted.unwrap();
-            assertNotNull(object, "The unwrapped object should not be null.");
+            assertNotNull("The unwrapped object should not be null.", object);
 
-            assertEquals(Level.WARN, object.get("level"), "The level is not correct.");
-            assertEquals("com.foo.NoSQLDbTest.testWriteInternal01",
-                object.get("loggerName"), "The logger is not correct.");
-            assertEquals("My formatted message 01.", object.get("message"), "The message is not correct.");
-            assertEquals("MyThread-A", object.get("threadName"), "The thread is not correct.");
-            assertEquals(1234567890123L, object.get("millis"), "The millis is not correct.");
-            assertEquals(1234567890123L, ((Date) object.get("date")).getTime(), "The date is not correct.");
+            assertEquals("The level is not correct.", Level.WARN, object.get("level"));
+            assertEquals("The logger is not correct.", "com.foo.NoSQLDbTest.testWriteInternal01",
+                object.get("loggerName"));
+            assertEquals("The message is not correct.", "My formatted message 01.", object.get("message"));
+            assertEquals("The thread is not correct.", "MyThread-A", object.get("threadName"));
+            assertEquals("The millis is not correct.", 1234567890123L, object.get("millis"));
+            assertEquals("The date is not correct.", 1234567890123L, ((Date) object.get("date")).getTime());
 
-            assertTrue(object.get("source") instanceof Map, "The source should be a map.");
+            assertTrue("The source should be a map.", object.get("source") instanceof Map);
             @SuppressWarnings("unchecked")
             final Map<String, Object> source = (Map<String, Object>) object.get("source");
-            assertEquals("com.foo.Bar", source.get("className"), "The class is not correct.");
-            assertEquals("testMethod01", source.get("methodName"), "The method is not correct.");
-            assertEquals("Bar.java", source.get("fileName"), "The file name is not correct.");
-            assertEquals(15, source.get("lineNumber"), "The line number is not correct.");
+            assertEquals("The class is not correct.", "com.foo.Bar", source.get("className"));
+            assertEquals("The method is not correct.", "testMethod01", source.get("methodName"));
+            assertEquals("The file name is not correct.", "Bar.java", source.get("fileName"));
+            assertEquals("The line number is not correct.", 15, source.get("lineNumber"));
 
-            assertNull(object.get("marker"), "The marker should be null.");
+            assertNull("The marker should be null.", object.get("marker"));
 
-            assertNull(object.get("thrown"), "The thrown should be null.");
+            assertNull("The thrown should be null.", object.get("thrown"));
 
-            assertTrue(((Map<?, ?>) object.get("contextMap")).isEmpty(), "The context map should be empty.");
+            assertTrue("The context map should be empty.", ((Map<?, ?>) object.get("contextMap")).isEmpty());
 
-            assertTrue(((Collection<?>) object.get("contextStack")).isEmpty(), "The context stack should be null.");
+            assertTrue("The context stack should be null.", ((Collection<?>) object.get("contextStack")).isEmpty());
 
         }
     }
@@ -200,60 +223,60 @@ public class NoSqlDatabaseManagerTest {
             then(connection).should().insertObject(captor.capture());
 
             final NoSqlObject<Map<String, Object>> inserted = captor.getValue();
-            assertNotNull(inserted, "The inserted value should not be null.");
+            assertNotNull("The inserted value should not be null.", inserted);
             final Map<String, Object> object = inserted.unwrap();
-            assertNotNull(object, "The unwrapped object should not be null.");
+            assertNotNull("The unwrapped object should not be null.", object);
 
-            assertEquals(Level.DEBUG, object.get("level"), "The level is not correct.");
-            assertEquals("com.foo.NoSQLDbTest.testWriteInternal02",
-                object.get("loggerName"), "The logger is not correct.");
-            assertEquals("Another cool message 02.", object.get("message"), "The message is not correct.");
-            assertEquals("AnotherThread-B", object.get("threadName"), "The thread is not correct.");
-            assertEquals(987654321564L, object.get("millis"), "The millis is not correct.");
-            assertEquals(987654321564L, ((Date) object.get("date")).getTime(), "The date is not correct.");
+            assertEquals("The level is not correct.", Level.DEBUG, object.get("level"));
+            assertEquals("The logger is not correct.", "com.foo.NoSQLDbTest.testWriteInternal02",
+                object.get("loggerName"));
+            assertEquals("The message is not correct.", "Another cool message 02.", object.get("message"));
+            assertEquals("The thread is not correct.", "AnotherThread-B", object.get("threadName"));
+            assertEquals("The millis is not correct.", 987654321564L, object.get("millis"));
+            assertEquals("The date is not correct.", 987654321564L, ((Date) object.get("date")).getTime());
 
-            assertTrue(object.get("source") instanceof Map, "The source should be a map.");
+            assertTrue("The source should be a map.", object.get("source") instanceof Map);
             @SuppressWarnings("unchecked")
             final Map<String, Object> source = (Map<String, Object>) object.get("source");
-            assertEquals("com.bar.Foo", source.get("className"), "The class is not correct.");
-            assertEquals("anotherMethod03", source.get("methodName"), "The method is not correct.");
-            assertEquals("Foo.java", source.get("fileName"), "The file name is not correct.");
-            assertEquals(9, source.get("lineNumber"), "The line number is not correct.");
+            assertEquals("The class is not correct.", "com.bar.Foo", source.get("className"));
+            assertEquals("The method is not correct.", "anotherMethod03", source.get("methodName"));
+            assertEquals("The file name is not correct.", "Foo.java", source.get("fileName"));
+            assertEquals("The line number is not correct.", 9, source.get("lineNumber"));
 
-            assertTrue(object.get("marker") instanceof Map, "The marker should be a map.");
+            assertTrue("The marker should be a map.", object.get("marker") instanceof Map);
             @SuppressWarnings("unchecked")
             final Map<String, Object> marker = (Map<String, Object>) object.get("marker");
-            assertEquals("LoneMarker", marker.get("name"), "The marker name is not correct.");
-            assertNull(marker.get("parent"), "The marker parent should be null.");
+            assertEquals("The marker name is not correct.", "LoneMarker", marker.get("name"));
+            assertNull("The marker parent should be null.", marker.get("parent"));
 
-            assertTrue(object.get("thrown") instanceof Map, "The thrown should be a map.");
+            assertTrue("The thrown should be a map.", object.get("thrown") instanceof Map);
             @SuppressWarnings("unchecked")
             final Map<String, Object> thrown = (Map<String, Object>) object.get("thrown");
-            assertEquals("java.lang.RuntimeException", thrown.get("type"), "The thrown type is not correct.");
-            assertEquals("This is something cool!", thrown.get("message"), "The thrown message is not correct.");
-            assertTrue(thrown.get("stackTrace") instanceof List, "The thrown stack trace should be a list.");
+            assertEquals("The thrown type is not correct.", "java.lang.RuntimeException", thrown.get("type"));
+            assertEquals("The thrown message is not correct.", "This is something cool!", thrown.get("message"));
+            assertTrue("The thrown stack trace should be a list.", thrown.get("stackTrace") instanceof List);
             @SuppressWarnings("unchecked")
             final List<Map<String, Object>> stackTrace = (List<Map<String, Object>>) thrown.get("stackTrace");
-            assertEquals(exception.getStackTrace().length,
-                stackTrace.size(), "The thrown stack trace length is not correct.");
+            assertEquals("The thrown stack trace length is not correct.", exception.getStackTrace().length,
+                stackTrace.size());
             for (int i = 0; i < exception.getStackTrace().length; i++) {
                 final StackTraceElement e1 = exception.getStackTrace()[i];
                 final Map<String, Object> e2 = stackTrace.get(i);
 
-                assertEquals(e1.getClassName(), e2.get("className"), "Element class name [" + i + "] is not correct.");
-                assertEquals(e1.getMethodName(),
-                    e2.get("methodName"), "Element method name [" + i + "] is not correct.");
-                assertEquals(e1.getFileName(), e2.get("fileName"), "Element file name [" + i + "] is not correct.");
-                assertEquals(e1.getLineNumber(),
-                    e2.get("lineNumber"), "Element line number [" + i + "] is not correct.");
+                assertEquals("Element class name [" + i + "] is not correct.", e1.getClassName(), e2.get("className"));
+                assertEquals("Element method name [" + i + "] is not correct.", e1.getMethodName(),
+                    e2.get("methodName"));
+                assertEquals("Element file name [" + i + "] is not correct.", e1.getFileName(), e2.get("fileName"));
+                assertEquals("Element line number [" + i + "] is not correct.", e1.getLineNumber(),
+                    e2.get("lineNumber"));
             }
-            assertNull(thrown.get("cause"), "The thrown should have no cause.");
+            assertNull("The thrown should have no cause.", thrown.get("cause"));
 
-            assertTrue(object.get("contextMap") instanceof Map, "The context map should be a map.");
-            assertEquals(context, object.get("contextMap"), "The context map is not correct.");
+            assertTrue("The context map should be a map.", object.get("contextMap") instanceof Map);
+            assertEquals("The context map is not correct.", context, object.get("contextMap"));
 
-            assertTrue(object.get("contextStack") instanceof List, "The context stack should be list.");
-            assertEquals(stack.asList(), object.get("contextStack"), "The context stack is not correct.");
+            assertTrue("The context stack should be list.", object.get("contextStack") instanceof List);
+            assertEquals("The context stack is not correct.", stack.asList(), object.get("contextStack"));
         }
     }
 
@@ -301,107 +324,107 @@ public class NoSqlDatabaseManagerTest {
             then(connection).should().insertObject(captor.capture());
 
             final NoSqlObject<Map<String, Object>> inserted = captor.getValue();
-            assertNotNull(inserted, "The inserted value should not be null.");
+            assertNotNull("The inserted value should not be null.", inserted);
             final Map<String, Object> object = inserted.unwrap();
-            assertNotNull(object, "The unwrapped object should not be null.");
+            assertNotNull("The unwrapped object should not be null.", object);
 
-            assertEquals(Level.DEBUG, object.get("level"), "The level is not correct.");
-            assertEquals("com.foo.NoSQLDbTest.testWriteInternal02",
-                object.get("loggerName"), "The logger is not correct.");
-            assertEquals("Another cool message 02.", object.get("message"), "The message is not correct.");
-            assertEquals("AnotherThread-B", object.get("threadName"), "The thread is not correct.");
-            assertEquals(987654321564L, object.get("millis"), "The millis is not correct.");
-            assertEquals(987654321564L, ((Date) object.get("date")).getTime(), "The date is not correct.");
+            assertEquals("The level is not correct.", Level.DEBUG, object.get("level"));
+            assertEquals("The logger is not correct.", "com.foo.NoSQLDbTest.testWriteInternal02",
+                object.get("loggerName"));
+            assertEquals("The message is not correct.", "Another cool message 02.", object.get("message"));
+            assertEquals("The thread is not correct.", "AnotherThread-B", object.get("threadName"));
+            assertEquals("The millis is not correct.", 987654321564L, object.get("millis"));
+            assertEquals("The date is not correct.", 987654321564L, ((Date) object.get("date")).getTime());
 
-            assertTrue(object.get("source") instanceof Map, "The source should be a map.");
+            assertTrue("The source should be a map.", object.get("source") instanceof Map);
             @SuppressWarnings("unchecked")
             final Map<String, Object> source = (Map<String, Object>) object.get("source");
-            assertEquals("com.bar.Foo", source.get("className"), "The class is not correct.");
-            assertEquals("anotherMethod03", source.get("methodName"), "The method is not correct.");
-            assertEquals("Foo.java", source.get("fileName"), "The file name is not correct.");
-            assertEquals(9, source.get("lineNumber"), "The line number is not correct.");
+            assertEquals("The class is not correct.", "com.bar.Foo", source.get("className"));
+            assertEquals("The method is not correct.", "anotherMethod03", source.get("methodName"));
+            assertEquals("The file name is not correct.", "Foo.java", source.get("fileName"));
+            assertEquals("The line number is not correct.", 9, source.get("lineNumber"));
 
-            assertTrue(object.get("marker") instanceof Map, "The marker should be a map.");
+            assertTrue("The marker should be a map.", object.get("marker") instanceof Map);
             @SuppressWarnings("unchecked")
             final Map<String, Object> marker = (Map<String, Object>) object.get("marker");
-            assertEquals("AnotherMarker", marker.get("name"), "The marker name is not correct.");
+            assertEquals("The marker name is not correct.", "AnotherMarker", marker.get("name"));
 
-            assertTrue(marker.get("parents") instanceof List, "The marker parents should be a list.");
+            assertTrue("The marker parents should be a list.", marker.get("parents") instanceof List);
             @SuppressWarnings("unchecked")
             final List<Object> markerParents = (List<Object>) marker.get("parents");
-            assertEquals(2, markerParents.size(), "The marker parents should contain two parents");
+            assertEquals("The marker parents should contain two parents", 2, markerParents.size());
 
-            assertTrue(markerParents.get(0) instanceof Map, "The marker parents[0] should be a map.");
+            assertTrue("The marker parents[0] should be a map.", markerParents.get(0) instanceof Map);
             @SuppressWarnings("unchecked")
             final Map<String, Object> parent1 = (Map<String, Object>) markerParents.get(0);
-            assertEquals("Parent1", parent1.get("name"), "The first marker parent name is not correct.");
+            assertEquals("The first marker parent name is not correct.", "Parent1", parent1.get("name"));
 
-            assertTrue(markerParents.get(1) instanceof Map, "The marker parents[1] should be a map.");
+            assertTrue("The marker parents[1] should be a map.", markerParents.get(1) instanceof Map);
             @SuppressWarnings("unchecked")
             final Map<String, Object> parent2 = (Map<String, Object>) markerParents.get(1);
-            assertEquals("Parent2", parent2.get("name"), "The second marker parent name is not correct.");
-            assertNull(parent2.get("parent"), "The second marker should have no parent.");
+            assertEquals("The second marker parent name is not correct.", "Parent2", parent2.get("name"));
+            assertNull("The second marker should have no parent.", parent2.get("parent"));
 
-            assertTrue(parent1.get("parents") instanceof List, "The parent1 parents should be a list.");
+            assertTrue("The parent1 parents should be a list.", parent1.get("parents") instanceof List);
             @SuppressWarnings("unchecked")
             final List<Object> parent1Parents = (List<Object>) parent1.get("parents");
-            assertEquals(1, parent1Parents.size(), "The parent1 parents should have only one parent");
+            assertEquals("The parent1 parents should have only one parent", 1, parent1Parents.size());
 
-            assertTrue(parent1Parents.get(0) instanceof Map, "The parent1Parents[0] should be a map.");
+            assertTrue("The parent1Parents[0] should be a map.", parent1Parents.get(0) instanceof Map);
             @SuppressWarnings("unchecked")
             final Map<String, Object> parent1parent = (Map<String, Object>) parent1Parents.get(0);
-            assertEquals("GrandParent1", parent1parent.get("name"), "The first parent1 parent name is not correct.");
-            assertNull(parent1parent.get("parent"), "The parent1parent marker should have no parent.");
+            assertEquals("The first parent1 parent name is not correct.", "GrandParent1", parent1parent.get("name"));
+            assertNull("The parent1parent marker should have no parent.", parent1parent.get("parent"));
 
-            assertTrue(object.get("thrown") instanceof Map, "The thrown should be a map.");
+            assertTrue("The thrown should be a map.", object.get("thrown") instanceof Map);
             @SuppressWarnings("unchecked")
             final Map<String, Object> thrown = (Map<String, Object>) object.get("thrown");
-            assertEquals("java.lang.IllegalStateException", thrown.get("type"), "The thrown type is not correct.");
-            assertEquals("This is the result.", thrown.get("message"), "The thrown message is not correct.");
-            assertTrue(thrown.get("stackTrace") instanceof List, "The thrown stack trace should be a list.");
+            assertEquals("The thrown type is not correct.", "java.lang.IllegalStateException", thrown.get("type"));
+            assertEquals("The thrown message is not correct.", "This is the result.", thrown.get("message"));
+            assertTrue("The thrown stack trace should be a list.", thrown.get("stackTrace") instanceof List);
             @SuppressWarnings("unchecked")
             final List<Map<String, Object>> stackTrace = (List<Map<String, Object>>) thrown.get("stackTrace");
-            assertEquals(exception2.getStackTrace().length,
-                stackTrace.size(), "The thrown stack trace length is not correct.");
+            assertEquals("The thrown stack trace length is not correct.", exception2.getStackTrace().length,
+                stackTrace.size());
             for (int i = 0; i < exception2.getStackTrace().length; i++) {
                 final StackTraceElement e1 = exception2.getStackTrace()[i];
                 final Map<String, Object> e2 = stackTrace.get(i);
 
-                assertEquals(e1.getClassName(), e2.get("className"), "Element class name [" + i + "] is not correct.");
-                assertEquals(e1.getMethodName(),
-                    e2.get("methodName"), "Element method name [" + i + "] is not correct.");
-                assertEquals(e1.getFileName(), e2.get("fileName"), "Element file name [" + i + "] is not correct.");
-                assertEquals(e1.getLineNumber(),
-                    e2.get("lineNumber"), "Element line number [" + i + "] is not correct.");
+                assertEquals("Element class name [" + i + "] is not correct.", e1.getClassName(), e2.get("className"));
+                assertEquals("Element method name [" + i + "] is not correct.", e1.getMethodName(),
+                    e2.get("methodName"));
+                assertEquals("Element file name [" + i + "] is not correct.", e1.getFileName(), e2.get("fileName"));
+                assertEquals("Element line number [" + i + "] is not correct.", e1.getLineNumber(),
+                    e2.get("lineNumber"));
             }
-            assertTrue(thrown.get("cause") instanceof Map, "The thrown cause should be a map.");
+            assertTrue("The thrown cause should be a map.", thrown.get("cause") instanceof Map);
             @SuppressWarnings("unchecked")
             final Map<String, Object> cause = (Map<String, Object>) thrown.get("cause");
-            assertEquals("java.io.IOException", cause.get("type"), "The cause type is not correct.");
-            assertEquals("This is the cause.", cause.get("message"), "The cause message is not correct.");
-            assertTrue(cause.get("stackTrace") instanceof List, "The cause stack trace should be a list.");
+            assertEquals("The cause type is not correct.", "java.io.IOException", cause.get("type"));
+            assertEquals("The cause message is not correct.", "This is the cause.", cause.get("message"));
+            assertTrue("The cause stack trace should be a list.", cause.get("stackTrace") instanceof List);
             @SuppressWarnings("unchecked")
             final List<Map<String, Object>> causeStackTrace = (List<Map<String, Object>>) cause.get("stackTrace");
-            assertEquals(exception1.getStackTrace().length,
-                causeStackTrace.size(), "The cause stack trace length is not correct.");
+            assertEquals("The cause stack trace length is not correct.", exception1.getStackTrace().length,
+                causeStackTrace.size());
             for (int i = 0; i < exception1.getStackTrace().length; i++) {
                 final StackTraceElement e1 = exception1.getStackTrace()[i];
                 final Map<String, Object> e2 = causeStackTrace.get(i);
 
-                assertEquals(e1.getClassName(), e2.get("className"), "Element class name [" + i + "] is not correct.");
-                assertEquals(e1.getMethodName(),
-                    e2.get("methodName"), "Element method name [" + i + "] is not correct.");
-                assertEquals(e1.getFileName(), e2.get("fileName"), "Element file name [" + i + "] is not correct.");
-                assertEquals(e1.getLineNumber(),
-                    e2.get("lineNumber"), "Element line number [" + i + "] is not correct.");
+                assertEquals("Element class name [" + i + "] is not correct.", e1.getClassName(), e2.get("className"));
+                assertEquals("Element method name [" + i + "] is not correct.", e1.getMethodName(),
+                    e2.get("methodName"));
+                assertEquals("Element file name [" + i + "] is not correct.", e1.getFileName(), e2.get("fileName"));
+                assertEquals("Element line number [" + i + "] is not correct.", e1.getLineNumber(),
+                    e2.get("lineNumber"));
             }
-            assertNull(cause.get("cause"), "The cause should have no cause.");
+            assertNull("The cause should have no cause.", cause.get("cause"));
 
-            assertTrue(object.get("contextMap") instanceof Map, "The context map should be a map.");
-            assertEquals(context, object.get("contextMap"), "The context map is not correct.");
+            assertTrue("The context map should be a map.", object.get("contextMap") instanceof Map);
+            assertEquals("The context map is not correct.", context, object.get("contextMap"));
 
-            assertTrue(object.get("contextStack") instanceof List, "The context stack should be list.");
-            assertEquals(stack.asList(), object.get("contextStack"), "The context stack is not correct.");
+            assertTrue("The context stack should be list.", object.get("contextStack") instanceof List);
+            assertEquals("The context stack is not correct.", stack.asList(), object.get("contextStack"));
         }
     }
 }
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RandomRollingAppenderOnStartupTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RandomRollingAppenderOnStartupTest.java
index b145be7..c24fa50 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RandomRollingAppenderOnStartupTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RandomRollingAppenderOnStartupTest.java
@@ -16,33 +16,56 @@
  */
 package org.apache.logging.log4j.core.appender.rolling;
 
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.junit.LoggerContextSource;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Test;
-
 import java.nio.file.DirectoryStream;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
+import java.util.Arrays;
+import java.util.Collection;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.junit.LoggerContextRule;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
 
-import static org.apache.logging.log4j.util.Unbox.box;
-import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.Assert.assertTrue;
 
-@LoggerContextSource(value = "log4j-test5.xml", timeout = 10)
+/**
+ *
+ */
+@RunWith(Parameterized.class)
 public class RandomRollingAppenderOnStartupTest {
 
     private static final String DIR = "target/onStartup";
 
-    private final Logger logger;
+    private Logger logger;
+
+    @Parameterized.Parameters(name = "{0} \u2192 {1}")
+    public static Collection<Object[]> data() {
+        return Arrays.asList(new Object[][] { //
+                // @formatter:off
+                {"log4j-test5.xml"},
+                {"log4j-test5.xml"},});
+                // @formatter:on
+    }
+
+    @Rule
+    public LoggerContextRule loggerContextRule;
+
+    public RandomRollingAppenderOnStartupTest(final String configFile) {
+        this.loggerContextRule = LoggerContextRule.createShutdownTimeoutLoggerContextRule(configFile);
+    }
 
-    public RandomRollingAppenderOnStartupTest(final LoggerContext context) {
-        logger = context.getLogger(getClass());
+    @Before
+    public void setUp() throws Exception {
+        this.logger = this.loggerContextRule.getLogger(RandomRollingAppenderOnStartupTest.class.getName());
     }
 
-    @BeforeAll
+    @BeforeClass
     public static void beforeClass() throws Exception {
         if (Files.exists(Paths.get("target/onStartup"))) {
             try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(Paths.get(DIR))) {
@@ -54,7 +77,7 @@ public class RandomRollingAppenderOnStartupTest {
         }
     }
 
-    @AfterAll
+    @AfterClass
     public static void afterClass() throws Exception {
         long size = 0;
         try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(Paths.get(DIR))) {
@@ -63,7 +86,8 @@ public class RandomRollingAppenderOnStartupTest {
                     size = Files.size(path);
                 } else {
                     final long fileSize = Files.size(path);
-                    assertEquals(fileSize, size, "Expected size: " + size + " Size of " + path.getFileName() + ": " + fileSize);
+                    assertTrue("Expected size: " + size + " Size of " + path.getFileName() + ": " + fileSize,
+                            size == fileSize);
                 }
                 Files.delete(path);
             }
@@ -74,7 +98,7 @@ public class RandomRollingAppenderOnStartupTest {
     @Test
     public void testAppender() throws Exception {
         for (int i = 0; i < 100; ++i) {
-            logger.debug("This is test message number {}", box(i));
+            logger.debug("This is test message number " + i);
         }
 
     }