logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mattsic...@apache.org
Subject svn commit: r1582151 - /logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/config/ConfigurationTest.java
Date Thu, 27 Mar 2014 02:09:25 GMT
Author: mattsicker
Date: Thu Mar 27 02:09:25 2014
New Revision: 1582151

URL: http://svn.apache.org/r1582151
Log:
Update test to use InitialLoggerContext rule.

Modified:
    logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/config/ConfigurationTest.java

Modified: logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/config/ConfigurationTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/config/ConfigurationTest.java?rev=1582151&r1=1582150&r2=1582151&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/config/ConfigurationTest.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/config/ConfigurationTest.java
Thu Mar 27 02:09:25 2014
@@ -28,21 +28,19 @@ import java.util.Iterator;
 import java.util.Map;
 
 import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.core.Appender;
 import org.apache.logging.log4j.core.Filter;
 import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.core.filter.ThreadContextMapFilter;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.junit.After;
+import org.apache.logging.log4j.junit.InitialLoggerContext;
 import org.junit.Before;
+import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameters;
 
-import static org.apache.logging.log4j.core.config.ConfigurationFactory.CONFIGURATION_FILE_PROPERTY;
 import static org.hamcrest.CoreMatchers.endsWith;
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.instanceOf;
@@ -64,6 +62,9 @@ public class ConfigurationTest {
     private final String configFileName;
     private final String logFileName;
 
+    @Rule
+    public InitialLoggerContext init;
+
     private LoggerContext ctx;
 
     private SecureRandom random = new SecureRandom();
@@ -71,6 +72,7 @@ public class ConfigurationTest {
     public ConfigurationTest(final String configFileName, final String logFileName) {
         this.configFileName = configFileName;
         this.logFileName = logFileName;
+        this.init = new InitialLoggerContext(configFileName);
     }
 
     @Parameters
@@ -86,17 +88,8 @@ public class ConfigurationTest {
 
     @Before
     public void setUp() throws Exception {
-        System.setProperty(CONFIGURATION_FILE_PROPERTY, this.configFileName);
-        clearLogFile(this.logFileName);
-        this.ctx = (LoggerContext) LogManager.getContext(false);
-        this.ctx.reconfigure();
-    }
-
-    @After
-    public void tearDown() throws Exception {
-        System.clearProperty(CONFIGURATION_FILE_PROPERTY);
-        this.ctx.reconfigure();
-        StatusLogger.getLogger().reset();
+        clearLogFile(this.configFileName);
+        this.ctx = this.init.getContext();
     }
 
     @Test



Mime
View raw message