Skip to content

Commit e7ef871

Browse files
committed
Refactor log4j-slf4j2-impl tests to use assertInstanceOf
1 parent eb36897 commit e7ef871

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

log4j-slf4j2-impl/src/test/java/org/apache/logging/slf4j/Log4j1222Test.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717
package org.apache.logging.slf4j;
1818

19-
import static org.junit.jupiter.api.Assertions.assertTrue;
19+
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
2020

2121
import org.junit.jupiter.api.Test;
2222
import org.slf4j.Logger;
@@ -47,8 +47,9 @@ public void run() {
4747

4848
private void trigger() {
4949
Holder.LOGGER.info("Attempt to trigger");
50-
assertTrue(
51-
Holder.LOGGER instanceof Log4jLogger,
50+
assertInstanceOf(
51+
Log4jLogger.class,
52+
Holder.LOGGER,
5253
"Logger is of type " + Holder.LOGGER.getClass().getName());
5354
}
5455
}

log4j-slf4j2-impl/src/test/java/org/apache/logging/slf4j/LoggerContextTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*/
1717
package org.apache.logging.slf4j;
1818

19+
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
1920
import static org.junit.jupiter.api.Assertions.assertTrue;
2021

2122
import java.util.Set;
@@ -35,7 +36,7 @@ public void testCleanup() throws Exception {
3536
factory.getLogger("test");
3637
Set<LoggerContext> set = factory.getLoggerContexts();
3738
final LoggerContext ctx1 = set.toArray(LoggerContext.EMPTY_ARRAY)[0];
38-
assertTrue(ctx1 instanceof LifeCycle, "LoggerContext is not enabled for shutdown");
39+
assertInstanceOf(LifeCycle.class, ctx1, "LoggerContext is not enabled for shutdown");
3940
((LifeCycle) ctx1).stop();
4041
set = factory.getLoggerContexts();
4142
assertTrue(set.isEmpty(), "Expected no LoggerContexts");

log4j-slf4j2-impl/src/test/java/org/apache/logging/slf4j/MarkerTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import static org.junit.jupiter.api.Assertions.assertEquals;
2020
import static org.junit.jupiter.api.Assertions.assertFalse;
21+
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
2122
import static org.junit.jupiter.api.Assertions.assertNotEquals;
2223
import static org.junit.jupiter.api.Assertions.assertTrue;
2324
import static org.junit.jupiter.api.Assertions.fail;
@@ -59,7 +60,7 @@ public void testAddMarker() {
5960
final Marker log4jParent = MarkerManager.getMarker(parentMarkerName);
6061
final Marker log4jMarker = MarkerManager.getMarker(childMakerName);
6162

62-
assertTrue(slf4jMarker instanceof Log4jMarker, "Incorrect Marker class");
63+
assertInstanceOf(Log4jMarker.class, slf4jMarker, "Incorrect Marker class");
6364
assertTrue(
6465
log4jMarker.isInstanceOf(log4jParent),
6566
String.format(

0 commit comments

Comments
 (0)