[logback-dev] [GIT] Logback: the generic, reliable, fast and flexible logging framework. branch, master, updated. v_0.9.27-2-ga0a585a

added by portage for gitosis-gentoo git-noreply at pixie.qos.ch
Tue Dec 28 19:36:26 CET 2010


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  a0a585a04d230d2fd8d3f3a68c2faf40dafdabe9 (commit)
      from  4a792d8efd47548dedbf838ef5d32531e9a928c8 (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=a0a585a04d230d2fd8d3f3a68c2faf40dafdabe9
http://github.com/ceki/logback/commit/a0a585a04d230d2fd8d3f3a68c2faf40dafdabe9

commit a0a585a04d230d2fd8d3f3a68c2faf40dafdabe9
Author: Ceki Gulcu <ceki at qos.ch>
Date:   Tue Dec 28 19:36:44 2010 +0100

    scala version of TimeBasedRollingTest now passes

diff --git a/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingTest.java b/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingTest.java
index 2cf9201..d327a28 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingTest.java
@@ -230,7 +230,10 @@ public class TimeBasedRollingTest extends ScaffoldingForRollingTests {
       tbrp2.timeBasedFileNamingAndTriggeringPolicy.setCurrentTime(currentTime);
     }
 
+    System.out.println("Before "+expectedFilenameList);
     massageExpectedFilesToCorresponToCurrentTarget("test4.log");
+    System.out.println("After "+expectedFilenameList);
+
 
     int i = 0;
     for (String fn : expectedFilenameList) {
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 ed78e3e..6b68d2d 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
@@ -31,6 +31,10 @@ trait RollingScaffolding {
   protected var nextRolloverThreshold: Long = 0;
   protected var expectedFilenameList: List[String] = Nil
 
+  val FILE_OPTION_SET = true
+  val FILE_OPTION_BLANK = false
+
+
   def setUpScaffolding: Unit = {
     context.setName("test")
     cal.set(Calendar.MILLISECOND, 333)
@@ -78,8 +82,21 @@ trait RollingScaffolding {
   }
 
   private[rolling] def waitForCompression(tbrp: TimeBasedRollingPolicy[AnyRef]): Unit = {
-      if (tbrp.future != null && !tbrp.future.isDone) {
-        tbrp.future.get(200, TimeUnit.MILLISECONDS)
-      }
+    if (tbrp.future != null && !tbrp.future.isDone) {
+      tbrp.future.get(200, TimeUnit.MILLISECONDS)
     }
-  }
\ No newline at end of file
+  }
+
+  private[rolling] def testId2FileName(testId: String): String = {
+    return randomOutputDir + testId + ".log"
+  }
+
+  // =========================================================================
+  // utility methods
+  // =========================================================================
+  private[rolling] def massageExpectedFilesToCorresponToCurrentTarget(file: String): Unit = {
+    expectedFilenameList = expectedFilenameList.dropRight(1)
+    expectedFilenameList +=  (randomOutputDir + file)
+  }
+
+}
\ No newline at end of file
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/TimeBasedRolling2Test.scala
index 06bd4af..6a90b50 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/TimeBasedRolling2Test.scala
@@ -19,11 +19,15 @@ import org.junit.Test
 import ch.qos.logback.core.util.Compare
 import ch.qos.logback.core.util.CoreTestConstants
 import ch.qos.logback.core.encoder.EchoEncoder
+import java.io.File
 
 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
@@ -50,11 +54,10 @@ class TimeBasedRolling2Test extends RollingScaffolding {
     rfa.start
   }
 
-  def genericTest(testId: String, compressionSuffix: String): Unit = {
+  def genericTest(testId: String, compressionSuffix: String, fileOptionIsSet: Boolean, waitDuration: Int): Unit = {
     val withCompression = compressionSuffix.length > 0
-    initRFA(rfa1, null);
-    println(randomOutputDir + testId + "-%d{"
-      + DATE_PATTERN_WITH_SECONDS + "}" + compressionSuffix )
+    val fileName = if (fileOptionIsSet) testId2FileName(testId) else null;
+    initRFA(rfa1, fileName);
 
     initTRBP(rfa1, tbrp1, randomOutputDir + testId + "-%d{"
       + DATE_PATTERN_WITH_SECONDS + "}" + compressionSuffix, currentTime);
@@ -67,16 +70,25 @@ class TimeBasedRolling2Test extends RollingScaffolding {
 
     for (i <- 0 until 3) {
       rfa1.doAppend("Hello---" + i);
-      addExpectedFileNamedIfItsTime_ByDate(randomOutputDir, testId, withCompression && (i !=2))
+      addExpectedFileNamedIfItsTime_ByDate(randomOutputDir, testId, withCompression && (i != 2))
       incCurrentTime(500);
       tbrp1.timeBasedFileNamingAndTriggeringPolicy.setCurrentTime(currentTime)
-      if(withCompression)
+      if (withCompression)
         waitForCompression(tbrp1)
     }
+    rfa1.stop
+
+    if (waitDuration != 0) {
+      doRestart(testId, fileOptionIsSet, waitDuration);
+    }
+
+    if (fileOptionIsSet) {
+      massageExpectedFilesToCorresponToCurrentTarget(testId + ".log")
+    }
 
     var i = 0;
     for (fn <- expectedFilenameList) {
-      val suffix: String = if(withCompression)  addGZIfNotLast(i, compressionSuffix) else ""
+      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
@@ -84,21 +96,65 @@ class TimeBasedRolling2Test extends RollingScaffolding {
 
   }
 
-  /**
-   * Test rolling without compression, file option left blank, no stop/start
-   */
+  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 = {
-    genericTest("test1", "")
+    genericTest("test1", "", FILE_OPTION_BLANK, NO_RESTART)
   }
 
-  /**
-   * With compression, file option left blank, no stop/restart
-   */
   @Test
   def withCompression_FileBlank_NoRestart_2 = {
-    genericTest("test2", ".gz");
+    genericTest("test2", ".gz", FILE_OPTION_BLANK, NO_RESTART);
+  }
+
+  @Test
+  def noCompression_FileBlank_StopRestart_3 = {
+    genericTest("test3", "", FILE_OPTION_BLANK, WITH_RESTART);
+  }
+
+  @Test
+  def noCompression_FileSet_StopRestart_4 = {
+    genericTest("test4", "", FILE_OPTION_SET, WITH_RESTART);
+  }
+
+  @Test
+  def noCompression_FileSet_StopRestart_WithLongWait_4B = {
+    genericTest("test4B", "", FILE_OPTION_SET, WITH_RESTART_AND_LONG_WAIT);
   }
 
+  @Test
+  def noCompression_FileSet_NoRestart_5 = {
+    genericTest("test5", "", FILE_OPTION_SET, NO_RESTART);
+  }
 
+  @Test
+  def withCompression_FileSet_NoRestart_6 = {
+    genericTest("test6", ".gz", FILE_OPTION_SET, NO_RESTART);
+  }
+
+  @Test
+  def withMissingTargetDir = {
+    genericTest("missingTargetDir", "", FILE_OPTION_SET, NO_RESTART);
+  }
 }
\ No newline at end of file
diff --git a/logback-core/src/test/witness/rolling/tbr-missingTargetDir.0 b/logback-core/src/test/witness/rolling/tbr-missingTargetDir.0
new file mode 100644
index 0000000..e69de29
diff --git a/logback-core/src/test/witness/rolling/tbr-missingTargetDir.1 b/logback-core/src/test/witness/rolling/tbr-missingTargetDir.1
new file mode 100644
index 0000000..aea23e8
--- /dev/null
+++ b/logback-core/src/test/witness/rolling/tbr-missingTargetDir.1
@@ -0,0 +1,2 @@
+Hello---0
+Hello---1
\ No newline at end of file
diff --git a/logback-core/src/test/witness/rolling/tbr-missingTargetDir.2 b/logback-core/src/test/witness/rolling/tbr-missingTargetDir.2
new file mode 100644
index 0000000..c32a130
--- /dev/null
+++ b/logback-core/src/test/witness/rolling/tbr-missingTargetDir.2
@@ -0,0 +1 @@
+Hello---2

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

Summary of changes:
 .../logback/core/rolling/TimeBasedRollingTest.java |    3 +
 .../logback/core/rolling/RollingScaffolding.scala  |   25 +++++-
 .../core/rolling/TimeBasedRolling2Test.scala       |   86 ++++++++++++++++----
 .../{tbr-test1.0 => tbr-missingTargetDir.0}        |    0
 .../{tbr-test4B.1 => tbr-missingTargetDir.1}       |    0
 .../{tbr-test1.2 => tbr-missingTargetDir.2}        |    0
 6 files changed, 95 insertions(+), 19 deletions(-)
 copy logback-core/src/test/witness/rolling/{tbr-test1.0 => tbr-missingTargetDir.0} (100%)
 copy logback-core/src/test/witness/rolling/{tbr-test4B.1 => tbr-missingTargetDir.1} (100%)
 copy logback-core/src/test/witness/rolling/{tbr-test1.2 => tbr-missingTargetDir.2} (100%)


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


More information about the logback-dev mailing list