[logback-dev] svn commit: r847 - in logback/trunk/logback-classic/src: main/java/ch/qos/logback/classic/turbo test/input/joran test/java/ch/qos/logback/classic/joran

noreply.seb at qos.ch noreply.seb at qos.ch
Wed Nov 1 17:51:55 CET 2006


Author: seb
Date: Wed Nov  1 17:51:54 2006
New Revision: 847

Added:
   logback/trunk/logback-classic/src/test/input/joran/turbo.xml
   logback/trunk/logback-classic/src/test/input/joran/turbo2.xml
Modified:
   logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/turbo/DebugUsersTurboFilter.java
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/BasicJoranTest.java

Log:
Added two test cases to check that Joran can configure turbo filters.
In BasicJoranTest, the method testTurboFilterWithStringList fails because Joran doesn't add correctly
users to the userList. Watch bug #27 for more info.

Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/turbo/DebugUsersTurboFilter.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/turbo/DebugUsersTurboFilter.java	(original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/turbo/DebugUsersTurboFilter.java	Wed Nov  1 17:51:54 2006
@@ -42,5 +42,9 @@
     System.out.println("******* ADD USER CALLED");
     userList.add(user);
   }
+  
+  public List<String> getUsers() {
+    return userList;
+  }
 
 }

Added: logback/trunk/logback-classic/src/test/input/joran/turbo.xml
==============================================================================
--- (empty file)
+++ logback/trunk/logback-classic/src/test/input/joran/turbo.xml	Wed Nov  1 17:51:54 2006
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE configuration>
+
+<configuration>
+  <turboFilter class="ch.qos.logback.classic.turbo.NOPTurboFilter" />
+
+  <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
+    <layout class="ch.qos.logback.classic.PatternLayout">
+      <Pattern>%caller{4} %d %level - %m%n</Pattern>
+    </layout>
+  </appender>
+  
+  <root>
+    <level value="DEBUG" />
+    <appender-ref ref="CONSOLE" />
+  </root>
+</configuration>
+  
\ No newline at end of file

Added: logback/trunk/logback-classic/src/test/input/joran/turbo2.xml
==============================================================================
--- (empty file)
+++ logback/trunk/logback-classic/src/test/input/joran/turbo2.xml	Wed Nov  1 17:51:54 2006
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE configuration>
+
+<configuration>
+  <turboFilter class="ch.qos.logback.classic.turbo.DebugUsersTurboFilter">
+    <user>seb</user>
+    <user>ceki</user>
+  </turboFilter>
+
+  <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
+    <layout class="ch.qos.logback.classic.PatternLayout">
+      <Pattern>%d %level - %m%n</Pattern>
+    </layout>
+  </appender>
+  
+  <root>
+    <level value="DEBUG" />
+    <appender-ref ref="CONSOLE" />
+  </root>
+</configuration>
+  
\ No newline at end of file

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/BasicJoranTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/BasicJoranTest.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/BasicJoranTest.java	Wed Nov  1 17:51:54 2006
@@ -15,6 +15,9 @@
 import ch.qos.logback.classic.Logger;
 import ch.qos.logback.classic.LoggerContext;
 import ch.qos.logback.classic.spi.LoggingEvent;
+import ch.qos.logback.classic.turbo.DebugUsersTurboFilter;
+import ch.qos.logback.classic.turbo.NOPTurboFilter;
+import ch.qos.logback.classic.turbo.TurboFilter;
 import ch.qos.logback.classic.util.Constants;
 import ch.qos.logback.core.appender.ListAppender;
 import ch.qos.logback.core.joran.spi.JoranException;
@@ -78,6 +81,32 @@
     logger.debug(msg);
   }
   
+  public void testTurboFilter() throws JoranException {
+    JoranConfigurator jc = new JoranConfigurator();
+    LoggerContext loggerContext = new LoggerContext();
+    jc.setContext(loggerContext);
+    jc.doConfigure(Constants.TEST_DIR_PREFIX + "input/joran/turbo.xml");
+
+    StatusPrinter.print(loggerContext.getStatusManager());
+    
+    TurboFilter filter = loggerContext.getFirstTurboFilter();
+    assertTrue(filter instanceof NOPTurboFilter);
+  }
+  
+  public void testTurboFilterWithStringList() throws JoranException {
+    JoranConfigurator jc = new JoranConfigurator();
+    LoggerContext loggerContext = new LoggerContext();
+    jc.setContext(loggerContext);
+    jc.doConfigure(Constants.TEST_DIR_PREFIX + "input/joran/turbo2.xml");
+
+    StatusPrinter.print(loggerContext.getStatusManager());
+    
+    TurboFilter filter = loggerContext.getFirstTurboFilter();
+    assertTrue(filter instanceof DebugUsersTurboFilter);
+    DebugUsersTurboFilter dutf = (DebugUsersTurboFilter)filter;
+    assertEquals(2, dutf.getUsers().size());
+  }
+  
   
   // COMMENTED_OUT_
   public static Test COMMENTED_OUT_suite() {
@@ -87,8 +116,5 @@
     //suite.addTest(new BasicJoranTest("testSimpleList"));
 
     return suite;
-  }
-  
-  
-  
+  } 
 }



More information about the logback-dev mailing list