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

added by portage for gitosis-gentoo git-noreply at pixie.qos.ch
Mon May 30 12:44:43 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  fa4c0c64511c879482103f6476ad2af84321ba7f (commit)
      from  938ae993ee2c8c4e6e30dd6350b71e6b8e14f412 (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=fa4c0c64511c879482103f6476ad2af84321ba7f
http://github.com/ceki/logback/commit/fa4c0c64511c879482103f6476ad2af84321ba7f

commit fa4c0c64511c879482103f6476ad2af84321ba7f
Author: Ceki Gulcu <ceki at qos.ch>
Date:   Mon May 30 12:37:08 2011 +0200

    - migrating SizeAndTimeBasedFNATP_Test to scala
    - attempting to make pom.xml files be compatible with Scala IDE

diff --git a/logback-access/pom.xml b/logback-access/pom.xml
index 6e20b83..aad6118 100644
--- a/logback-access/pom.xml
+++ b/logback-access/pom.xml
@@ -94,6 +94,12 @@
       <optional>true</optional>
     </dependency>
 
+    <dependency>
+      <groupId>org.scala-lang</groupId>
+      <artifactId>scala-library</artifactId>
+      <scope>test</scope>
+    </dependency>
+
   </dependencies>
 
   <build>
diff --git a/logback-classic/pom.xml b/logback-classic/pom.xml
index 8eae411..3aa7b7c 100644
--- a/logback-classic/pom.xml
+++ b/logback-classic/pom.xml
@@ -181,6 +181,12 @@
       <version>2.0.2</version>
       <scope>test</scope>
     </dependency>
+
+    <dependency>
+      <groupId>org.scala-lang</groupId>
+      <artifactId>scala-library</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <build>
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/joran/conditional/ConditionalTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/joran/conditional/ConditionalTest.java
index 7dc3d1c..459656f 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/joran/conditional/ConditionalTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/joran/conditional/ConditionalTest.java
@@ -63,6 +63,7 @@ public class ConditionalTest {
     jc.doConfigure(file);
   }
 
+  @SuppressWarnings("rawtypes")
   @Test
   public void conditionalConsoleApp_IF_THEN_True() throws JoranException,
           IOException, InterruptedException {
@@ -82,6 +83,7 @@ public class ConditionalTest {
     assertTrue(checker.isErrorFree());
   }
 
+  @SuppressWarnings("rawtypes")
   @Test
   public void conditionalConsoleApp_IF_THEN_False() throws JoranException,
           IOException, InterruptedException {
@@ -98,6 +100,7 @@ public class ConditionalTest {
     assertTrue(checker.isErrorFree());
   }
 
+  @SuppressWarnings("rawtypes")
   @Test
   public void conditionalConsoleApp_IF_THEN_ELSE() throws JoranException,
           IOException, InterruptedException {
@@ -106,7 +109,7 @@ public class ConditionalTest {
             + "conditional/conditionalConsoleApp_ELSE.xml";
     configure(configFileAsStr);
 
-    FileAppender fileAppender = (FileAppender) root.getAppender("FILE");
+	FileAppender fileAppender = (FileAppender) root.getAppender("FILE");
     assertNotNull(fileAppender);
 
     ConsoleAppender consoleAppender = (ConsoleAppender) root.getAppender("CON");
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 ccabee3..a61f8fa 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
@@ -18,7 +18,7 @@ import org.junit.runners.Suite;
 
 @RunWith(Suite.class)
 @Suite.SuiteClasses({RenameUtilTest.class, SizeBasedRolling_STest.class,
-        TimeBasedRolling2Test.class, TimeBasedRollingWithArchiveRemovalTest.class,
+        TimeBasedRolling_STest.class, TimeBasedRollingWithArchiveRemovalTest.class,
         MultiThreadedRollingTest.class,
         SizeAndTimeBasedFNATP_Test.class,
         RollingFileAppenderTest.class,
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
deleted file mode 100644
index 5764cd4..0000000
--- a/logback-core/src/test/java/ch/qos/logback/core/rolling/SizeAndTimeBasedFNATP_STest.scala
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * 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
-
-import org.junit.Test
-
-/**
- * @author Ceki G&uuml;c&uuml;
-*/
-class SizeAndTimeBasedFNATP_STest {
-
-  @Test
-  def x() {
-
-  }
-}
\ 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 76dc664..23da3c3 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
@@ -50,13 +50,18 @@ trait RollingScaffolding {
     currentTime += increment
   }
 
+  protected def getMillisOfCurrentPeriodsStart: Long = {
+    var delta: Long = currentTime % 1000
+    return (currentTime - delta)
+  }
+
   protected def getDateOfCurrentPeriodsStart: Date = {
     var delta: Long = currentTime % 1000
     return new Date(currentTime - delta)
   }
 
-  protected def addExpectedFileName_ByDate(outputDir: String, testId: String, date: Date, gzExtension: Boolean): Unit = {
-    var fn: String = outputDir + testId + "-" + SDF.format(date.getTime)
+  protected def addExpectedFileName_ByDate(outputDir: String, testId: String, millis: Long, gzExtension: Boolean): Unit = {
+    var fn: String = outputDir + testId + "-" + SDF.format(millis)
     if (gzExtension) {
       fn += ".gz"
     }
@@ -66,7 +71,7 @@ trait RollingScaffolding {
 
   protected def addExpectedFileNamedIfItsTime_ByDate(outputDir: String, testId: String, gzExtension: Boolean): Unit = {
     if (passThresholdTime(nextRolloverThreshold)) {
-      addExpectedFileName_ByDate(outputDir, testId, getDateOfCurrentPeriodsStart, gzExtension)
+      addExpectedFileName_ByDate(outputDir, testId, getMillisOfCurrentPeriodsStart, gzExtension)
       nextRolloverThreshold = recomputeRolloverThreshold(currentTime)
     }
   }
@@ -100,7 +105,7 @@ trait RollingScaffolding {
   // =========================================================================
   private[rolling] def massageExpectedFilesToCorresponToCurrentTarget(file: String): Unit = {
     expectedFilenameList = expectedFilenameList.dropRight(1)
-    expectedFilenameList =  expectedFilenameList ::: List(randomOutputDir + file)
+    expectedFilenameList = expectedFilenameList ::: List(file) 
   }
 
   def existenceCheck(filenameList: List[String]): Unit = {
@@ -114,7 +119,13 @@ trait RollingScaffolding {
     return outputDir.listFiles
   }
 
-  def reverseSortedContentCheck(outputDirStr: String, runLength: Int, prefix: String): Unit = {
+  def sortedContentCheck(outputDirStr: String, runLength: Int, prefix: String) {
+    var fileArray: Array[File] = getFilesInDirectory(outputDirStr)
+    FileFilterUtil.sortFileArrayByName(fileArray)
+    fileContentCheck(fileArray, runLength, prefix)
+  }
+   
+  def reverseSortedContentCheck(outputDirStr: String, runLength: Int, prefix: String) {
     var fileArray: Array[File] = getFilesInDirectory(outputDirStr)
     FileFilterUtil.reverseSortFileArrayByName(fileArray)
     fileContentCheck(fileArray, runLength, prefix)
@@ -127,7 +138,7 @@ trait RollingScaffolding {
       FileToBufferUtil.readIntoList(file, stringList)
     }
     var witnessList: List[String] = Nil
-    for(i <- 0 until runLength) {
+    for (i <- 0 until runLength) {
       witnessList = (prefix + i) :: witnessList
     }
     witnessList = witnessList.reverse
diff --git a/logback-core/src/test/scala/ch/qos/logback/core/rolling/SizeAndTimeBasedFNATP_STest.scala b/logback-core/src/test/scala/ch/qos/logback/core/rolling/SizeAndTimeBasedFNATP_STest.scala
new file mode 100644
index 0000000..643fce2
--- /dev/null
+++ b/logback-core/src/test/scala/ch/qos/logback/core/rolling/SizeAndTimeBasedFNATP_STest.scala
@@ -0,0 +1,118 @@
+package ch.qos.logback.core.rolling
+
+/**
+ * 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.
+ */
+import ch.qos.logback.core.encoder.EchoEncoder
+import ch.qos.logback.core.status.InfoStatus
+import java.util.Date
+import org.junit.{Ignore, Test}
+import org.junit.Before
+
+/**
+ * @author Ceki G&uuml;c&uuml;
+ */
+class SizeAndTimeBasedFNATP_STest extends RollingScaffolding {
+  private var sizeAndTimeBasedFNATP: SizeAndTimeBasedFNATP[AnyRef] = null
+  private val rfa1: RollingFileAppender[AnyRef] = new RollingFileAppender[AnyRef]
+  private val tbrp1: TimeBasedRollingPolicy[AnyRef] = new TimeBasedRollingPolicy[AnyRef]
+  private val rfa2: RollingFileAppender[AnyRef] = new RollingFileAppender[AnyRef]
+  private val tbrp2: TimeBasedRollingPolicy[AnyRef] = new TimeBasedRollingPolicy[AnyRef]
+
+  private val encoder: EchoEncoder[AnyRef] = new EchoEncoder[AnyRef]
+  var fileSize = 0
+  var fileIndexCounter = 0
+  var sizeThreshold = 0
+  
+  @Before
+  def setUp() {
+    setUpScaffolding
+  }
+  
+  private def initRollingFileAppender(rfa: RollingFileAppender[AnyRef], filename: String): Unit = {
+    rfa.setContext(context)
+    rfa.setEncoder(encoder)
+    if (filename != null) {
+      rfa.setFile(filename)
+    }
+  }
+
+  private def initPolicies(rfa: RollingFileAppender[AnyRef], tbrp: TimeBasedRollingPolicy[AnyRef], filenamePattern: String, sizeThreshold: Int, givenTime: Long, lastCheck: Long): Unit = {
+    sizeAndTimeBasedFNATP = new SizeAndTimeBasedFNATP[AnyRef]
+    tbrp.setContext(context)
+    sizeAndTimeBasedFNATP.setMaxFileSize("" + sizeThreshold)
+    tbrp.setTimeBasedFileNamingAndTriggeringPolicy(sizeAndTimeBasedFNATP)
+    tbrp.setFileNamePattern(filenamePattern)
+    tbrp.setParent(rfa)
+    tbrp.timeBasedFileNamingAndTriggeringPolicy.setCurrentTime(givenTime)
+    rfa.setRollingPolicy(tbrp)
+    tbrp.start
+    rfa.start
+  }
+
+  private def addExpectedFileName(randomOutputDir: String, testId: String, millis: Long, fileIndexCounter: Int, gzExtension: Boolean): Unit = {
+    var fn: String = randomOutputDir + testId + "-" + SDF.format(millis) + "-" + fileIndexCounter + ".txt"
+    if (gzExtension) {
+      fn += ".gz"
+    }
+     expectedFilenameList = expectedFilenameList ::: List(fn)
+  }
+
+  private def addExpectedFileNamedIfItsTime(randomOutputDir: String, testId: String, msg: String, gzExtension: Boolean): Unit = {
+      fileSize = fileSize + msg.getBytes.length
+      if (passThresholdTime(nextRolloverThreshold)) {
+        fileIndexCounter = 0
+        fileSize = 0
+        addExpectedFileName(randomOutputDir, testId, getMillisOfCurrentPeriodsStart, fileIndexCounter, gzExtension)
+        recomputeRolloverThreshold(currentTime)
+        return
+      }
+
+    // windows can delay file size changes, so we only allow for
+    // fileIndexCounter 0 and 1
+      if ((fileIndexCounter < 1) && fileSize > sizeThreshold) {
+        addExpectedFileName(randomOutputDir, testId, getMillisOfCurrentPeriodsStart, ({
+          fileIndexCounter += 1; fileIndexCounter - 1
+        }), gzExtension)
+        fileSize = 0
+        return
+      }
+    }
+
+  @Test
+  def noCompression_FileSet_NoRestart_1 {
+    var testId: String = "test1"
+    var file: String = randomOutputDir + "toto.log"
+    initRollingFileAppender(rfa1, file)
+    sizeThreshold = 300
+    initPolicies(rfa1, tbrp1, randomOutputDir + testId + "-%d{" + DATE_PATTERN_WITH_SECONDS + "}-%i.txt", sizeThreshold, currentTime, 0)
+    addExpectedFileName(randomOutputDir, testId, getMillisOfCurrentPeriodsStart, fileIndexCounter, false)
+    incCurrentTime(100)
+    tbrp1.timeBasedFileNamingAndTriggeringPolicy.setCurrentTime(currentTime)
+    var runLength: Int = 100
+    var prefix: String = "Hello -----------------"
+
+    for (i <- 0 until runLength) {
+      var msg: String = prefix + i
+      rfa1.doAppend(msg)
+      addExpectedFileNamedIfItsTime(randomOutputDir, testId, msg, false)
+      incCurrentTime(20)
+      tbrp1.timeBasedFileNamingAndTriggeringPolicy.setCurrentTime(currentTime)
+    }
+    massageExpectedFilesToCorresponToCurrentTarget(file)
+    expectedFilenameList.foreach(println(_))
+ 
+    existenceCheck(expectedFilenameList)
+    sortedContentCheck(randomOutputDir, runLength, prefix)
+  }
+}
diff --git a/logback-core/src/test/scala/ch/qos/logback/core/rolling/TimeBasedRolling2Test.scala b/logback-core/src/test/scala/ch/qos/logback/core/rolling/TimeBasedRolling_STest.scala
similarity index 84%
rename from logback-core/src/test/scala/ch/qos/logback/core/rolling/TimeBasedRolling2Test.scala
rename to logback-core/src/test/scala/ch/qos/logback/core/rolling/TimeBasedRolling_STest.scala
index 2a94519..51e14c0 100644
--- a/logback-core/src/test/scala/ch/qos/logback/core/rolling/TimeBasedRolling2Test.scala
+++ b/logback-core/src/test/scala/ch/qos/logback/core/rolling/TimeBasedRolling_STest.scala
@@ -1,201 +1,202 @@
-/**
- * Logback: the reliable, generic, fast and flexible logging framework.
- * Copyright (C) 1999-2010, 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 org.junit.Assert.assertTrue
-import org.junit.Before
-import org.junit.Test
-import ch.qos.logback.core.encoder.EchoEncoder
-import java.io.{FileOutputStream, File}
-import ch.qos.logback.core.util.{StatusPrinter, Compare, CoreTestConstants}
-import ch.qos.logback.core.testUtil.Env
-
-class TimeBasedRolling2Test extends RollingScaffolding {
-
-  private[rolling] var rfa1: RollingFileAppender[AnyRef] = new RollingFileAppender[AnyRef]
-  private[rolling] var tbrp1: TimeBasedRollingPolicy[AnyRef] = new TimeBasedRollingPolicy[AnyRef]
-  private[rolling] var rfa2: RollingFileAppender[AnyRef] = new RollingFileAppender[AnyRef]
-  private[rolling] var tbrp2: TimeBasedRollingPolicy[AnyRef] = new TimeBasedRollingPolicy[AnyRef]
-
-  private[rolling] var encoder: EchoEncoder[AnyRef] = new EchoEncoder[AnyRef]
-
-  @Before
-  def setUp: Unit = {
-    setUpScaffolding
-  }
-
-  private[rolling] def initRFA(rfa: RollingFileAppender[AnyRef], filename: String): Unit = {
-    rfa.setContext(context)
-    rfa.setEncoder(encoder)
-    if (filename != null) {
-      rfa.setFile(filename)
-    }
-  }
-
-  private[rolling] def initTRBP(rfa: RollingFileAppender[AnyRef], tbrp: TimeBasedRollingPolicy[AnyRef], filenamePattern: String, givenTime: Long): Unit = {
-    tbrp.setContext(context)
-    tbrp.setFileNamePattern(filenamePattern)
-    tbrp.setParent(rfa)
-    tbrp.timeBasedFileNamingAndTriggeringPolicy = new DefaultTimeBasedFileNamingAndTriggeringPolicy[AnyRef]
-    tbrp.timeBasedFileNamingAndTriggeringPolicy.setCurrentTime(givenTime)
-    rfa.setRollingPolicy(tbrp)
-    tbrp.start
-    rfa.start
-  }
-
-  type CheckFunction = ((String, Boolean, String) => Unit)
-  def genericTest(checkFunction: CheckFunction)(testId: String, compressionSuffix: String, fileOptionIsSet: Boolean, waitDuration: Int): Unit = {
-    val withCompression = compressionSuffix.length > 0
-    val fileName = if (fileOptionIsSet) testId2FileName(testId) else null;
-    initRFA(rfa1, fileName);
-
-    initTRBP(rfa1, tbrp1, randomOutputDir + testId + "-%d{"
-      + DATE_PATTERN_WITH_SECONDS + "}" + compressionSuffix, currentTime);
-
-    // compute the current filename
-    addExpectedFileName_ByDate(randomOutputDir, testId, getDateOfCurrentPeriodsStart, withCompression);
-
-    incCurrentTime(1100);
-    tbrp1.timeBasedFileNamingAndTriggeringPolicy.setCurrentTime(currentTime);
-
-    for (i <- 0 until 3) {
-      rfa1.doAppend("Hello---" + i);
-      addExpectedFileNamedIfItsTime_ByDate(randomOutputDir, testId, withCompression && (i != 2))
-      incCurrentTime(500);
-      tbrp1.timeBasedFileNamingAndTriggeringPolicy.setCurrentTime(currentTime)
-      if (withCompression)
-        waitForCompression(tbrp1)
-    }
-    rfa1.stop
-
-    if (waitDuration != 0) {
-      doRestart(testId, fileOptionIsSet, waitDuration);
-    }
-
-    if (fileOptionIsSet) {
-      massageExpectedFilesToCorresponToCurrentTarget(testId + ".log")
-    }
-
-    checkFunction(testId, withCompression, compressionSuffix)
-  }
-
-  // defaultTest uses the defaultCheck function
-  val defaultTest = genericTest(defaultCheck)_
-
-  def defaultCheck(testId: String, withCompression: Boolean, compressionSuffix:String) = {
-    var i = 0;
-    for (fn <- expectedFilenameList) {
-      val suffix: String = if (withCompression) addGZIfNotLast(i, compressionSuffix) else ""
-      val witnessFileName: String = CoreTestConstants.TEST_DIR_PREFIX + "witness/rolling/tbr-" + testId + "." + i.toString + suffix
-      assertTrue(Compare.compare(fn, witnessFileName));
-      i += 1
-    }
-  }
-
-  def zCheck(testId: String, withCompression: Boolean, compressionSuffix:String) = {
-    val lastFile = expectedFilenameList.last
-    val witnessFileName: String = CoreTestConstants.TEST_DIR_PREFIX + "witness/rolling/tbr-" + testId
-    println(lastFile+"  "+witnessFileName)
-    assertTrue(Compare.compare(lastFile, witnessFileName));
-
-  }
-
-
-
-  def doRestart(testId: String, fileOptionIsSet: Boolean, waitDuration: Int) {
-    // change the timestamp of the currently actively file
-    var activeFile: File = new File(rfa1.getFile)
-    activeFile.setLastModified(currentTime)
-
-    incCurrentTime(waitDuration)
-
-    val fileName = if (fileOptionIsSet) testId2FileName(testId) else null;
-    initRFA(rfa2, fileName)
-    initTRBP(rfa2, tbrp2, randomOutputDir + testId + "-%d{" + DATE_PATTERN_WITH_SECONDS + "}", currentTime)
-    for (i <- 0 until 3) {
-      rfa2.doAppend("World---" + i)
-      addExpectedFileNamedIfItsTime_ByDate(randomOutputDir, testId, false)
-      incCurrentTime(100)
-      tbrp2.timeBasedFileNamingAndTriggeringPolicy.setCurrentTime(currentTime)
-    }
-  }
-
-  val NO_RESTART = 0
-  val WITH_RESTART = 1
-  val WITH_RESTART_AND_LONG_WAIT = 2000
-
-  @Test
-  def noCompression_FileBlank_NoRestart_1 = {
-    defaultTest("test1", "", FILE_OPTION_BLANK, NO_RESTART)
-  }
-
-  @Test
-  def withCompression_FileBlank_NoRestart_2 = {
-    defaultTest("test2", ".gz", FILE_OPTION_BLANK, NO_RESTART);
-  }
-
-  @Test
-  def noCompression_FileBlank_StopRestart_3 = {
-    defaultTest("test3", "", FILE_OPTION_BLANK, WITH_RESTART);
-  }
-
-  @Test
-  def noCompression_FileSet_StopRestart_4 = {
-    defaultTest("test4", "", FILE_OPTION_SET, WITH_RESTART);
-  }
-
-  @Test
-  def noCompression_FileSet_StopRestart_WithLongWait_4B = {
-    defaultTest("test4B", "", FILE_OPTION_SET, WITH_RESTART_AND_LONG_WAIT);
-  }
-
-  @Test
-  def noCompression_FileSet_NoRestart_5 = {
-    defaultTest("test5", "", FILE_OPTION_SET, NO_RESTART);
-  }
-
-  @Test
-  def withCompression_FileSet_NoRestart_6 = {
-    defaultTest("test6", ".gz", FILE_OPTION_SET, NO_RESTART);
-  }
-
-  @Test
-  def withMissingTargetDir = {
-    defaultTest("missingTargetDir", "", FILE_OPTION_SET, NO_RESTART);
-  }
-
-
-  @Test
-  def failed_rename: Unit = {
-
-    if(!Env.isWindows) return null
-
-    var fos: FileOutputStream = null
-    try {
-      val fileName = testId2FileName("failed_rename");
-      val file= new File(fileName)
-      file.getParentFile.mkdirs
-
-      fos = new FileOutputStream(fileName)
-      genericTest(zCheck)("failed_rename", "", FILE_OPTION_SET, NO_RESTART)
-
-    } finally {
-      StatusPrinter.print(context)
-      if(fos != null) fos.close;
-    }
-  }
-
-
-
+/**
+ * Logback: the reliable, generic, fast and flexible logging framework.
+ * Copyright (C) 1999-2010, 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 org.junit.Assert.assertTrue
+import org.junit.Before
+import org.junit.Test
+import ch.qos.logback.core.encoder.EchoEncoder
+import java.io.{FileOutputStream, File}
+import ch.qos.logback.core.util.{StatusPrinter, Compare, CoreTestConstants}
+import ch.qos.logback.core.testUtil.Env
+import java.security.PrivateKey
+
+class TimeBasedRolling_STest extends RollingScaffolding {
+
+  private var rfa1: RollingFileAppender[AnyRef] = new RollingFileAppender[AnyRef]
+  private var tbrp1: TimeBasedRollingPolicy[AnyRef] = new TimeBasedRollingPolicy[AnyRef]
+  private var rfa2: RollingFileAppender[AnyRef] = new RollingFileAppender[AnyRef]
+  private var tbrp2: TimeBasedRollingPolicy[AnyRef] = new TimeBasedRollingPolicy[AnyRef]
+
+  private var encoder: EchoEncoder[AnyRef] = new EchoEncoder[AnyRef]
+
+  @Before
+  def setUp: Unit = {
+    setUpScaffolding
+  }
+
+  private def initRFA(rfa: RollingFileAppender[AnyRef], filename: String): Unit = {
+    rfa.setContext(context)
+    rfa.setEncoder(encoder)
+    if (filename != null) {
+      rfa.setFile(filename)
+    }
+  }
+
+ private def initTRBP(rfa: RollingFileAppender[AnyRef], tbrp: TimeBasedRollingPolicy[AnyRef], filenamePattern: String, givenTime: Long): Unit = {
+    tbrp.setContext(context)
+    tbrp.setFileNamePattern(filenamePattern)
+    tbrp.setParent(rfa)
+    tbrp.timeBasedFileNamingAndTriggeringPolicy = new DefaultTimeBasedFileNamingAndTriggeringPolicy[AnyRef]
+    tbrp.timeBasedFileNamingAndTriggeringPolicy.setCurrentTime(givenTime)
+    rfa.setRollingPolicy(tbrp)
+    tbrp.start
+    rfa.start
+  }
+
+  type CheckFunction = ((String, Boolean, String) => Unit)
+  def genericTest(checkFunction: CheckFunction)(testId: String, compressionSuffix: String, fileOptionIsSet: Boolean, waitDuration: Int): Unit = {
+    val withCompression = compressionSuffix.length > 0
+    val fileName = if (fileOptionIsSet) testId2FileName(testId) else null;
+    initRFA(rfa1, fileName);
+
+    initTRBP(rfa1, tbrp1, randomOutputDir + testId + "-%d{"
+      + DATE_PATTERN_WITH_SECONDS + "}" + compressionSuffix, currentTime);
+
+    // compute the current filename
+    addExpectedFileName_ByDate(randomOutputDir, testId, getMillisOfCurrentPeriodsStart, withCompression);
+
+    incCurrentTime(1100);
+    tbrp1.timeBasedFileNamingAndTriggeringPolicy.setCurrentTime(currentTime);
+
+    for (i <- 0 until 3) {
+      rfa1.doAppend("Hello---" + i);
+      addExpectedFileNamedIfItsTime_ByDate(randomOutputDir, testId, withCompression && (i != 2))
+      incCurrentTime(500);
+      tbrp1.timeBasedFileNamingAndTriggeringPolicy.setCurrentTime(currentTime)
+      if (withCompression)
+        waitForCompression(tbrp1)
+    }
+    rfa1.stop
+
+    if (waitDuration != 0) {
+      doRestart(testId, fileOptionIsSet, waitDuration);
+    }
+
+    if (fileOptionIsSet) {
+      massageExpectedFilesToCorresponToCurrentTarget(testId + ".log")
+    }
+
+    checkFunction(testId, withCompression, compressionSuffix)
+  }
+
+  // defaultTest uses the defaultCheck function
+  val defaultTest = genericTest(defaultCheck)_
+
+  def defaultCheck(testId: String, withCompression: Boolean, compressionSuffix:String) = {
+    var i = 0;
+    for (fn <- expectedFilenameList) {
+      val suffix: String = if (withCompression) addGZIfNotLast(i, compressionSuffix) else ""
+      val witnessFileName: String = CoreTestConstants.TEST_DIR_PREFIX + "witness/rolling/tbr-" + testId + "." + i.toString + suffix
+      assertTrue(Compare.compare(fn, witnessFileName));
+      i += 1
+    }
+  }
+
+  def zCheck(testId: String, withCompression: Boolean, compressionSuffix:String) = {
+    val lastFile = expectedFilenameList.last
+    val witnessFileName: String = CoreTestConstants.TEST_DIR_PREFIX + "witness/rolling/tbr-" + testId
+    println(lastFile+"  "+witnessFileName)
+    assertTrue(Compare.compare(lastFile, witnessFileName));
+
+  }
+
+
+
+  def doRestart(testId: String, fileOptionIsSet: Boolean, waitDuration: Int) {
+    // change the timestamp of the currently actively file
+    var activeFile: File = new File(rfa1.getFile)
+    activeFile.setLastModified(currentTime)
+
+    incCurrentTime(waitDuration)
+
+    val fileName = if (fileOptionIsSet) testId2FileName(testId) else null;
+    initRFA(rfa2, fileName)
+    initTRBP(rfa2, tbrp2, randomOutputDir + testId + "-%d{" + DATE_PATTERN_WITH_SECONDS + "}", currentTime)
+    for (i <- 0 until 3) {
+      rfa2.doAppend("World---" + i)
+      addExpectedFileNamedIfItsTime_ByDate(randomOutputDir, testId, false)
+      incCurrentTime(100)
+      tbrp2.timeBasedFileNamingAndTriggeringPolicy.setCurrentTime(currentTime)
+    }
+  }
+
+  val NO_RESTART = 0
+  val WITH_RESTART = 1
+  val WITH_RESTART_AND_LONG_WAIT = 2000
+
+  @Test
+  def noCompression_FileBlank_NoRestart_1 = {
+    defaultTest("test1", "", FILE_OPTION_BLANK, NO_RESTART)
+  }
+
+  @Test
+  def withCompression_FileBlank_NoRestart_2 = {
+    defaultTest("test2", ".gz", FILE_OPTION_BLANK, NO_RESTART);
+  }
+
+  @Test
+  def noCompression_FileBlank_StopRestart_3 = {
+    defaultTest("test3", "", FILE_OPTION_BLANK, WITH_RESTART);
+  }
+
+  @Test
+  def noCompression_FileSet_StopRestart_4 = {
+    defaultTest("test4", "", FILE_OPTION_SET, WITH_RESTART);
+  }
+
+  @Test
+  def noCompression_FileSet_StopRestart_WithLongWait_4B = {
+    defaultTest("test4B", "", FILE_OPTION_SET, WITH_RESTART_AND_LONG_WAIT);
+  }
+
+  @Test
+  def noCompression_FileSet_NoRestart_5 = {
+    defaultTest("test5", "", FILE_OPTION_SET, NO_RESTART);
+  }
+
+  @Test
+  def withCompression_FileSet_NoRestart_6 = {
+    defaultTest("test6", ".gz", FILE_OPTION_SET, NO_RESTART);
+  }
+
+  @Test
+  def withMissingTargetDir = {
+    defaultTest("missingTargetDir", "", FILE_OPTION_SET, NO_RESTART);
+  }
+
+
+  @Test
+  def failed_rename: Unit = {
+
+    if(!Env.isWindows) return null
+
+    var fos: FileOutputStream = null
+    try {
+      val fileName = testId2FileName("failed_rename");
+      val file= new File(fileName)
+      file.getParentFile.mkdirs
+
+      fos = new FileOutputStream(fileName)
+      genericTest(zCheck)("failed_rename", "", FILE_OPTION_SET, NO_RESTART)
+
+    } finally {
+      StatusPrinter.print(context)
+      if(fos != null) fos.close;
+    }
+  }
+
+
+
 }
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 9c3d1f5..7b38899 100755
--- a/pom.xml
+++ b/pom.xml
@@ -1,25 +1,24 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" 
+<project xmlns="http://maven.apache.org/POM/4.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- 
+
   <modelVersion>4.0.0</modelVersion>
-  
+
   <groupId>ch.qos.logback</groupId>
   <artifactId>logback-parent</artifactId>
   <version>0.9.29-SNAPSHOT</version>
   <packaging>pom</packaging>
   <name>Logback-Parent</name>
-  
+
   <url>http://logback.qos.ch</url>
-  
+
   <organization>
     <name>QOS.ch</name>
     <url>http://www.qos.ch</url>
   </organization>
   <inceptionYear>2005</inceptionYear>
-    
-  
- 
+
+
   <modules>
     <module>logback-core</module>
     <module>logback-classic</module>
@@ -28,7 +27,7 @@
     <module>logback-examples</module>
   </modules>
 
- <properties>
+  <properties>
     <!-- slf4j.version property is used below, in
          logback-classic/pom.xml and in setClasspath.cmd -->
     <slf4j.version>1.6.1</slf4j.version>
@@ -37,7 +36,7 @@
     <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>  
+    <consolePlugin.version>1.1.0</consolePlugin.version>
   </properties>
 
   <dependencies>
@@ -55,7 +54,7 @@
     </dependency>
   </dependencies>
 
- 
+
   <dependencyManagement>
     <dependencies>
       <!-- Project modules -->
@@ -64,20 +63,20 @@
         <artifactId>logback-core</artifactId>
         <version>${project.version}</version>
       </dependency>
-      
+
       <dependency>
         <groupId>ch.qos.logback</groupId>
         <artifactId>logback-core</artifactId>
         <version>${project.version}</version>
         <type>test-jar</type>
       </dependency>
-      
+
       <dependency>
         <groupId>ch.qos.logback</groupId>
         <artifactId>logback-classic</artifactId>
         <version>${project.version}</version>
       </dependency>
-      
+
       <dependency>
         <groupId>ch.qos.logback</groupId>
         <artifactId>logback-access</artifactId>
@@ -122,7 +121,7 @@
         <groupId>postgresql</groupId>
         <artifactId>postgresql</artifactId>
         <version>8.4-701.jdbc4</version>
-      </dependency> 
+      </dependency>
       <dependency>
         <groupId>mysql</groupId>
         <artifactId>mysql-connector-java</artifactId>
@@ -149,17 +148,17 @@
         <groupId>org.mortbay.jetty</groupId>
         <artifactId>servlet-api-2.5</artifactId>
         <version>6.1.1</version>
-      </dependency>           
+      </dependency>
       <dependency>
         <groupId>org.apache.geronimo.specs</groupId>
         <artifactId>geronimo-jms_1.1_spec</artifactId>
         <version>1.0</version>
-      </dependency>    
+      </dependency>
       <dependency>
         <groupId>javax.servlet</groupId>
         <artifactId>servlet-api</artifactId>
         <version>2.5</version>
-      </dependency> 
+      </dependency>
 
       <dependency>
         <groupId>org.scala-lang</groupId>
@@ -169,9 +168,8 @@
 
     </dependencies>
   </dependencyManagement>
-  
- 
-  
+
+
   <build>
     <extensions>
       <extension>
@@ -180,8 +178,28 @@
         <version>1.0-beta-1</version>
       </extension>
     </extensions>
+
     <plugins>
       <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>build-helper-maven-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>add-test-source</id>
+            <phase>generate-sources</phase>
+            <goals>
+              <goal>add-test-source</goal>
+            </goals>
+            <configuration>
+              <sources>
+                <source>src/test/scala</source>
+              </sources>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+
+      <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-compiler-plugin</artifactId>
         <configuration>
@@ -203,20 +221,34 @@
       </plugin>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-idea-plugin</artifactId>
+        <artifactId>maven-eclipse-plugin</artifactId>
         <configuration>
-          <jdkLevel>1.5</jdkLevel>
           <downloadSources>true</downloadSources>
           <downloadJavadocs>true</downloadJavadocs>
+          <projectnatures>
+            <projectnature>org.scala-ide.sdt.core.scalanature</projectnature>
+            <projectnature>org.eclipse.jdt.core.javanature</projectnature>
+          </projectnatures>
+          <buildcommands>
+            <buildcommand>org.scala-ide.sdt.core.scalabuilder</buildcommand>
+          </buildcommands>
+<!--          <classpathContainers>
+            <classpathContainer>org.scala-ide.sdt.launching.SCALA_CONTAINER</classpathContainer>
+            <classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER
+            </classpathContainer>
+          </classpathContainers>
+          -->
+<!--          <excludes>
+            <exclude>org.scala-lang:scala-library</exclude>
+            <exclude>org.scala-lang:scala-compiler</exclude>
+          </excludes>
+    -->
+          <sourceIncludes>
+            <sourceInclude>**/*.scala</sourceInclude>
+            <sourceInclude>**/*.java</sourceInclude>
+          </sourceIncludes>
         </configuration>
       </plugin>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-eclipse-plugin</artifactId>
-        <configuration>
-          <downloadSources>true</downloadSources>
-        </configuration>
-      </plugin>   			
 
       <plugin>
         <artifactId>maven-assembly-plugin</artifactId>
@@ -234,10 +266,10 @@
           <outputDirectory>target/site/dist/</outputDirectory>
         </configuration>
       </plugin>
-    
+
     </plugins>
   </build>
-  
+
   <reporting>
     <plugins>
       <plugin>
@@ -258,19 +290,21 @@
           <linkJavadoc>true</linkJavadoc>
         </configuration>
       </plugin>
-      <plugin>  
+      <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>
           maven-project-info-reports-plugin
         </artifactId>
         <reportSets>
-          <reportSet><reports></reports></reportSet>
+          <reportSet>
+            <reports></reports>
+          </reportSet>
         </reportSets>
-			</plugin>
+      </plugin>
 
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-javadoc-plugin</artifactId>       
+        <artifactId>maven-javadoc-plugin</artifactId>
         <configuration>
           <aggregate>true</aggregate>
           <!--<linksource>true</linksource>-->
@@ -286,7 +320,9 @@
             </group>
             <group>
               <title>Logback Classic</title>
-              <packages>ch.qos.logback:ch.qos.logback.classic:ch.qos.logback.classic.*</packages>
+              <packages>
+                ch.qos.logback:ch.qos.logback.classic:ch.qos.logback.classic.*
+              </packages>
             </group>
             <group>
               <title>Logback Access</title>
@@ -301,35 +337,35 @@
               <packages>chapter*:joran*</packages>
             </group>
           </groups>
-        </configuration>      
+        </configuration>
       </plugin>
-      
+
     </plugins>
 
   </reporting>
 
   <scm>
     <connection>scm:svn:http://svn.qos.ch/repos/logback/trunk/</connection>
-    <developerConnection>scm:svn:https://svn.qos.ch/repos/logback/trunk/</developerConnection>
+    <developerConnection>scm:svn:https://svn.qos.ch/repos/logback/trunk/
+    </developerConnection>
     <url>http://svn.qos.ch/repos/logback/trunk/</url>
   </scm>
-   
+
   <distributionManagement>
     <site>
       <id>pixie</id>
       <url>scp://pixie.qos.ch/var/www/logback.qos.ch/htdocs/</url>
     </site>
-    
+
     <repository>
       <id>pixie</id>
       <url>scp://pixie.qos.ch/var/mvnrepo/</url>
     </repository>
-        
+
   </distributionManagement>
 
- 
-  
-  <profiles>    
+
+  <profiles>
     <profile>
       <id>testSkip</id>
       <properties>
@@ -337,7 +373,7 @@
       </properties>
     </profile>
     <profile>
-      <id>license</id>     
+      <id>license</id>
       <build>
         <plugins>
           <plugin>
@@ -355,7 +391,7 @@
               <useDefaultMapping>true</useDefaultMapping>
               <properties>
                 <year>1999</year>
-              </properties>     
+              </properties>
               <headerDefinitions>
                 <headerDefinition>src/main/javadocHeaders.xml</headerDefinition>
               </headerDefinitions>
@@ -377,10 +413,10 @@
           </releases>
         </pluginRepository>
       </pluginRepositories>
-   </profile>
+    </profile>
 
-   <profile>
-     <id>javadocjar</id>
+    <profile>
+      <id>javadocjar</id>
       <build>
         <plugins>
           <plugin>
@@ -399,6 +435,6 @@
       </build>
     </profile>
 
- </profiles>
+  </profiles>
 
 </project>

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

Summary of changes:
 logback-access/pom.xml                             |    6 +
 logback-classic/pom.xml                            |    6 +
 .../classic/joran/conditional/ConditionalTest.java |    5 +-
 .../ch/qos/logback/core/rolling/PackageTest.java   |    2 +-
 .../core/rolling/SizeAndTimeBasedFNATP_STest.scala |   27 --
 .../logback/core/rolling/RollingScaffolding.scala  |   23 +-
 .../core/rolling/SizeAndTimeBasedFNATP_STest.scala |  118 ++++++
 ...ing2Test.scala => TimeBasedRolling_STest.scala} |  401 ++++++++++----------
 pom.xml                                            |  140 +++++---
 9 files changed, 441 insertions(+), 287 deletions(-)
 delete mode 100644 logback-core/src/test/java/ch/qos/logback/core/rolling/SizeAndTimeBasedFNATP_STest.scala
 create mode 100644 logback-core/src/test/scala/ch/qos/logback/core/rolling/SizeAndTimeBasedFNATP_STest.scala
 rename logback-core/src/test/scala/ch/qos/logback/core/rolling/{TimeBasedRolling2Test.scala => TimeBasedRolling_STest.scala} (84%)


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


More information about the logback-dev mailing list