[logback-dev] svn commit: r956 - in logback/trunk/logback-classic/src/test: input/joran java/ch/qos/logback/classic java/ch/qos/logback/classic/boolex java/ch/qos/logback/classic/control java/ch/qos/logback/classic/joran java/ch/qos/logback/classic/net java/ch/qos/logback/classic/pattern

noreply.ceki at qos.ch noreply.ceki at qos.ch
Fri Nov 17 18:35:05 CET 2006


Author: ceki
Date: Fri Nov 17 18:35:05 2006
New Revision: 956

Added:
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/StringListAppender.java
Modified:
   logback/trunk/logback-classic/src/test/input/joran/callerData.xml
   logback/trunk/logback-classic/src/test/input/joran/ignore.xml
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/boolex/JaninoEventEvaluatorTest.java
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/RandomUtilTest.java
   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/EvaluatorJoranTest.java
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SyslogAppenderTest.java
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ConverterTest.java

Log:
less noise when testing

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 Nov 17 18:35:05 2006
@@ -11,7 +11,7 @@
     </matcher>  
   </evaluator>
 
-  <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
+  <appender name="STR_LIST" class="ch.qos.logback.classic.StringListAppender">
     <layout class="ch.qos.logback.classic.PatternLayout">
       <Pattern>%caller{4, helloEval}%d %level - %m%n</Pattern>
     </layout>
@@ -19,7 +19,7 @@
   
   <root>
     <level value="DEBUG" />
-    <appender-ref ref="CONSOLE" />
+    <appender-ref ref="STR_LIST" />
   </root>
   
   

Modified: logback/trunk/logback-classic/src/test/input/joran/ignore.xml
==============================================================================
--- logback/trunk/logback-classic/src/test/input/joran/ignore.xml	(original)
+++ logback/trunk/logback-classic/src/test/input/joran/ignore.xml	Fri Nov 17 18:35:05 2006
@@ -6,7 +6,7 @@
    <Expression>(marker.contains("IGNORE"))</Expression>
   </evaluator>
 
- <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
+ <appender name="LIST" class="ch.qos.logback.core.read.ListAppender">
     <layout class="ch.qos.logback.classic.PatternLayout">
       <Pattern>%date %level - %m%n%ex{full, IGNORE_EVAL}</Pattern>
     </layout>

Added: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/StringListAppender.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/StringListAppender.java	Fri Nov 17 18:35:05 2006
@@ -0,0 +1,44 @@
+package ch.qos.logback.classic;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import ch.qos.logback.classic.spi.LoggingEvent;
+import ch.qos.logback.core.AppenderBase;
+import ch.qos.logback.core.Layout;
+
+public class StringListAppender extends AppenderBase {
+
+  Layout layout;
+  public List<String> strList = new ArrayList<String>();
+
+  public void start() {
+    strList.clear();
+    
+    if (layout == null || !layout.isStarted()) {
+      return;
+    }
+    super.start();
+  }
+
+  public void stop() {
+    super.stop();
+  }
+
+  @Override
+  protected void append(Object eventObject) {
+    LoggingEvent le = (LoggingEvent) eventObject;
+    String res = layout.doLayout(le);
+    strList.add(res);
+  }
+
+  public Layout getLayout() {
+    return layout;
+  }
+
+  public void setLayout(Layout layout) {
+    this.layout = layout;
+
+  }
+
+}

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/boolex/JaninoEventEvaluatorTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/boolex/JaninoEventEvaluatorTest.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/boolex/JaninoEventEvaluatorTest.java	Fri Nov 17 18:35:05 2006
@@ -43,7 +43,7 @@
     jee.start();
 
     LoggingEvent event = makeLoggingEvent(null);
-    System.out.println(event);
+    //System.out.println(event);
     assertTrue(jee.evaluate(event));
   }
 
@@ -54,7 +54,7 @@
     jee.start();
 
     LoggingEvent event = makeLoggingEvent(null);
-    System.out.println(event);
+    //System.out.println(event);
     assertTrue(jee.evaluate(event));
   }
 
@@ -182,7 +182,7 @@
       jee.evaluate(event);
     }
     final long end = System.nanoTime();
-    System.out.println(msg + (end - start) / LEN + " nanos");
+    //System.out.println(msg + (end - start) / LEN + " nanos");
   }
 
   public void testLoop1() throws Exception {

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/RandomUtilTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/RandomUtilTest.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/RandomUtilTest.java	Fri Nov 17 18:35:05 2006
@@ -24,7 +24,7 @@
     }
 
     double resultingAverage =   sum/(1.0*len);
-    System.out.println("Resulting average is "+resultingAverage);
+    //System.out.println("Resulting average is "+resultingAverage);
 
     assertTrue("Expected "+AVERAGE+" but got "+resultingAverage, Math.abs(resultingAverage-AVERAGE)<0.1);
   }

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	Fri Nov 17 18:35:05 2006
@@ -14,6 +14,7 @@
 import junit.framework.TestSuite;
 import ch.qos.logback.classic.Logger;
 import ch.qos.logback.classic.LoggerContext;
+import ch.qos.logback.classic.StringListAppender;
 import ch.qos.logback.classic.spi.LoggingEvent;
 import ch.qos.logback.classic.turbo.DebugUsersTurboFilter;
 import ch.qos.logback.classic.turbo.NOPTurboFilter;
@@ -72,12 +73,19 @@
     jc.setContext(loggerContext);
     jc.doConfigure(Constants.TEST_DIR_PREFIX + "input/joran/callerData.xml");
 
-    //StatusPrinter.print(loggerContext.getStatusManager());
-  
     Logger logger = loggerContext.getLogger(this.getClass().getName());
     String msg = "hello world";
     logger.debug("toto");
     logger.debug(msg);
+    
+    StringListAppender slAppender = (StringListAppender) 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"));
   }
   
   public void testTurboFilter() throws JoranException {

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/EvaluatorJoranTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/EvaluatorJoranTest.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/EvaluatorJoranTest.java	Fri Nov 17 18:35:05 2006
@@ -25,7 +25,6 @@
 import ch.qos.logback.core.CoreGlobal;
 import ch.qos.logback.core.boolex.EvaluationException;
 import ch.qos.logback.core.joran.spi.JoranException;
-import ch.qos.logback.core.util.StatusPrinter;
 
 
 public class EvaluatorJoranTest extends TestCase {
@@ -45,7 +44,7 @@
     
     Logger logger = loggerContext.getLogger("xx");
     LoggingEvent event = new LoggingEvent("foo", logger, Level.DEBUG, "Hello world", null, null);
-    StatusPrinter.print(loggerContext.getStatusManager());
+    //StatusPrinter.print(loggerContext.getStatusManager());
     assertTrue(evaluator.evaluate(event));
     
     //StatusPrinter.print(loggerContext.getStatusManager());
@@ -57,17 +56,17 @@
     jc.setContext(loggerContext);
     jc.doConfigure(Constants.TEST_DIR_PREFIX + "input/joran/ignore.xml");
     
-    StatusPrinter.print(loggerContext.getStatusManager());
+    //StatusPrinter.print(loggerContext.getStatusManager());
     
     Map evalMap = (Map) loggerContext.getObject(CoreGlobal.EVALUATOR_MAP);
     assertNotNull(evalMap);
-    StatusPrinter.print(loggerContext.getStatusManager());
+    //StatusPrinter.print(loggerContext.getStatusManager());
     
     Logger logger = loggerContext.getLogger("xx");
     
     JaninoEventEvaluator evaluator = (JaninoEventEvaluator) evalMap.get("IGNORE_EVAL");
     LoggingEvent event = new LoggingEvent("foo", logger, Level.DEBUG, "Hello world",null, null);
-    StatusPrinter.print(loggerContext.getStatusManager());
+    //StatusPrinter.print(loggerContext.getStatusManager());
     
     Marker ignoreMarker = MarkerFactory.getMarker("IGNORE");
     event.setMarker(ignoreMarker);
@@ -78,7 +77,7 @@
     
     //logger.debug("hello", new Exception("test"));
     
-    StatusPrinter.print(loggerContext.getStatusManager());
+    //StatusPrinter.print(loggerContext.getStatusManager());
   }
   
   public void testMultipleConditionsInExpression() throws NullPointerException, EvaluationException {
@@ -91,7 +90,7 @@
     //&amp;&amp;
     ee.setExpression("message.contains(\"stacktrace\") && message.contains(\"logging\")");
     ee.start();
-    StatusPrinter.print(loggerContext);
+    //StatusPrinter.print(loggerContext);
     
     String message = "stacktrace bla bla logging";
     LoggingEvent event = new LoggingEvent(this.getClass().getName(), logger, Level.DEBUG, message, null, null);

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SyslogAppenderTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SyslogAppenderTest.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SyslogAppenderTest.java	Fri Nov 17 18:35:05 2006
@@ -53,7 +53,7 @@
     logger.addAppender(sa);
     String logMsg = "hello";
     logger.debug(logMsg);
-    StatusPrinter.print(lc.getStatusManager());
+    //StatusPrinter.print(lc.getStatusManager());
 
     // wait max 2 seconds for mock server to finish. However, it should
     // much sooner than that.
@@ -98,7 +98,7 @@
     String exMsg = "just testing";
     Exception ex = new Exception(exMsg);
     logger.debug(logMsg, ex);
-    StatusPrinter.print(lc.getStatusManager());
+    //StatusPrinter.print(lc.getStatusManager());
 
     // wait max 2 seconds for mock server to finish. However, it should
     // much sooner than that.

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ConverterTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ConverterTest.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ConverterTest.java	Fri Nov 17 18:35:05 2006
@@ -119,7 +119,7 @@
       DynamicConverter converter = new ThrowableInformationConverter();
       StringBuffer buf = new StringBuffer();
       converter.write(buf, le);
-      System.out.println(buf);
+      // System.out.println(buf);
     }
 
     {
@@ -128,7 +128,7 @@
       converter.setOptionList(this.optionList);
       StringBuffer buf = new StringBuffer();
       converter.write(buf, le);
-      System.out.println(buf);
+      // System.out.println(buf);
     }
   }
 
@@ -255,7 +255,7 @@
       if (buf.length() < 10) {
         fail("buf is too short");
       }
-      System.out.println(buf);
+      // System.out.println(buf);
     }
 
   }



More information about the logback-dev mailing list