logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mattsic...@apache.org
Subject svn commit: r1582158 - /logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/CallerInformationTest.java
Date Thu, 27 Mar 2014 02:43:34 GMT
Author: mattsicker
Date: Thu Mar 27 02:43:34 2014
New Revision: 1582158

URL: http://svn.apache.org/r1582158
Log:
Updated to use InitialLoggerContext rule.

Modified:
    logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/CallerInformationTest.java

Modified: logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/CallerInformationTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/CallerInformationTest.java?rev=1582158&r1=1582157&r2=1582158&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/CallerInformationTest.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/CallerInformationTest.java
Thu Mar 27 02:43:34 2014
@@ -16,16 +16,14 @@
  */
 package org.apache.logging.log4j.core.pattern;
 
-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.LoggerContext;
 import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.apache.logging.log4j.status.StatusLogger;
+import org.apache.logging.log4j.junit.InitialLoggerContext;
 import org.apache.logging.log4j.test.appender.ListAppender;
-import org.junit.AfterClass;
 import org.junit.BeforeClass;
+import org.junit.ClassRule;
 import org.junit.Test;
 
 import java.util.List;
@@ -36,7 +34,8 @@ import static org.junit.Assert.assertNot
 
 public class CallerInformationTest {
 
-    private static final String CONFIG = "log4j2-calling-class.xml";
+    @ClassRule
+    public static InitialLoggerContext init = new InitialLoggerContext("log4j2-calling-class.xml");
 
     private static LoggerContext ctx;
 
@@ -44,8 +43,7 @@ public class CallerInformationTest {
 
     @BeforeClass
     public static void setConfig() {
-        System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
-        ctx = (LoggerContext) LogManager.getContext(false);
+        ctx = init.getContext();
         assertNotNull("No LoggerContext created.", ctx);
         final Configuration config = ctx.getConfiguration();
         assertNotNull("No configuration found!", config);
@@ -54,13 +52,6 @@ public class CallerInformationTest {
         assertEquals("Incorrect number of appenders configured.", 2, appenders.size());
     }
 
-    @AfterClass
-    public static void resetConfig() {
-        System.clearProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
-        ctx.reconfigure();
-        StatusLogger.getLogger().reset();
-    }
-
     @Test
     public void testClassLogger() throws Exception {
         final ListAppender app = (ListAppender) appenders.get("Class");



Mime
View raw message