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
commit 4f27e1310648070484cff8a70189762d4aa06ed5 Author: Matt Sicker <[email protected]> AuthorDate: Sun Oct 30 14:17:42 2022 -0500 Add assertions to give better error messages Signed-off-by: Matt Sicker <[email protected]> --- .../logging/log4j/core/test/CoreLoggerContexts.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/log4j-core-test/src/main/java/org/apache/logging/log4j/core/test/CoreLoggerContexts.java b/log4j-core-test/src/main/java/org/apache/logging/log4j/core/test/CoreLoggerContexts.java index a2b9456848..b9d479c04f 100644 --- a/log4j-core-test/src/main/java/org/apache/logging/log4j/core/test/CoreLoggerContexts.java +++ b/log4j-core-test/src/main/java/org/apache/logging/log4j/core/test/CoreLoggerContexts.java @@ -17,10 +17,13 @@ package org.apache.logging.log4j.core.test; -import java.io.File; - import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.core.LifeCycle; +import org.apache.logging.log4j.spi.LoggerContext; + +import java.io.File; + +import static org.assertj.core.api.Assertions.assertThat; public class CoreLoggerContexts { @@ -32,11 +35,15 @@ public class CoreLoggerContexts { } public static void stopLoggerContext() { - ((LifeCycle) LogManager.getContext()).stop(); // stops async thread + final LoggerContext context = LogManager.getContext(); + assertThat(context).isInstanceOf(LifeCycle.class); + ((LifeCycle) context).stop(); // stops async thread } public static void stopLoggerContext(final boolean currentContext) { - ((LifeCycle) LogManager.getContext(currentContext)).stop(); // stops async thread + final LoggerContext context = LogManager.getContext(currentContext); + assertThat(context).isInstanceOf(LifeCycle.class); + ((LifeCycle) context).stop(); // stops async thread } public static void stopLoggerContext(final boolean currentContext, final File checkFilePresence) throws InterruptedException {
