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

Branch: 
refs/heads/LOG4J2-1010&LOG4J2-1447-injectable-contextdata&better-datastructure
Commit: f965d03cbeb269dddaeca5dabf2f2b46e5d09474
Parents: 0277dd9
Author: Gary Gregory <ggreg...@apache.org>
Authored: Mon Aug 15 13:16:38 2016 -0700
Committer: Gary Gregory <ggreg...@apache.org>
Committed: Mon Aug 15 13:16:38 2016 -0700

----------------------------------------------------------------------
 .../log4j/core/pattern/NdcPatternConverterTest.java   | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f965d03c/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/NdcPatternConverterTest.java
----------------------------------------------------------------------
diff --git 
a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/NdcPatternConverterTest.java
 
b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/NdcPatternConverterTest.java
index 85b3e85..92557ec 100644
--- 
a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/NdcPatternConverterTest.java
+++ 
b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/NdcPatternConverterTest.java
@@ -16,19 +16,23 @@
  */
 package org.apache.logging.log4j.core.pattern;
 
+import static org.junit.Assert.assertEquals;
+
 import org.apache.logging.log4j.Level;
 import org.apache.logging.log4j.ThreadContext;
 import org.apache.logging.log4j.core.LogEvent;
 import org.apache.logging.log4j.core.impl.Log4jLogEvent;
+import org.apache.logging.log4j.junit.ThreadContextStackRule;
 import org.apache.logging.log4j.message.Message;
 import org.apache.logging.log4j.message.SimpleMessage;
-import org.junit.After;
+import org.junit.Rule;
 import org.junit.Test;
 
-import static org.junit.Assert.assertEquals;
-
 public class NdcPatternConverterTest {
 
+    @Rule
+    public final ThreadContextStackRule threadContextRule = new 
ThreadContextStackRule(); 
+
     @Test
     public void testEmpty() {
         testConverter("[]");
@@ -69,9 +73,5 @@ public class NdcPatternConverterTest {
         assertEquals(expected, str);
     }
 
-    @After
-    public void tearDown() {
-        ThreadContext.clearStack();
-    }
 }
 

Reply via email to