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:47 UTC

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

Branch: refs/heads/LOG4J2-1010&LOG4J2-1447-injectable-contextdata&better-datastructure
Commit: 927a593d1026461cf108740271e4dbbb3f353f96
Parents: f2fdaf9
Author: Gary Gregory <gg...@apache.org>
Authored: Mon Aug 15 13:54:42 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Mon Aug 15 13:54:42 2016 -0700

----------------------------------------------------------------------
 .../log4j/core/pattern/RegexReplacementTest.java   | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/927a593d/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/RegexReplacementTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/RegexReplacementTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/RegexReplacementTest.java
index ec526a2..8d68d5c 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/RegexReplacementTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/RegexReplacementTest.java
@@ -16,19 +16,22 @@
  */
 package org.apache.logging.log4j.core.pattern;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
 import java.util.List;
 
 import org.apache.logging.log4j.ThreadContext;
 import org.apache.logging.log4j.core.util.Constants;
 import org.apache.logging.log4j.junit.LoggerContextRule;
+import org.apache.logging.log4j.junit.ThreadContextMapRule;
 import org.apache.logging.log4j.test.appender.ListAppender;
-import org.junit.After;
 import org.junit.Before;
 import org.junit.ClassRule;
+import org.junit.Rule;
 import org.junit.Test;
 
-import static org.junit.Assert.*;
-
 /**
  *
  */
@@ -42,17 +45,15 @@ public class RegexReplacementTest {
     @ClassRule
     public static LoggerContextRule context = new LoggerContextRule(CONFIG);
 
+    @Rule
+    public final ThreadContextMapRule threadContextRule = new ThreadContextMapRule(); 
+
     @Before
     public void setUp() throws Exception {
         app = context.getListAppender("List").clear();
         app2 = context.getListAppender("List2").clear();
     }
 
-    @After
-    public void tearDown() throws Exception {
-        ThreadContext.clearMap();
-    }
-
     org.apache.logging.log4j.Logger logger = context.getLogger("LoggerTest");
     org.apache.logging.log4j.Logger logger2 = context.getLogger("ReplacementTest");