[logback-dev] svn commit: r1502 - logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic

noreply.ceki at qos.ch noreply.ceki at qos.ch
Mon Apr 2 20:10:36 CEST 2007


Author: ceki
Date: Mon Apr  2 20:10:36 2007
New Revision: 1502

Added:
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/TurboFilteringInLoggerTest.java
      - copied, changed from r1501, /logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/LoggerTest.java
Removed:
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/LoggerTest.java
Modified:
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/BasicLoggerTest.java
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/PackageTest.java

Log:

- Renamed LoggerTest as TurboFilteringInLoggerTest
- Fixed serious bugs in isXYZEnabled methods as reported in http://www.slf4j.org/pipermail/user/2007-April/000319.html

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/BasicLoggerTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/BasicLoggerTest.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/BasicLoggerTest.java	Mon Apr  2 20:10:36 2007
@@ -83,4 +83,72 @@
     assertEquals(3, listAppender.list.size());
   }
   
+  public void testEnabledX_Debug() throws Exception {
+    LoggerContext lc = new LoggerContext();
+    Logger root = lc.getLogger(LoggerContext.ROOT_NAME);
+    root.setLevel(Level.DEBUG);
+    Logger logger = lc.getLogger(BasicLoggerTest.class);
+
+
+    assertTrue(logger.isDebugEnabled());
+    assertTrue(logger.isInfoEnabled());
+    assertTrue(logger.isWarnEnabled());
+    assertTrue(logger.isErrorEnabled());
+    assertTrue(logger.isEnabledFor(Level.DEBUG));
+    assertTrue(logger.isEnabledFor(Level.INFO));
+    assertTrue(logger.isEnabledFor(Level.WARN));    
+    assertTrue(logger.isEnabledFor(Level.ERROR));
+  }
+  
+  
+  
+  public void testEnabledX_Info() throws Exception {
+    LoggerContext lc = new LoggerContext();
+    Logger root = lc.getLogger(LoggerContext.ROOT_NAME);
+    root.setLevel(Level.INFO);
+    Logger logger = lc.getLogger(BasicLoggerTest.class);
+
+    assertFalse(logger.isDebugEnabled());
+    assertTrue(logger.isInfoEnabled());
+    assertTrue(logger.isWarnEnabled());
+    assertTrue(logger.isErrorEnabled());
+    assertFalse(logger.isEnabledFor(Level.DEBUG));
+    assertTrue(logger.isEnabledFor(Level.INFO));
+    assertTrue(logger.isEnabledFor(Level.WARN));    
+    assertTrue(logger.isEnabledFor(Level.ERROR));
+  }
+  
+  public void testEnabledX_Warn() throws Exception {
+    LoggerContext lc = new LoggerContext();
+    Logger root = lc.getLogger(LoggerContext.ROOT_NAME);
+    root.setLevel(Level.WARN);
+    Logger logger = lc.getLogger(BasicLoggerTest.class);
+
+    assertFalse(logger.isDebugEnabled());
+    assertFalse(logger.isInfoEnabled());
+    assertTrue(logger.isWarnEnabled());
+    assertTrue(logger.isErrorEnabled());
+    assertFalse(logger.isEnabledFor(Level.DEBUG));
+    assertFalse(logger.isEnabledFor(Level.INFO));
+    assertTrue(logger.isEnabledFor(Level.WARN));    
+    assertTrue(logger.isEnabledFor(Level.ERROR));
+  }
+  
+  public void testEnabledX_Errror() throws Exception {
+    LoggerContext lc = new LoggerContext();
+    Logger root = lc.getLogger(LoggerContext.ROOT_NAME);
+    root.setLevel(Level.ERROR);
+    Logger logger = lc.getLogger(BasicLoggerTest.class);
+
+    assertFalse(logger.isDebugEnabled());
+    assertFalse(logger.isInfoEnabled());
+    assertFalse(logger.isWarnEnabled());
+    assertTrue(logger.isErrorEnabled());
+    assertFalse(logger.isEnabledFor(Level.DEBUG));
+    assertFalse(logger.isEnabledFor(Level.INFO));
+    assertFalse(logger.isEnabledFor(Level.WARN));    
+    assertTrue(logger.isEnabledFor(Level.ERROR));
+  }
+
+  
 }

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/PackageTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/PackageTest.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/PackageTest.java	Mon Apr  2 20:10:36 2007
@@ -21,7 +21,7 @@
     suite.addTestSuite(BasicLoggerTest.class);
     suite.addTestSuite(MessageFormattingTest.class);
     suite.addTestSuite(MDCTest.class);
-    suite.addTestSuite(LoggerTest.class);
+    suite.addTestSuite(TurboFilteringInLoggerTest.class);
     return suite;
   }
 }
\ No newline at end of file

Copied: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/TurboFilteringInLoggerTest.java (from r1501, /logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/LoggerTest.java)
==============================================================================
--- /logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/LoggerTest.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/TurboFilteringInLoggerTest.java	Mon Apr  2 20:10:36 2007
@@ -6,7 +6,7 @@
 import ch.qos.logback.core.spi.FilterReply;
 import junit.framework.TestCase;
 
-public class LoggerTest extends TestCase {
+public class TurboFilteringInLoggerTest extends TestCase {
 
   LoggerContext context;
   Logger logger;
@@ -17,7 +17,7 @@
     context = new LoggerContext();
     context.setName("test");
     context.start();
-    logger = context.getLogger(LoggerTest.class);
+    logger = context.getLogger(TurboFilteringInLoggerTest.class);
   }
 
   @Override



More information about the logback-dev mailing list