[logback-dev] [GIT] Logback: the generic, reliable, fast and flexible logging framework. branch, master, updated. v_0.9.28-39-g2948e8c

added by portage for gitosis-gentoo git-noreply at pixie.qos.ch
Mon May 30 09:46:01 CEST 2011


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Logback: the generic, reliable, fast and flexible logging framework.".

The branch, master has been updated
       via  2948e8c816e77bcd85ba35e69430ca1d697230fd (commit)
      from  79989e013e314dd815b23a12fea8bcd5e16fcc49 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=2948e8c816e77bcd85ba35e69430ca1d697230fd
http://github.com/ceki/logback/commit/2948e8c816e77bcd85ba35e69430ca1d697230fd

commit 2948e8c816e77bcd85ba35e69430ca1d697230fd
Author: Ceki Gulcu <ceki at qos.ch>
Date:   Mon May 30 09:39:17 2011 +0200

    SizeBasedRollingTest replaced by its Scala equivalent

diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/db/DBAppender.java b/logback-classic/src/main/java/ch/qos/logback/classic/db/DBAppender.java
index 93e0c13..4c2f5c6 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/db/DBAppender.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/db/DBAppender.java
@@ -178,8 +178,7 @@ public class DBAppender extends DBAppenderBase<ILoggingEvent> {
     Map<String, String> mergedMap = new HashMap<String, String>();
     // we add the context properties first, then the event properties, since
     // we consider that event-specific properties should have priority over
-    // context-wide
-    // properties.
+    // context-wide properties.
     Map<String, String> loggerContextMap = event.getLoggerContextVO()
         .getPropertyMap();
     Map<String, String> mdcMap = event.getMDCPropertyMap();
diff --git a/logback-core/src/test/java/ch/qos/logback/core/rolling/PackageTest.java b/logback-core/src/test/java/ch/qos/logback/core/rolling/PackageTest.java
index 684b16a..0865e6c 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/rolling/PackageTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/rolling/PackageTest.java
@@ -17,11 +17,11 @@ import org.junit.runner.RunWith;
 import org.junit.runners.Suite;
 
 @RunWith(Suite.class)
- at Suite.SuiteClasses( { RenameUtilTest.class, SizeBasedRollingTest.class,
-    TimeBasedRolling2Test.class, TimeBasedRollingWithArchiveRemovalTest.class,
-    MultiThreadedRollingTest.class,
-    SizeAndTimeBasedFNATP_Test.class,
-    RollingFileAppenderTest.class,
-    ch.qos.logback.core.rolling.helper.PackageTest.class })
+ at Suite.SuiteClasses({RenameUtilTest.class, SizeBasedRolling_STest.class,
+        TimeBasedRolling2Test.class, TimeBasedRollingWithArchiveRemovalTest.class,
+        MultiThreadedRollingTest.class,
+        SizeAndTimeBasedFNATP_Test.class,
+        RollingFileAppenderTest.class,
+        ch.qos.logback.core.rolling.helper.PackageTest.class})
 public class PackageTest {
 }
diff --git a/logback-core/src/test/java/ch/qos/logback/core/rolling/SizeAndTimeBasedFNATP_STest.scala b/logback-core/src/test/java/ch/qos/logback/core/rolling/SizeAndTimeBasedFNATP_STest.scala
new file mode 100644
index 0000000..e0e1a06
--- /dev/null
+++ b/logback-core/src/test/java/ch/qos/logback/core/rolling/SizeAndTimeBasedFNATP_STest.scala
@@ -0,0 +1,21 @@
+/**
+ * Logback: the reliable, generic, fast and flexible logging framework.
+ * Copyright (C) 1999-2011, QOS.ch. All rights reserved.
+ *
+ * This program and the accompanying materials are dual-licensed under
+ * either the terms of the Eclipse Public License v1.0 as published by
+ * the Eclipse Foundation
+ *
+ *   or (per the licensee's choosing)
+ *
+ * under the terms of the GNU Lesser General Public License version 2.1
+ * as published by the Free Software Foundation.
+ */
+package ch.qos.logback.core.rolling
+
+/**
+ * @author Ceki G&uuml;c&uuml;
+*/
+class SizeAndTimeBasedFNATP_STest {
+
+}
\ No newline at end of file
diff --git a/logback-core/src/test/java/ch/qos/logback/core/rolling/SizeBasedRollingTest.java b/logback-core/src/test/java/ch/qos/logback/core/rolling/SizeBasedRollingTest.java
deleted file mode 100644
index 36b5cd0..0000000
--- a/logback-core/src/test/java/ch/qos/logback/core/rolling/SizeBasedRollingTest.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/**
- * Logback: the reliable, generic, fast and flexible logging framework.
- * Copyright (C) 1999-2009, QOS.ch. All rights reserved.
- *
- * This program and the accompanying materials are dual-licensed under
- * either the terms of the Eclipse Public License v1.0 as published by
- * the Eclipse Foundation
- *
- *   or (per the licensee's choosing)
- *
- * under the terms of the GNU Lesser General Public License version 2.1
- * as published by the Free Software Foundation.
- */
-package ch.qos.logback.core.rolling;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.File;
-import java.io.IOException;
-import java.text.SimpleDateFormat;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import ch.qos.logback.core.Context;
-import ch.qos.logback.core.ContextBase;
-import ch.qos.logback.core.encoder.DummyEncoder;
-import ch.qos.logback.core.encoder.EchoEncoder;
-import ch.qos.logback.core.util.CoreTestConstants;
-
-/**
- * Do not forget to call start() when configuring programatically.
- *
- * @author Ceki G&uuml;lc&uuml;
- * @author S&eacute;bastien Pennec
- */
-public class SizeBasedRollingTest extends ScaffoldingForRollingTests {
-
-  @Before
-  @Override
-  public void setUp() {
-    super.setUp();
-    {
-      File target = new File(CoreTestConstants.OUTPUT_DIR_PREFIX
-              + "sizeBased-smoke.log");
-      target.mkdirs();
-      target.delete();
-    }
-    {
-      File target = new File(CoreTestConstants.OUTPUT_DIR_PREFIX
-              + "sbr-test3.log");
-      target.mkdirs();
-      target.delete();
-    }
-  }
-
-  @After
-  public void tearDown() {
-  }
-
-  /**
-   * Test whether FixedWindowRollingPolicy throws an exception when the
-   * ActiveFileName is not set.
-   */
-  @Test
-  public void activeFileNameNotSet() throws Exception {
-    // We purposefully use the \n as the line separator.
-    // This makes the regression test system independent.
-    Context context = new ContextBase();
-    RollingFileAppender<Object> rfa = new RollingFileAppender<Object>();
-    rfa.setEncoder(new DummyEncoder<Object>());
-    rfa.setContext(new ContextBase());
-
-    FixedWindowRollingPolicy fwrp = new FixedWindowRollingPolicy();
-    fwrp.setContext(context);
-    fwrp.setParent(rfa);
-    SizeBasedTriggeringPolicy sbtp = new SizeBasedTriggeringPolicy();
-    sbtp.setContext(context);
-
-    sbtp.setMaxFileSize("100");
-    sbtp.start();
-    fwrp.setFileNamePattern(CoreTestConstants.OUTPUT_DIR_PREFIX
-            + "sizeBased-test1.%i");
-    try {
-      fwrp.start();
-      fail("The absence of activeFileName option should have caused an exception.");
-    } catch (IllegalStateException e) {
-      return;
-    }
-  }
-
-  /**
-   * Test basic rolling functionality.
-   */
-  @Test
-  public void smoke() throws Exception {
-    Context context = new ContextBase();
-
-    RollingFileAppender<Object> rfa = new RollingFileAppender<Object>();
-    rfa.setName("ROLLING");
-    rfa.setEncoder(new EchoEncoder<Object>());
-    rfa.setContext(context);
-    // make the .log show first
-    rfa.setFile(randomOutputDir + "a-sizeBased-smoke.log");
-
-    FixedWindowRollingPolicy swrp = new FixedWindowRollingPolicy();
-    swrp.setContext(context);
-    SizeBasedTriggeringPolicy<Object> sbtp = new SizeBasedTriggeringPolicy<Object>();
-    sbtp.setContext(context);
-
-    sbtp.setMaxFileSize("100");
-    swrp.setMinIndex(0);
-    swrp.setFileNamePattern(randomOutputDir + "sizeBased-smoke.%i");
-    swrp.setParent(rfa);
-    swrp.start();
-
-    rfa.setRollingPolicy(swrp);
-    rfa.setTriggeringPolicy(sbtp);
-    rfa.start();
-
-    int runLength = 45;
-    String prefix = "hello";
-    for (int i = 0; i < runLength; i++) {
-      Thread.sleep(10);
-      rfa.doAppend(prefix + i);
-    }
-
-    expectedFilenameList.add(randomOutputDir + "a-sizeBased-smoke.log");
-    expectedFilenameList.add(randomOutputDir + "sizeBased-smoke.0");
-    expectedFilenameList.add(randomOutputDir + "sizeBased-smoke.1");
-    existenceCheck(expectedFilenameList);
-
-    reverseSortedContentCheck(randomOutputDir, runLength, prefix);
-  }
-
-  /**
-   * Same as testBasic but also with GZ compression.
-   */
-  @Test
-  public void test3() throws Exception {
-    Context context = new ContextBase();
-    RollingFileAppender<Object> rfa = new RollingFileAppender<Object>();
-    rfa.setEncoder(new EchoEncoder<Object>());
-    rfa.setContext(context);
-    rfa.setFile(randomOutputDir + "a-sbr-test3.log");
-
-    FixedWindowRollingPolicy fwrp = new FixedWindowRollingPolicy();
-    fwrp.setContext(context);
-    SizeBasedTriggeringPolicy<Object> sbtp = new SizeBasedTriggeringPolicy<Object>();
-    sbtp.setContext(context);
-
-    sbtp.setMaxFileSize("100");
-    fwrp.setMinIndex(0);
-    // fwrp.setActiveFileName(Constants.TEST_DIR_PREFIX +
-    // "output/sbr-test3.log");
-    fwrp.setFileNamePattern(randomOutputDir + "sbr-test3.%i.gz");
-    fwrp.setParent(rfa);
-    fwrp.start();
-    rfa.setRollingPolicy(fwrp);
-    rfa.setTriggeringPolicy(sbtp);
-    rfa.start();
-
-    int runLength = 40;
-    String prefix = "hello";
-    for (int i = 0; i < runLength; i++) {
-      Thread.sleep(10);
-      rfa.doAppend("hello" + i);
-    }
-
-    expectedFilenameList.add(randomOutputDir + "a-sbr-test3.log");
-    expectedFilenameList.add(randomOutputDir + "sbr-test3.0.gz");
-    expectedFilenameList.add(randomOutputDir + "sbr-test3.1.gz");
-
-    existenceCheck(expectedFilenameList);
-    reverseSortedContentCheck(randomOutputDir, runLength, prefix);
-  }
-
-  @Test
-  public void test3Zip() throws Exception {
-    Context context = new ContextBase();
-    RollingFileAppender<Object> rfa = new RollingFileAppender<Object>();
-    rfa.setEncoder(new EchoEncoder<Object>());
-    rfa.setContext(context);
-    rfa.setFile(randomOutputDir + "a-sbr-test3.log");
-
-    FixedWindowRollingPolicy fwrp = new FixedWindowRollingPolicy();
-    fwrp.setContext(context);
-    SizeBasedTriggeringPolicy<Object> sbtp = new SizeBasedTriggeringPolicy<Object>();
-    sbtp.setContext(context);
-
-    sbtp.setMaxFileSize("100");
-    fwrp.setMinIndex(0);
-    // fwrp.setActiveFileName(Constants.TEST_DIR_PREFIX +
-    // "output/sbr-test3.log");
-    fwrp.setFileNamePattern(randomOutputDir + "sbr-test3.%i.zip");
-    fwrp.setParent(rfa);
-    fwrp.start();
-    rfa.setRollingPolicy(fwrp);
-    rfa.setTriggeringPolicy(sbtp);
-    rfa.start();
-
-    int runLength = 40;
-    String prefix = "hello";
-    for (int i = 0; i < runLength; i++) {
-      Thread.sleep(10);
-      rfa.doAppend("hello" + i);
-    }
-    expectedFilenameList.add(randomOutputDir + "a-sbr-test3.log");
-    expectedFilenameList.add(randomOutputDir + "sbr-test3.0.zip");
-    expectedFilenameList.add(randomOutputDir + "sbr-test3.1.zip");
-
-    existenceCheck(expectedFilenameList);
-    reverseSortedContentCheck(randomOutputDir, runLength, prefix);
-    zipEntryNameCheck(expectedFilenameList);
-    //fail("we should check zipEntries names as well");
-
-  }
-
-  private void zipEntryNameCheck(List<String> expectedFilenameList) throws IOException {
-    for (String filepath : expectedFilenameList) {
-      if (filepath.endsWith(".zip")) {
-        checkZipEntryName(filepath, "sbr-test3.%i.zip");
-      }
-    }
-  }
-
-  SimpleDateFormat SDF = new SimpleDateFormat();
-
-  private void checkZipEntryName(String filepath, String pattern) throws IOException {
-    System.out.println("Checking ["+filepath+"]");
-    ZipFile zf = new ZipFile(filepath);
-    Enumeration entries = zf.entries();
-    assert(entries.hasMoreElements());
-    ZipEntry firstZipEntry = (ZipEntry) entries.nextElement();
-    assert(!entries.hasMoreElements());
-    System.out.println("Testing zip entry ["+firstZipEntry.getName()+"]");
-    assertTrue(firstZipEntry.getName().matches("sbr-test3.20\\d{2}-\\d{2}-\\d{2}_\\d{4}"));
-
-  }
-}
diff --git a/logback-core/src/test/scala/ch/qos/logback/core/rolling/LBCORE_199.scala b/logback-core/src/test/scala/ch/qos/logback/core/rolling/LBCORE_199.scala
deleted file mode 100644
index 1d79982..0000000
--- a/logback-core/src/test/scala/ch/qos/logback/core/rolling/LBCORE_199.scala
+++ /dev/null
@@ -1,61 +0,0 @@
-package ch.qos.logback.core.rolling
-
-import org.junit.{Before, Test}
-import ch.qos.logback.core.encoder.EchoEncoder
-import ch.qos.logback.core.util.StatusPrinter
-
-/**
- * Created by IntelliJ IDEA.
- * User: ceki
- * Date: 09.03.11
- * Time: 18:11
- * To change this template use File | Settings | File Templates.
- */
-
-class LBCORE_199 extends RollingScaffolding {
-
-  private[rolling] var rfa: RollingFileAppender[AnyRef] = new RollingFileAppender[AnyRef]
-  private[rolling] var fwrp: FixedWindowRollingPolicy[AnyRef] = new FixedWindowRollingPolicy[AnyRef]
-  private[rolling] var triggeringPolicy = new SizeBasedTriggeringPolicy[AnyRef]
-  private[rolling] var encoder: EchoEncoder[AnyRef] = new EchoEncoder[AnyRef]
-
-  @Before
-  def setUp: Unit = {
-    setUpScaffolding
-    fwrp.setContext(context)
-    rfa.setContext(context)
-    triggeringPolicy.setContext(context)
-  }
-
-  private[rolling] def initRFA(filename: String): Unit = {
-    rfa.setEncoder(encoder)
-    if (filename != null) {
-      rfa.setFile(filename)
-    }
-  }
-
-  @Test
-  def smoke() {
-    initRFA("toto.log")
-    fwrp.setFileNamePattern("tests.%i.log.zip")
-    fwrp.minIndex = 1
-    fwrp.maxIndex = 3
-    fwrp.setParent(rfa)
-    fwrp.start
-    triggeringPolicy.setMaxFileSize("20")
-    triggeringPolicy.start
-    rfa.triggeringPolicy = triggeringPolicy
-    rfa.rollingPolicy = fwrp
-    rfa.start
-
-    for (i <- 1 to 100) {
-      Thread.sleep(10)
-      rfa.doAppend("hello "+i)
-    }
-
-    StatusPrinter.print(context)
-
-  }
-
-
-}
\ No newline at end of file
diff --git a/logback-core/src/test/scala/ch/qos/logback/core/rolling/RollingScaffolding.scala b/logback-core/src/test/scala/ch/qos/logback/core/rolling/RollingScaffolding.scala
index 905530b..76dc664 100644
--- a/logback-core/src/test/scala/ch/qos/logback/core/rolling/RollingScaffolding.scala
+++ b/logback-core/src/test/scala/ch/qos/logback/core/rolling/RollingScaffolding.scala
@@ -14,20 +14,24 @@
 package ch.qos.logback.core.rolling
 
 import ch.qos.logback.core.{ContextBase, Context}
-import ch.qos.logback.core.testUtil.RandomUtil
-import java.util.{Date, Calendar}
+import helper.FileFilterUtil
 import java.util.concurrent.TimeUnit
-import java.text.SimpleDateFormat
 import ch.qos.logback.core.util.{CachingDateFormatter, CoreTestConstants}
+import org.junit.Assert._
+import java.io.File
+import ch.qos.logback.core.testUtil.{FileToBufferUtil, RandomUtil}
+import java.util.{ArrayList, Date, Calendar}
 
 trait RollingScaffolding {
   final val DATE_PATTERN_WITH_SECONDS = "yyyy-MM-dd_HH_mm_ss"
   final val SDF = new CachingDateFormatter(DATE_PATTERN_WITH_SECONDS)
-  private[rolling] var context: Context = new ContextBase
-  private[rolling] var diff: Int = RandomUtil.getPositiveInt
+
+  var context: Context = new ContextBase
+  var diff: Int = RandomUtil.getPositiveInt
+
   protected var currentTime: Long = 0L
   protected var randomOutputDir: String = CoreTestConstants.OUTPUT_DIR_PREFIX + diff + "/"
-  private[rolling] var cal: Calendar = Calendar.getInstance
+  var cal: Calendar = Calendar.getInstance
   protected var nextRolloverThreshold: Long = 0;
   protected var expectedFilenameList: List[String] = Nil
 
@@ -56,7 +60,7 @@ trait RollingScaffolding {
     if (gzExtension) {
       fn += ".gz"
     }
-    expectedFilenameList += fn
+    expectedFilenameList = expectedFilenameList ::: List(fn)
 
   }
 
@@ -96,7 +100,38 @@ trait RollingScaffolding {
   // =========================================================================
   private[rolling] def massageExpectedFilesToCorresponToCurrentTarget(file: String): Unit = {
     expectedFilenameList = expectedFilenameList.dropRight(1)
-    expectedFilenameList +=  (randomOutputDir + file)
+    expectedFilenameList =  expectedFilenameList ::: List(randomOutputDir + file)
+  }
+
+  def existenceCheck(filenameList: List[String]): Unit = {
+    for (filename <- filenameList) {
+      assertTrue("File " + filename + " does not exist", new File(filename).exists)
+    }
+  }
+
+  def getFilesInDirectory(outputDirStr: String): Array[File] = {
+    var outputDir: File = new File(outputDirStr)
+    return outputDir.listFiles
   }
 
+  def reverseSortedContentCheck(outputDirStr: String, runLength: Int, prefix: String): Unit = {
+    var fileArray: Array[File] = getFilesInDirectory(outputDirStr)
+    FileFilterUtil.reverseSortFileArrayByName(fileArray)
+    fileContentCheck(fileArray, runLength, prefix)
+  }
+
+  def fileContentCheck(fileArray: Array[File], runLength: Int, prefix: String): Unit = {
+    var stringList: ArrayList[String] = new ArrayList[String]
+
+    for (file <- fileArray) {
+      FileToBufferUtil.readIntoList(file, stringList)
+    }
+    var witnessList: List[String] = Nil
+    for(i <- 0 until runLength) {
+      witnessList = (prefix + i) :: witnessList
+    }
+    witnessList = witnessList.reverse
+    import scala.collection.JavaConversions.asScalaBuffer
+    assertEquals(witnessList, asScalaBuffer(stringList))
+  }
 }
\ No newline at end of file
diff --git a/logback-site/src/site/pages/news.html b/logback-site/src/site/pages/news.html
index 928f35b..6403d6f 100644
--- a/logback-site/src/site/pages/news.html
+++ b/logback-site/src/site/pages/news.html
@@ -40,7 +40,14 @@
     MDC.clear operation. This issue was reported in <a
     href="http://jira.qos.ch/browse/LBCLASSIC-253">LBCLASSIC-253</a>
     by Tommy Becker and independently fixed by the changes designated
-    to fix LBCLASSIC-254</p>.
+    to fix LBCLASSIC-254.</p>
+
+    <p>As reported by Deepak Vadgama in <a
+    href="http://jira.qos.ch/browse/LBCORE-199">LBCORE-199</a>, the
+    entry in every zip file created by
+    <code>FixedWindowRollingPolicy</code> had the same name. The issue
+    was solved by adding a timestamp to the name of the entry in the
+    zip files as suggested by a Benoit Xhenseval.</p> 
 
     <p><code>ConfigurationWatchList</code> no longer emits an error
     message when it encouters a configuraton file placed in a jar
@@ -61,7 +68,7 @@
     </p>
 
     <p>The AccessEvent class in logback-access module now implements
-    the IAccessEvent interface. This fixes <a
+    the <code>IAccessEvent</code> interface. This fixes <a
     href="http://jira.qos.ch/browse/LBACCESS-12">LBACCESS-12</a>
     reported by Joern Huxhorn.</p>
     
diff --git a/pom.xml b/pom.xml
index 514ea01..9c3d1f5 100755
--- a/pom.xml
+++ b/pom.xml
@@ -34,7 +34,7 @@
     <slf4j.version>1.6.1</slf4j.version>
     <junit.version>4.8.2</junit.version>
     <janino.version>2.5.10</janino.version>
-    <scala.version>2.7.7</scala.version>
+    <scala.version>2.9.0</scala.version>
     <groovy.version>1.7.6</groovy.version>
     <surefire.version>2.6</surefire.version>
     <consolePlugin.version>1.1.0</consolePlugin.version>  

-----------------------------------------------------------------------

Summary of changes:
 .../java/ch/qos/logback/classic/db/DBAppender.java |    3 +-
 .../ch/qos/logback/core/rolling/PackageTest.java   |   12 +-
 .../core/rolling/SizeAndTimeBasedFNATP_STest.scala |   44 ++--
 .../logback/core/rolling/SizeBasedRollingTest.java |  246 --------------------
 .../ch/qos/logback/core/rolling/LBCORE_199.scala   |   61 -----
 .../logback/core/rolling/RollingScaffolding.scala  |   51 ++++-
 logback-site/src/site/pages/news.html              |   11 +-
 pom.xml                                            |    2 +-
 8 files changed, 81 insertions(+), 349 deletions(-)
 copy logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/NestedType.groovy => logback-core/src/test/java/ch/qos/logback/core/rolling/SizeAndTimeBasedFNATP_STest.scala (74%)
 delete mode 100644 logback-core/src/test/java/ch/qos/logback/core/rolling/SizeBasedRollingTest.java
 delete mode 100644 logback-core/src/test/scala/ch/qos/logback/core/rolling/LBCORE_199.scala


hooks/post-receive
-- 
Logback: the generic, reliable, fast and flexible logging framework.


More information about the logback-dev mailing list