Use a ThreadContextRule to clean up tests. Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/e982213b Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/e982213b Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/e982213b
Branch: refs/heads/LOG4J2-1010&LOG4J2-1447-injectable-contextdata&better-datastructure Commit: e982213b2103cc3504fffb1ce7e765ff8cbea623 Parents: e88800c Author: Gary Gregory <ggreg...@apache.org> Authored: Mon Aug 15 13:24:28 2016 -0700 Committer: Gary Gregory <ggreg...@apache.org> Committed: Mon Aug 15 13:24:28 2016 -0700 ---------------------------------------------------------------------- .../apache/logging/log4j/core/layout/PatternLayoutTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/e982213b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java index 07bde21..43a9167 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java @@ -31,10 +31,12 @@ import org.apache.logging.log4j.core.LoggerContext; import org.apache.logging.log4j.core.config.ConfigurationFactory; import org.apache.logging.log4j.core.impl.Log4jLogEvent; import org.apache.logging.log4j.core.lookup.MainMapLookup; +import org.apache.logging.log4j.junit.ThreadContextRule; import org.apache.logging.log4j.message.SimpleMessage; import org.apache.logging.log4j.util.Strings; import org.junit.After; import org.junit.BeforeClass; +import org.junit.Rule; import org.junit.Test; import static org.junit.Assert.*; @@ -70,10 +72,8 @@ public class PatternLayoutTest { Logger root = ctx.getRootLogger(); - @After - public void after() { - ThreadContext.clearMap(); - } + @Rule + public final ThreadContextRule threadContextRule = new ThreadContextRule(); private static class Destination implements ByteBufferDestination { ByteBuffer byteBuffer = ByteBuffer.wrap(new byte[2048]);