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

Branch: 
refs/heads/LOG4J2-1010&LOG4J2-1447-injectable-contextdata&better-datastructure
Commit: cdd636b69df81772d47edaac227a6a415acd38d6
Parents: 85f214e
Author: Gary Gregory <ggreg...@apache.org>
Authored: Mon Aug 15 13:09:12 2016 -0700
Committer: Gary Gregory <ggreg...@apache.org>
Committed: Mon Aug 15 13:09:12 2016 -0700

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


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/cdd636b6/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/GelfLayoutTest.java
----------------------------------------------------------------------
diff --git 
a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/GelfLayoutTest.java
 
b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/GelfLayoutTest.java
index 74b5c10..7ed9eeb 100644
--- 
a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/GelfLayoutTest.java
+++ 
b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/GelfLayoutTest.java
@@ -24,10 +24,12 @@ import org.apache.logging.log4j.core.*;
 import org.apache.logging.log4j.core.config.ConfigurationFactory;
 import org.apache.logging.log4j.core.layout.GelfLayout.CompressionType;
 import org.apache.logging.log4j.core.util.KeyValuePair;
+import org.apache.logging.log4j.junit.ThreadContextRule;
 import org.apache.logging.log4j.test.appender.EncodingListAppender;
 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 java.io.ByteArrayInputStream;
@@ -57,15 +59,16 @@ public class GelfLayoutTest {
     private static final String VALUE1 = "Value1";
     private static final String VALUE2 = "Value2";
 
+    @Rule
+    public final ThreadContextRule threadContextRule = new 
ThreadContextRule(); 
+
     @AfterClass
     public static void cleanupClass() {
         ConfigurationFactory.removeConfigurationFactory(configFactory);
-        ThreadContext.clearAll();
     }
 
     @BeforeClass
     public static void setupClass() {
-        ThreadContext.clearAll();
         ConfigurationFactory.setConfigurationFactory(configFactory);
         final LoggerContext ctx = LoggerContext.getContext();
         ctx.reconfigure();

Reply via email to