[logback-dev] svn commit: r2131 - in logback/trunk: logback-access/src/main/java/ch/qos/logback/access/joran logback-access/src/test/input/joran logback-access/src/test/java/ch/qos/logback/access logback-access/src/test/java/ch/qos/logback/access/db logback-access/src/test/java/ch/qos/logback/access/joran logback-classic/src/main/java/ch/qos/logback/classic/joran logback-classic/src/main/java/ch/qos/logback/classic/sift logback-classic/src/main/java/ch/qos/logback/classic/util logback-classic/src/test/input/joran logback-classic/src/test/input/joran/conversionRule logback-classic/src/test/input/joran/sift logback-classic/src/test/java/ch/qos/logback/classic logback-classic/src/test/java/ch/qos/logback/classic/html logback-classic/src/test/java/ch/qos/logback/classic/joran logback-classic/src/test/java/ch/qos/logback/classic/sift logback-classic/src/test/java/ch/qos/logback/classic/testUtil logback-core/src/test/java/ch/qos/logback/core/appender logback-core/src/test/java/ch/qos/lo gback/core/joran/spi logback-core/src/test/java/ch/qos/logback/core/rolling logback-core/src/test/java/ch/qos/logback/core/rolling/helper logback-core/src/test/java/ch/qos/logback/core/testUtil

noreply.ceki at qos.ch noreply.ceki at qos.ch
Fri Jan 23 14:56:31 CET 2009


Author: ceki
Date: Fri Jan 23 14:56:31 2009
New Revision: 2131

Added:
   logback/trunk/logback-access/src/test/input/joran/
   logback/trunk/logback-access/src/test/input/joran/defaultLayout.xml
   logback/trunk/logback-access/src/test/input/joran/smoke.xml
   logback/trunk/logback-access/src/test/java/ch/qos/logback/access/TeztConstants.java
   logback/trunk/logback-access/src/test/java/ch/qos/logback/access/joran/
   logback/trunk/logback-access/src/test/java/ch/qos/logback/access/joran/JoranConfiguratorTest.java
   logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/util/DefaultNestedComponentRules.java
   logback/trunk/logback-classic/src/test/input/joran/sift/defaultLayoutRule.xml
   logback/trunk/logback-core/src/test/java/ch/qos/logback/core/testUtil/StringListAppender.java
Removed:
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/testUtil/StringListAppender.java
Modified:
   logback/trunk/logback-access/src/main/java/ch/qos/logback/access/joran/JoranConfigurator.java
   logback/trunk/logback-access/src/test/java/ch/qos/logback/access/db/DBAppenderIntegrationTest.java
   logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/JoranConfigurator.java
   logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/sift/SiftingJoranConfigurator.java
   logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/util/StatusListenerConfigHelper.java
   logback/trunk/logback-classic/src/test/input/joran/callerData.xml
   logback/trunk/logback-classic/src/test/input/joran/conversionRule/htmlLayout0.xml
   logback/trunk/logback-classic/src/test/input/joran/conversionRule/patternLayout0.xml
   logback/trunk/logback-classic/src/test/input/joran/evaluatorFilter.xml
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/PatternLayoutTest.java
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/html/HTMLLayoutTest.java
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/JoranConfiguratorTest.java
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/sift/SiftingAppenderTest.java
   logback/trunk/logback-core/src/test/java/ch/qos/logback/core/appender/FileAppenderTest.java
   logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/spi/PropertySetterTest.java
   logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingTest.java
   logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/FileNamePatternTest.java

Log:
- Moved StringListAppender from logback-classic/src/test to logback-core/src/test since
  logback-access uses it as well.
  
- Added unit tests in relation with default component class mapping rules in Joran. 
  See also jira issue LBCLASSIC-103


Modified: logback/trunk/logback-access/src/main/java/ch/qos/logback/access/joran/JoranConfigurator.java
==============================================================================
--- logback/trunk/logback-access/src/main/java/ch/qos/logback/access/joran/JoranConfigurator.java	(original)
+++ logback/trunk/logback-access/src/main/java/ch/qos/logback/access/joran/JoranConfigurator.java	Fri Jan 23 14:56:31 2009
@@ -11,12 +11,15 @@
 package ch.qos.logback.access.joran;
 
 
+import ch.qos.logback.access.PatternLayout;
 import ch.qos.logback.access.joran.action.ConfigurationAction;
 import ch.qos.logback.access.joran.action.EvaluatorAction;
 import ch.qos.logback.access.sift.SiftAction;
+import ch.qos.logback.core.AppenderBase;
 import ch.qos.logback.core.joran.JoranConfiguratorBase;
 import ch.qos.logback.core.joran.action.AppenderRefAction;
 import ch.qos.logback.core.joran.action.NOPAction;
+import ch.qos.logback.core.joran.spi.DefaultNestedComponentRegistry;
 import ch.qos.logback.core.joran.spi.Pattern;
 import ch.qos.logback.core.joran.spi.RuleStore;
 
@@ -41,5 +44,10 @@
     rs.addRule(new Pattern("configuration/evaluator"), new EvaluatorAction());
   }
 
+  @Override
+  protected void addDefaultNestedComponentRegistryRules(
+      DefaultNestedComponentRegistry registry) {
+    registry.add(AppenderBase.class, "layout", PatternLayout.class);
+  }
 
 }

Added: logback/trunk/logback-access/src/test/input/joran/defaultLayout.xml
==============================================================================
--- (empty file)
+++ logback/trunk/logback-access/src/test/input/joran/defaultLayout.xml	Fri Jan 23 14:56:31 2009
@@ -0,0 +1,13 @@
+<configuration>
+
+  <appender name="STR_LIST"
+    class="ch.qos.logback.core.testUtil.StringListAppender">
+    <!-- the fact that the layout class is not declared tests default component class
+      mapping rules -->
+    <layout>
+      <Pattern>%requestMethod</Pattern>
+    </layout>
+  </appender>
+  
+  <appender-ref ref="STR_LIST" />
+</configuration>
\ No newline at end of file

Added: logback/trunk/logback-access/src/test/input/joran/smoke.xml
==============================================================================
--- (empty file)
+++ logback/trunk/logback-access/src/test/input/joran/smoke.xml	Fri Jan 23 14:56:31 2009
@@ -0,0 +1,5 @@
+<configuration>
+
+  <appender name="LIST"  class="ch.qos.logback.core.read.ListAppender"/>
+  <appender-ref ref="LIST" />
+</configuration>
\ No newline at end of file

Added: logback/trunk/logback-access/src/test/java/ch/qos/logback/access/TeztConstants.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-access/src/test/java/ch/qos/logback/access/TeztConstants.java	Fri Jan 23 14:56:31 2009
@@ -0,0 +1,6 @@
+package ch.qos.logback.access;
+
+public class TeztConstants {
+ 
+  public static final String TEST_DIR_PREFIX =  "src/test/";
+}

Modified: logback/trunk/logback-access/src/test/java/ch/qos/logback/access/db/DBAppenderIntegrationTest.java
==============================================================================
--- logback/trunk/logback-access/src/test/java/ch/qos/logback/access/db/DBAppenderIntegrationTest.java	(original)
+++ logback/trunk/logback-access/src/test/java/ch/qos/logback/access/db/DBAppenderIntegrationTest.java	Fri Jan 23 14:56:31 2009
@@ -12,9 +12,7 @@
 import org.junit.Ignore;
 import org.junit.Test;
 
-import ch.qos.logback.access.dummy.DummyRequest;
-import ch.qos.logback.access.dummy.DummyResponse;
-import ch.qos.logback.access.dummy.DummyServerAdapter;
+import ch.qos.logback.access.dummy.DummyAccessEventBuilder;
 import ch.qos.logback.access.joran.JoranConfigurator;
 import ch.qos.logback.access.spi.AccessContext;
 import ch.qos.logback.access.spi.AccessEvent;
@@ -59,7 +57,7 @@
     Appender<AccessEvent> appender = context.getAppender("DB");
     
     for (int i = 0; i < 10; i++) {
-      AccessEvent event = createAccessEvent();
+      AccessEvent event = DummyAccessEventBuilder.buildNewAccessEvent();
       appender.doAppend(event);
     }
     
@@ -128,13 +126,4 @@
     doTest("src/test/input/integration/db/postgresql-with-driver.xml");
   }
   
-  private AccessEvent createAccessEvent() {
-    DummyRequest request = new DummyRequest();
-    DummyResponse response = new DummyResponse();
-    DummyServerAdapter adapter = new DummyServerAdapter(request, response);
-
-    AccessEvent ae = new AccessEvent(request, response, adapter);
-    return ae;
-  }
-  
 }

Added: logback/trunk/logback-access/src/test/java/ch/qos/logback/access/joran/JoranConfiguratorTest.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-access/src/test/java/ch/qos/logback/access/joran/JoranConfiguratorTest.java	Fri Jan 23 14:56:31 2009
@@ -0,0 +1,73 @@
+/**
+ * Logback: the generic, reliable, fast and flexible logging framework.
+ * 
+ * Copyright (C) 2000-2009, QOS.ch
+ * 
+ * This library is free software, you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation.
+ */
+package ch.qos.logback.access.joran;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import ch.qos.logback.access.TeztConstants;
+import ch.qos.logback.access.dummy.DummyAccessEventBuilder;
+import ch.qos.logback.access.spi.AccessContext;
+import ch.qos.logback.access.spi.AccessEvent;
+import ch.qos.logback.core.joran.spi.JoranException;
+import ch.qos.logback.core.read.ListAppender;
+import ch.qos.logback.core.testUtil.StringListAppender;
+
+public class JoranConfiguratorTest {
+
+  AccessContext context = new AccessContext();
+
+  @Before
+  public void setUp() throws Exception {
+  }
+
+  @After
+  public void tearDown() throws Exception {
+  }
+
+  void configure(String file) throws JoranException {
+    JoranConfigurator jc = new JoranConfigurator();
+    jc.setContext(context);
+    jc.doConfigure(file);
+  }
+
+  @Test
+  public void smoke() throws Exception {
+    configure(TeztConstants.TEST_DIR_PREFIX + "input/joran/smoke.xml");
+
+    ListAppender<AccessEvent> listAppender = (ListAppender<AccessEvent>) context
+        .getAppender("LIST");
+    AccessEvent event = DummyAccessEventBuilder.buildNewAccessEvent();
+    listAppender.doAppend(event);
+
+    assertEquals(1, listAppender.list.size());
+
+    assertEquals(1, listAppender.list.size());
+    AccessEvent ae = (AccessEvent) listAppender.list.get(0);
+    assertNotNull(ae);
+  }
+
+  @Test
+  public void defaultLayout() throws Exception {
+    configure(TeztConstants.TEST_DIR_PREFIX + "input/joran/defaultLayout.xml");
+    StringListAppender<AccessEvent> listAppender = (StringListAppender<AccessEvent>) context
+        .getAppender("STR_LIST");
+    AccessEvent event = DummyAccessEventBuilder.buildNewAccessEvent();
+    listAppender.doAppend(event);
+    assertEquals(1, listAppender.strList.size());
+    // the result contains a line separator at the end
+    assertTrue(listAppender.strList.get(0).startsWith("testMethod"));
+  }
+}

Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/JoranConfigurator.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/JoranConfigurator.java	(original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/JoranConfigurator.java	Fri Jan 23 14:56:31 2009
@@ -10,8 +10,6 @@
 
 package ch.qos.logback.classic.joran;
 
-import ch.qos.logback.classic.PatternLayout;
-import ch.qos.logback.classic.boolex.JaninoEventEvaluator;
 import ch.qos.logback.classic.joran.action.ConfigurationAction;
 import ch.qos.logback.classic.joran.action.ConsolePluginAction;
 import ch.qos.logback.classic.joran.action.ContextNameAction;
@@ -23,8 +21,7 @@
 import ch.qos.logback.classic.joran.action.RootLoggerAction;
 import ch.qos.logback.classic.sift.SiftAction;
 import ch.qos.logback.classic.spi.PlatformInfo;
-import ch.qos.logback.core.AppenderBase;
-import ch.qos.logback.core.filter.EvaluatorFilter;
+import ch.qos.logback.classic.util.DefaultNestedComponentRules;
 import ch.qos.logback.core.joran.JoranConfiguratorBase;
 import ch.qos.logback.core.joran.action.AppenderRefAction;
 import ch.qos.logback.core.joran.action.IncludeAction;
@@ -89,10 +86,7 @@
   @Override
   protected void addDefaultNestedComponentRegistryRules(
       DefaultNestedComponentRegistry registry) {
-    registry.add(AppenderBase.class, "layout", PatternLayout.class);
-    registry
-        .add(EvaluatorFilter.class, "evaluator", JaninoEventEvaluator.class);
-
+    DefaultNestedComponentRules.addDefaultNestedComponentRegistryRules(registry);
   }
 
 }

Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/sift/SiftingJoranConfigurator.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/sift/SiftingJoranConfigurator.java	(original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/sift/SiftingJoranConfigurator.java	Fri Jan 23 14:56:31 2009
@@ -1,3 +1,12 @@
+/**
+ * Logback: the generic, reliable, fast and flexible logging framework.
+ * 
+ * Copyright (C) 2000-2009, QOS.ch
+ * 
+ * This library is free software, you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation.
+ */
 package ch.qos.logback.classic.sift;
 
 import java.util.Collection;
@@ -5,9 +14,11 @@
 import java.util.Map;
 
 import ch.qos.logback.classic.spi.LoggingEvent;
+import ch.qos.logback.classic.util.DefaultNestedComponentRules;
 import ch.qos.logback.core.Appender;
 import ch.qos.logback.core.joran.action.ActionConst;
 import ch.qos.logback.core.joran.action.AppenderAction;
+import ch.qos.logback.core.joran.spi.DefaultNestedComponentRegistry;
 import ch.qos.logback.core.joran.spi.Pattern;
 import ch.qos.logback.core.joran.spi.RuleStore;
 import ch.qos.logback.core.sift.SiftingJoranConfiguratorBase;
@@ -32,6 +43,13 @@
     rs.addRule(new Pattern("configuration/appender"), new AppenderAction());
   }
 
+
+  @Override
+  protected void addDefaultNestedComponentRegistryRules(
+      DefaultNestedComponentRegistry registry) {
+    DefaultNestedComponentRules.addDefaultNestedComponentRegistryRules(registry);
+  }
+    
   @Override
   protected void buildInterpreter() {
     super.buildInterpreter();

Added: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/util/DefaultNestedComponentRules.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/util/DefaultNestedComponentRules.java	Fri Jan 23 14:56:31 2009
@@ -0,0 +1,37 @@
+/**
+ * Logback: the generic, reliable, fast and flexible logging framework.
+ * 
+ * Copyright (C) 2000-2009, QOS.ch
+ * 
+ * This library is free software, you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation.
+ */
+package ch.qos.logback.classic.util;
+
+import ch.qos.logback.classic.PatternLayout;
+import ch.qos.logback.classic.boolex.JaninoEventEvaluator;
+import ch.qos.logback.core.AppenderBase;
+import ch.qos.logback.core.filter.EvaluatorFilter;
+import ch.qos.logback.core.joran.spi.DefaultNestedComponentRegistry;
+
+/**
+ * Contains mappings for the default type of nested components in
+ * logback-classic.
+ * 
+ * @author Ceki Gulcu
+ * 
+ */
+public class DefaultNestedComponentRules {
+
+  static public void addDefaultNestedComponentRegistryRules(
+      DefaultNestedComponentRegistry registry) {
+    // if you modify the rules here, then do not forget to modify
+    // SiftingJoranConfigurator as well.
+    registry.add(AppenderBase.class, "layout", PatternLayout.class);
+    registry
+        .add(EvaluatorFilter.class, "evaluator", JaninoEventEvaluator.class);
+
+  }
+
+}

Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/util/StatusListenerConfigHelper.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/util/StatusListenerConfigHelper.java	(original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/util/StatusListenerConfigHelper.java	Fri Jan 23 14:56:31 2009
@@ -1,3 +1,12 @@
+/**
+ * Logback: the generic, reliable, fast and flexible logging framework.
+ * 
+ * Copyright (C) 2000-2009, QOS.ch
+ * 
+ * This library is free software, you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation.
+ */
 package ch.qos.logback.classic.util;
 
 import ch.qos.logback.classic.LoggerContext;

Modified: logback/trunk/logback-classic/src/test/input/joran/callerData.xml
==============================================================================
--- logback/trunk/logback-classic/src/test/input/joran/callerData.xml	(original)
+++ logback/trunk/logback-classic/src/test/input/joran/callerData.xml	Fri Jan 23 14:56:31 2009
@@ -9,21 +9,23 @@
       <name>m</name>
       <regex>^hello.*</regex>
       <CaseSensitive>false</CaseSensitive>
-    </matcher>  
+    </matcher>
   </evaluator>
 
-  <appender name="STR_LIST" class="ch.qos.logback.classic.testUtil.StringListAppender">
-    <layout class="ch.qos.logback.classic.PatternLayout">
+  <appender name="STR_LIST"
+    class="ch.qos.logback.core.testUtil.StringListAppender">
+    <!-- the fact that the layout class is not declared tests default component class
+      mapping rules -->
+    <layout>
       <Pattern>%caller{4, helloEval}%d %level - %m%n</Pattern>
     </layout>
   </appender>
-  
+
   <root>
     <level value="DEBUG" />
     <appender-ref ref="STR_LIST" />
   </root>
-  
-  
-  
+
+
+
 </configuration>
-  
\ No newline at end of file

Modified: logback/trunk/logback-classic/src/test/input/joran/conversionRule/htmlLayout0.xml
==============================================================================
--- logback/trunk/logback-classic/src/test/input/joran/conversionRule/htmlLayout0.xml	(original)
+++ logback/trunk/logback-classic/src/test/input/joran/conversionRule/htmlLayout0.xml	Fri Jan 23 14:56:31 2009
@@ -3,7 +3,7 @@
   <conversionRule conversionWord="sample"
     converterClass="ch.qos.logback.classic.testUtil.SampleConverter" />
 
-  <appender name="LIST" class="ch.qos.logback.classic.testUtil.StringListAppender">
+  <appender name="LIST" class="ch.qos.logback.core.testUtil.StringListAppender">
     <layout class="ch.qos.logback.classic.html.HTMLLayout">
       <Pattern>%sample%msg</Pattern>
     </layout>

Modified: logback/trunk/logback-classic/src/test/input/joran/conversionRule/patternLayout0.xml
==============================================================================
--- logback/trunk/logback-classic/src/test/input/joran/conversionRule/patternLayout0.xml	(original)
+++ logback/trunk/logback-classic/src/test/input/joran/conversionRule/patternLayout0.xml	Fri Jan 23 14:56:31 2009
@@ -3,7 +3,7 @@
   <conversionRule conversionWord="sample"
     converterClass="ch.qos.logback.classic.testUtil.SampleConverter" />
 
-  <appender name="LIST" class="ch.qos.logback.classic.testUtil.StringListAppender">
+  <appender name="LIST" class="ch.qos.logback.core.testUtil.StringListAppender">
     <layout class="ch.qos.logback.classic.PatternLayout">
       <Pattern>%sample - %msg</Pattern>
     </layout>

Modified: logback/trunk/logback-classic/src/test/input/joran/evaluatorFilter.xml
==============================================================================
--- logback/trunk/logback-classic/src/test/input/joran/evaluatorFilter.xml	(original)
+++ logback/trunk/logback-classic/src/test/input/joran/evaluatorFilter.xml	Fri Jan 23 14:56:31 2009
@@ -6,7 +6,7 @@
     <filter class="ch.qos.logback.core.filter.EvaluatorFilter">
       <Name>myFilter</Name>
       <OnMatch>DENY</OnMatch>
-      <Evaluator class="ch.qos.logback.classic.boolex.JaninoEventEvaluator">
+      <Evaluator>
         <Name>mdcEvaluator</Name>
         <Expression>"to be ignored".equals(message)</Expression>
       </Evaluator>

Added: logback/trunk/logback-classic/src/test/input/joran/sift/defaultLayoutRule.xml
==============================================================================
--- (empty file)
+++ logback/trunk/logback-classic/src/test/input/joran/sift/defaultLayoutRule.xml	Fri Jan 23 14:56:31 2009
@@ -0,0 +1,23 @@
+<configuration debug="true">
+
+  <appender name="SIFT" class="ch.qos.logback.classic.sift.SiftingAppender">
+
+    <discriminator>
+      <Key>userid</Key>
+      <defaultValue>default</defaultValue>
+    </discriminator>
+    <sift>
+      <appender name="LIST-${userid}"
+        class="ch.qos.logback.core.testUtil.StringListAppender">
+        <layout>
+          <Pattern>%level %msg</Pattern>
+        </layout>
+      </appender>
+    </sift>
+  </appender>
+
+  <root level="DEBUG">
+    <appender-ref ref="SIFT" />
+  </root>
+
+</configuration>

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/PatternLayoutTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/PatternLayoutTest.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/PatternLayoutTest.java	Fri Jan 23 14:56:31 2009
@@ -25,12 +25,12 @@
 import ch.qos.logback.classic.pattern.ConverterTest;
 import ch.qos.logback.classic.spi.LoggingEvent;
 import ch.qos.logback.classic.testUtil.SampleConverter;
-import ch.qos.logback.classic.testUtil.StringListAppender;
 import ch.qos.logback.classic.util.TeztConstants;
 import ch.qos.logback.core.Context;
 import ch.qos.logback.core.joran.spi.JoranException;
 import ch.qos.logback.core.pattern.PatternLayoutBase;
 import ch.qos.logback.core.pattern.parser.AbstractPatternLayoutBaseTest;
+import ch.qos.logback.core.testUtil.StringListAppender;
 
 public class PatternLayoutTest extends AbstractPatternLayoutBaseTest {
 

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/html/HTMLLayoutTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/html/HTMLLayoutTest.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/html/HTMLLayoutTest.java	Fri Jan 23 14:56:31 2009
@@ -25,11 +25,12 @@
 import ch.qos.logback.classic.spi.LoggingEvent;
 import ch.qos.logback.classic.spi.ThrowableDataPoint;
 import ch.qos.logback.classic.spi.ThrowableProxy;
-import ch.qos.logback.classic.testUtil.StringListAppender;
 import ch.qos.logback.classic.util.TeztConstants;
 import ch.qos.logback.core.CoreConstants;
 import ch.qos.logback.core.joran.spi.JoranException;
 import ch.qos.logback.core.read.ListAppender;
+import ch.qos.logback.core.testUtil.StringListAppender;
+import ch.qos.logback.core.util.StatusPrinter;
 
 public class HTMLLayoutTest {
 
@@ -217,11 +218,14 @@
   public void testConversionRuleSupportInHtmlLayout() throws JoranException {
     configure(TeztConstants.TEST_DIR_PREFIX
         + "input/joran/conversionRule/htmlLayout0.xml");
+   
     root.getAppender("LIST");
     String msg = "Simon says";
     root.debug(msg);
-    StringListAppender sla = (StringListAppender) root.getAppender("LIST");
+    StringListAppender<LoggingEvent> sla = (StringListAppender<LoggingEvent>) root
+        .getAppender("LIST");
     assertNotNull(sla);
+    StatusPrinter.print(lc);
     assertEquals(1, sla.strList.size());
     assertFalse(sla.strList.get(0).contains("PARSER_ERROR"));
   }

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/JoranConfiguratorTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/JoranConfiguratorTest.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/JoranConfiguratorTest.java	Fri Jan 23 14:56:31 2009
@@ -20,7 +20,6 @@
 import ch.qos.logback.classic.Logger;
 import ch.qos.logback.classic.LoggerContext;
 import ch.qos.logback.classic.spi.LoggingEvent;
-import ch.qos.logback.classic.testUtil.StringListAppender;
 import ch.qos.logback.classic.turbo.DebugUsersTurboFilter;
 import ch.qos.logback.classic.turbo.NOPTurboFilter;
 import ch.qos.logback.classic.turbo.TurboFilter;
@@ -28,7 +27,7 @@
 import ch.qos.logback.core.CoreConstants;
 import ch.qos.logback.core.joran.spi.JoranException;
 import ch.qos.logback.core.read.ListAppender;
-import ch.qos.logback.core.util.StatusPrinter;
+import ch.qos.logback.core.testUtil.StringListAppender;
 
 public class JoranConfiguratorTest {
 
@@ -73,7 +72,7 @@
    
     System.setProperty(propertyName, "INFO");
     configure(TeztConstants.TEST_DIR_PREFIX + "input/joran/rootLevelByProperty.xml");
-    StatusPrinter.print(loggerContext);
+    //StatusPrinter.print(loggerContext);
     ListAppender listAppender = (ListAppender) root.getAppender("LIST");
     assertEquals(0, listAppender.list.size());
     String msg = "hello world";
@@ -88,7 +87,7 @@
    
     System.setProperty(propertyName, "DEBUG");
     configure(TeztConstants.TEST_DIR_PREFIX + "input/joran/loggerLevelByProperty.xml");
-    StatusPrinter.print(loggerContext);
+    //StatusPrinter.print(loggerContext);
     ListAppender listAppender = (ListAppender) root.getAppender("LIST");
     assertEquals(0, listAppender.list.size());
     String msg = "hello world";
@@ -100,7 +99,7 @@
   @Test
   public void testStatusListener() throws JoranException {
     configure(TeztConstants.TEST_DIR_PREFIX + "input/joran/statusListener.xml");
-    StatusPrinter.print(loggerContext);
+    //StatusPrinter.print(loggerContext);
   }
 
   @Test
@@ -118,12 +117,12 @@
     logger.debug("toto");
     logger.debug(msg);
 
-    StringListAppender slAppender = (StringListAppender) loggerContext
+    StringListAppender<LoggingEvent> slAppender = (StringListAppender<LoggingEvent>) loggerContext
         .getLogger("root").getAppender("STR_LIST");
     assertNotNull(slAppender);
     assertEquals(2, slAppender.strList.size());
     assertTrue(slAppender.strList.get(0).contains(" DEBUG - toto"));
-
+    
     String str1 = slAppender.strList.get(1);
     assertTrue(str1.contains("Caller+0"));
     assertTrue(str1.contains(" DEBUG - hello world"));
@@ -160,7 +159,7 @@
   public void testLevelFilter() throws JoranException {
     configure(TeztConstants.TEST_DIR_PREFIX + "input/joran/levelFilter.xml");
 
-    StatusPrinter.print(loggerContext);
+    //StatusPrinter.print(loggerContext);
 
     logger.warn("hello");
     logger.error("to be ignored");
@@ -180,7 +179,7 @@
   public void testEvaluatorFilter() throws JoranException {
     configure(TeztConstants.TEST_DIR_PREFIX + "input/joran/evaluatorFilter.xml");
 
-    StatusPrinter.print(loggerContext);
+    //StatusPrinter.print(loggerContext);
 
     logger.warn("hello");
     logger.error("to be ignored");

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/sift/SiftingAppenderTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/sift/SiftingAppenderTest.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/sift/SiftingAppenderTest.java	Fri Jan 23 14:56:31 2009
@@ -27,12 +27,13 @@
 import ch.qos.logback.core.joran.spi.JoranException;
 import ch.qos.logback.core.read.ListAppender;
 import ch.qos.logback.core.sift.AppenderTracker;
+import ch.qos.logback.core.testUtil.StringListAppender;
 import ch.qos.logback.core.util.StatusPrinter;
 
 public class SiftingAppenderTest {
 
   static String PREFIX = TeztConstants.TEST_DIR_PREFIX + "input/joran/sift/";
-  		
+
   LoggerContext loggerContext = new LoggerContext();
   Logger logger = loggerContext.getLogger(this.getClass().getName());
   Logger root = loggerContext.getLogger(LoggerContext.ROOT_NAME);
@@ -57,8 +58,9 @@
     logger.debug("smoke");
     long timestamp = 0;
     SiftingAppender ha = (SiftingAppender) root.getAppender("SIFT");
-    ListAppender<LoggingEvent> listAppender = (ListAppender<LoggingEvent>) ha.getAppenderTracker().get("smoke", timestamp);
-    
+    ListAppender<LoggingEvent> listAppender = (ListAppender<LoggingEvent>) ha
+        .getAppenderTracker().get("smoke", timestamp);
+
     StatusPrinter.print(loggerContext);
     assertNotNull(listAppender);
     List<LoggingEvent> eventList = listAppender.list;
@@ -67,6 +69,22 @@
   }
 
   @Test
+  public void defaultLayoutRule() throws JoranException {
+    configure(PREFIX + "defaultLayoutRule.xml");
+    logger.debug("hello");
+    long timestamp = 0;
+    SiftingAppender ha = (SiftingAppender) root.getAppender("SIFT");
+    StringListAppender<LoggingEvent> listAppender = (StringListAppender<LoggingEvent>) ha
+        .getAppenderTracker().get("default", timestamp);
+
+    StatusPrinter.print(loggerContext);
+    assertNotNull(listAppender);
+    List<String> strList = listAppender.strList;
+    assertEquals(1, strList.size());
+    assertEquals("DEBUG hello", strList.get(0));
+  }
+
+  @Test
   public void testWholeCycle() throws JoranException {
     String mdcKey = "cycle";
     configure(PREFIX + "completeCycle.xml");
@@ -74,21 +92,22 @@
     logger.debug("smoke");
     long timestamp = System.currentTimeMillis();
     SiftingAppender ha = (SiftingAppender) root.getAppender("SIFT");
-    ListAppender<LoggingEvent> listAppender = (ListAppender<LoggingEvent>) ha.getAppenderTracker().get("a", timestamp);
+    ListAppender<LoggingEvent> listAppender = (ListAppender<LoggingEvent>) ha
+        .getAppenderTracker().get("a", timestamp);
     StatusPrinter.print(loggerContext);
-    
+
     assertNotNull(listAppender);
     List<LoggingEvent> eventList = listAppender.list;
     assertEquals(1, listAppender.list.size());
     assertEquals("smoke", eventList.get(0).getMessage());
 
     MDC.remove(mdcKey);
-    LoggingEvent le = new LoggingEvent("x", logger, Level.INFO, "hello", null, null);
-    le.setTimeStamp(timestamp+AppenderTracker.THRESHOLD*2);
+    LoggingEvent le = new LoggingEvent("x", logger, Level.INFO, "hello", null,
+        null);
+    le.setTimeStamp(timestamp + AppenderTracker.THRESHOLD * 2);
     ha.doAppend(le);
     assertFalse(listAppender.isStarted());
     assertEquals(1, ha.getAppenderTracker().keyList().size());
     assertEquals("cycleDefault", ha.getAppenderTracker().keyList().get(0));
-    
   }
 }

Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/appender/FileAppenderTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/appender/FileAppenderTest.java	(original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/appender/FileAppenderTest.java	Fri Jan 23 14:56:31 2009
@@ -29,7 +29,6 @@
 import ch.qos.logback.core.status.StatusManager;
 import ch.qos.logback.core.util.Constants;
 import ch.qos.logback.core.util.FileUtil;
-import ch.qos.logback.core.util.StatusPrinter;
 
 public class FileAppenderTest extends AbstractAppenderTest<Object> {
 
@@ -121,8 +120,7 @@
 
     assertTrue("Got message [" + msg1 + "]", msg1
         .startsWith("Setting \"Append\" property"));
-    StatusPrinter.print(context);
-
+    
     appender.doAppend(new Object());
     appender.stop();
     assertTrue(file.exists());

Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/spi/PropertySetterTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/spi/PropertySetterTest.java	(original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/spi/PropertySetterTest.java	Fri Jan 23 14:56:31 2009
@@ -16,7 +16,6 @@
 import ch.qos.logback.core.util.AggregationType;
 import ch.qos.logback.core.util.Duration;
 import ch.qos.logback.core.util.FileSize;
-import ch.qos.logback.core.util.StatusPrinter;
 
 public class PropertySetterTest {
 
@@ -137,7 +136,7 @@
     setter.setContext(context);
     setter.addBasicProperty("adjective", "nice");
     setter.addBasicProperty("adjective", "big");
-    StatusPrinter.print(context);
+   
     assertEquals(2, house.adjectiveList.size());
     assertEquals("nice", house.adjectiveList.get(0));
     assertEquals("big", house.adjectiveList.get(1));

Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingTest.java	(original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingTest.java	Fri Jan 23 14:56:31 2009
@@ -29,7 +29,6 @@
 import ch.qos.logback.core.layout.EchoLayout;
 import ch.qos.logback.core.util.Compare;
 import ch.qos.logback.core.util.Constants;
-import ch.qos.logback.core.util.StatusPrinter;
 
 /**
  * A rather exhaustive set of tests. Tests include leaving the file option
@@ -141,9 +140,6 @@
       tbrp1.setCurrentTime(currentTime);
     }
 
-    StatusPrinter.print(context);
-    //System.out.println(expectedFilenameList);
-
     int i = 0;
     for (String fn : expectedFilenameList) {
       assertTrue(Compare.compare(fn, Constants.TEST_DIR_PREFIX

Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/FileNamePatternTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/FileNamePatternTest.java	(original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/FileNamePatternTest.java	Fri Jan 23 14:56:31 2009
@@ -1,7 +1,7 @@
 /**
- * LOGBack: the reliable, fast and flexible logging library for Java.
+ * Logback: the generic, reliable, fast and flexible logging framework.
  * 
- * Copyright (C) 1999-2006, QOS.ch
+ * Copyright (C) 2000-2009, QOS.ch
  * 
  * This library is free software, you can redistribute it and/or modify it under
  * the terms of the GNU Lesser General Public License as published by the Free
@@ -18,7 +18,6 @@
 
 import ch.qos.logback.core.Context;
 import ch.qos.logback.core.ContextBase;
-import ch.qos.logback.core.util.StatusPrinter;
 
 /**
  * @author Ceki
@@ -44,7 +43,7 @@
     // assertEquals("foo%", pp.convertInt(3));
 
     pp = new FileNamePattern("%i foo", context);
-    StatusPrinter.print(context.getStatusManager());
+    
     assertEquals("3 foo", pp.convertInt(3));
 
     pp = new FileNamePattern("foo%i.xixo", context);
@@ -84,7 +83,7 @@
     cal.set(2003, 4, 20, 17, 55);
 
     FileNamePattern pp = new FileNamePattern("foo%d{yyyy.MM.dd}", context);
-    StatusPrinter.print(context.getStatusManager());
+    
     assertEquals("foo2003.05.20", pp.convertDate(cal.getTime()));
 
     pp = new FileNamePattern("foo%d{yyyy.MM.dd HH:mm}", context);

Added: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/testUtil/StringListAppender.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/testUtil/StringListAppender.java	Fri Jan 23 14:56:31 2009
@@ -0,0 +1,46 @@
+package ch.qos.logback.core.testUtil;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import ch.qos.logback.core.AppenderBase;
+import ch.qos.logback.core.Layout;
+
+public class StringListAppender<E> extends AppenderBase<E> {
+
+  Layout<E> layout;
+  public List<String> strList = new ArrayList<String>();
+
+  public StringListAppender() {
+
+  }
+
+  public void start() {
+    strList.clear();
+
+    if (layout == null || !layout.isStarted()) {
+      return;
+    }
+    super.start();
+  }
+
+  public void stop() {
+    super.stop();
+  }
+
+  @Override
+  protected void append(E eventObject) {
+    String res = layout.doLayout(eventObject);
+    strList.add(res);
+  }
+
+  @Override
+  public Layout<E> getLayout() {
+    return layout;
+  }
+
+  @Override
+  public void setLayout(Layout<E> layout) {
+    this.layout = layout;
+  }
+}


More information about the logback-dev mailing list