You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rg...@apache.org on 2014/04/27 07:29:24 UTC

svn commit: r1590347 - /logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/config/CustomConfigurationTest.java

Author: rgoers
Date: Sun Apr 27 05:29:24 2014
New Revision: 1590347

URL: http://svn.apache.org/r1590347
Log:
Fix bug in unit test

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

Modified: logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/config/CustomConfigurationTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/config/CustomConfigurationTest.java?rev=1590347&r1=1590346&r2=1590347&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/config/CustomConfigurationTest.java (original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/config/CustomConfigurationTest.java Sun Apr 27 05:29:24 2014
@@ -27,8 +27,11 @@ import org.apache.logging.log4j.core.app
 import org.apache.logging.log4j.core.config.xml.XMLConfiguration;
 import org.apache.logging.log4j.core.layout.PatternLayout;
 import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.status.StatusConsoleListener;
+import org.apache.logging.log4j.status.StatusListener;
 import org.apache.logging.log4j.status.StatusLogger;
 import org.junit.Before;
+import org.junit.BeforeClass;
 import org.junit.Rule;
 import org.junit.Test;
 
@@ -42,6 +45,12 @@ public class CustomConfigurationTest {
 
     public static final String LOG_FILE = "target/test.log";
 
+    @BeforeClass
+    public static void before() {
+        System.setProperty("log4j.level", "info");
+        System.setProperty("log.level", "info");
+    }
+
     @Rule
     public InitialLoggerContext init = new InitialLoggerContext("log4j-props.xml");
 
@@ -53,12 +62,16 @@ public class CustomConfigurationTest {
     @Test
     public void testConfig() {
         // don't bother using "error" since that's the default; try another level
-        System.setProperty("log4j.level", "info");
         final LoggerContext ctx = this.init.getContext();
         ctx.reconfigure();
         final Configuration config = ctx.getConfiguration();
         assertTrue("Configuration is not an XMLConfiguration", config instanceof XMLConfiguration);
-        assertSame(StatusLogger.getLogger().getLevel(), Level.INFO);
+        for (StatusListener listener : StatusLogger.getLogger().getListeners()) {
+            if (listener instanceof StatusConsoleListener) {
+                assertSame(listener.getStatusLevel(), Level.INFO);
+                break;
+            }
+        }
         Layout<? extends Serializable> layout = PatternLayout.createLayout(PatternLayout.SIMPLE_CONVERSION_PATTERN, config, null,
             null,null, null, null, null);
         Appender appender = FileAppender.createAppender(LOG_FILE, "false", "false", "File", "true",