[logback-dev] svn commit: r1903 - in logback/trunk/logback-classic/src: main/java/ch/qos/logback/classic/util test/java/ch/qos/logback/classic test/java/ch/qos/logback/classic/util

noreply.ceki at qos.ch noreply.ceki at qos.ch
Wed Oct 29 16:08:53 CET 2008


Author: ceki
Date: Wed Oct 29 16:08:53 2008
New Revision: 1903

Added:
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/util/LevelToSyslogSeverityTest.java
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/util/PackageTest.java
Modified:
   logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/util/LevelToSyslogSeverity.java
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/AllClassicTest.java

Log:
LBCLASSIC-69

LevelToSyslogSeverity.convert method did not cover the TRACE level.

Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/util/LevelToSyslogSeverity.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/util/LevelToSyslogSeverity.java	(original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/util/LevelToSyslogSeverity.java	Wed Oct 29 16:08:53 2008
@@ -17,8 +17,8 @@
 public class LevelToSyslogSeverity {
 
   /*
-   * Convert a level to equivalent syslog severity. Only levels for printing methods
-   * i.e DEBUG, WARN, INFO and ERROR are converted.
+   * Convert a level to equivalent syslog severity. Only levels for printing
+   * methods i.e TRACE, DEBUG, WARN, INFO and ERROR are converted.
    * 
    */
   static public int convert(LoggingEvent event) {
@@ -34,6 +34,8 @@
       return SyslogConstants.INFO_SEVERITY;
     case Level.DEBUG_INT:
       return SyslogConstants.DEBUG_SEVERITY;
+    case Level.TRACE_INT:
+      return SyslogConstants.DEBUG_SEVERITY;
     default:
       throw new IllegalArgumentException("Level " + level
           + " is not a valid level for a printing method");

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/AllClassicTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/AllClassicTest.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/AllClassicTest.java	Wed Oct 29 16:08:53 2008
@@ -20,6 +20,7 @@
 
     suite.addTest(org.slf4j.impl.PackageTest.suite());
     suite.addTest(ch.qos.logback.classic.PackageTest.suite());
+    suite.addTest(ch.qos.logback.classic.util.PackageTest.suite());
     suite.addTest(ch.qos.logback.classic.control.PackageTest.suite());
     suite.addTest(ch.qos.logback.classic.joran.PackageTest.suite());
     suite.addTest(ch.qos.logback.classic.boolex.PackageTest.suite());

Added: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/util/LevelToSyslogSeverityTest.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/util/LevelToSyslogSeverityTest.java	Wed Oct 29 16:08:53 2008
@@ -0,0 +1,39 @@
+package ch.qos.logback.classic.util;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.spi.LoggingEvent;
+import ch.qos.logback.core.net.SyslogConstants;
+
+public class LevelToSyslogSeverityTest {
+
+  @Test
+  public void smoke() {
+
+    assertEquals(SyslogConstants.DEBUG_SEVERITY, LevelToSyslogSeverity
+        .convert(createEventOfLevel(Level.TRACE)));
+
+    assertEquals(SyslogConstants.DEBUG_SEVERITY, LevelToSyslogSeverity
+        .convert(createEventOfLevel(Level.DEBUG)));
+
+    assertEquals(SyslogConstants.INFO_SEVERITY, LevelToSyslogSeverity
+        .convert(createEventOfLevel(Level.INFO)));
+
+    assertEquals(SyslogConstants.WARNING_SEVERITY, LevelToSyslogSeverity
+        .convert(createEventOfLevel(Level.WARN)));
+
+    assertEquals(SyslogConstants.ERROR_SEVERITY, LevelToSyslogSeverity
+        .convert(createEventOfLevel(Level.ERROR)));
+
+  }
+
+  LoggingEvent createEventOfLevel(Level level) {
+    LoggingEvent event = new LoggingEvent();
+    event.setLevel(level);
+    return event;
+  }
+
+}

Added: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/util/PackageTest.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/util/PackageTest.java	Wed Oct 29 16:08:53 2008
@@ -0,0 +1,26 @@
+/**
+ * Logback: the generic, reliable, fast and flexible logging framework.
+ * 
+ * Copyright (C) 1999-2006, 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 junit.framework.JUnit4TestAdapter;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class PackageTest extends TestCase {
+  
+  public static Test suite() {
+    TestSuite suite = new TestSuite();
+    suite.addTest(new JUnit4TestAdapter(InitializationTest.class));
+    suite.addTest(new JUnit4TestAdapter(LevelToSyslogSeverityTest.class));
+    return suite;
+  }
+}
\ No newline at end of file


More information about the logback-dev mailing list