You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rp...@apache.org on 2016/08/19 07:15:36 UTC

[11/50] logging-log4j2 git commit: Use a ThreadContextRule to clean up tests.

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/3969b593
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/3969b593
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/3969b593

Branch: refs/heads/LOG4J2-1010&LOG4J2-1447-injectable-contextdata&better-datastructure
Commit: 3969b5935be2a08a3ac380a70842ade8459f93de
Parents: 49035f8
Author: Gary Gregory <gg...@apache.org>
Authored: Mon Aug 15 13:12:00 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Mon Aug 15 13:12:00 2016 -0700

----------------------------------------------------------------------
 .../logging/log4j/core/layout/SerializedLayoutTest.java       | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3969b593/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/SerializedLayoutTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/SerializedLayoutTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/SerializedLayoutTest.java
index d4636b4..09b0a0a 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/SerializedLayoutTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/SerializedLayoutTest.java
@@ -35,10 +35,12 @@ import org.apache.logging.log4j.core.Logger;
 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.junit.ThreadContextRule;
 import org.apache.logging.log4j.message.SimpleMessage;
 import org.apache.logging.log4j.test.appender.ListAppender;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
+import org.junit.Rule;
 import org.junit.Test;
 
 import static org.junit.Assert.*;
@@ -53,9 +55,11 @@ public class SerializedLayoutTest {
 
     static ConfigurationFactory cf = new BasicConfigurationFactory();
 
+    @Rule
+    public final ThreadContextRule threadContextRule = new ThreadContextRule(); 
+
     @BeforeClass
     public static void setupClass() {
-        ThreadContext.clearAll();
         ConfigurationFactory.setConfigurationFactory(cf);
         final LoggerContext ctx = LoggerContext.getContext();
         ctx.reconfigure();
@@ -64,7 +68,6 @@ public class SerializedLayoutTest {
     @AfterClass
     public static void cleanupClass() {
         ConfigurationFactory.removeConfigurationFactory(cf);
-        ThreadContext.clearAll();
     }
 
     private static final String body =