[logback-dev] svn commit: r2376 - in logback/trunk/logback-core/src: main/java/ch/qos/logback/core/rolling test/java/ch/qos/logback/core/rolling test/witness/rolling

noreply.ceki at qos.ch noreply.ceki at qos.ch
Fri Jul 24 10:07:41 CEST 2009


Author: ceki
Date: Fri Jul 24 10:07:40 2009
New Revision: 2376

Added:
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/DefaultTimeBasedTriggeringPolicy.java
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/NamingAndTriggeringPolicy.java
   logback/trunk/logback-core/src/test/witness/rolling/tbr-test2.0.gz   (contents, props changed)
   logback/trunk/logback-core/src/test/witness/rolling/tbr-test2.1.gz   (contents, props changed)
   logback/trunk/logback-core/src/test/witness/rolling/tbr-test2.2
   logback/trunk/logback-core/src/test/witness/rolling/tbr-test3.0
      - copied unchanged from r2372, /logback/trunk/logback-core/src/test/witness/rolling/tbr-test2.0
   logback/trunk/logback-core/src/test/witness/rolling/tbr-test3.1
      - copied unchanged from r2372, /logback/trunk/logback-core/src/test/witness/rolling/tbr-test2.1
   logback/trunk/logback-core/src/test/witness/rolling/tbr-test3.2
      - copied unchanged from r2372, /logback/trunk/logback-core/src/test/witness/rolling/tbr-test2.2
   logback/trunk/logback-core/src/test/witness/rolling/tbr-test3.3
      - copied unchanged from r2372, /logback/trunk/logback-core/src/test/witness/rolling/tbr-test2.3
Removed:
   logback/trunk/logback-core/src/test/witness/rolling/tbr-test2.0
   logback/trunk/logback-core/src/test/witness/rolling/tbr-test2.1
   logback/trunk/logback-core/src/test/witness/rolling/tbr-test2.3
   logback/trunk/logback-core/src/test/witness/rolling/tbr-test3.0.gz
   logback/trunk/logback-core/src/test/witness/rolling/tbr-test3.1.gz
Modified:
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedRollingPolicy.java
   logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/RenamingTest.java
   logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingTest.java

Log:
Significant refactoring of TimeBasedRollingPolicy. Most of the work related to triggerring has
moved a new class called DefaultTimedBasedTriggeringPolicy. Related to LBCORE-61.

The File attribute of RollingFileAppender is _now_ ignored! As a consequence, 
3 tests in TimeBasedRollingTest have been removed/disabled.

WARNING: ongoing and unpolished work.

Added: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/DefaultTimeBasedTriggeringPolicy.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/DefaultTimeBasedTriggeringPolicy.java	Fri Jul 24 10:07:40 2009
@@ -0,0 +1,101 @@
+package ch.qos.logback.core.rolling;
+
+import java.io.File;
+import java.util.Date;
+
+import ch.qos.logback.core.rolling.helper.DateTokenConverter;
+import ch.qos.logback.core.rolling.helper.FileNamePattern;
+import ch.qos.logback.core.rolling.helper.RollingCalendar;
+import ch.qos.logback.core.spi.ContextAwareBase;
+
+public class DefaultTimeBasedTriggeringPolicy<E> extends ContextAwareBase
+    implements NamingAndTriggeringPolicy<E> {
+
+  FileNamePattern fileNamePattern;
+  String elapsedPeriodsFileName;
+  FileNamePattern activeFileNamePattern;
+  RollingCalendar rc;
+  long currentTime;
+  long nextCheck;
+  // indicate whether the time has been forced or not
+  boolean isTimeForced = false;
+  Date lastCheck = null;
+  boolean started = false;
+
+  public void setCurrentTime(long timeInMillis) {
+    currentTime = timeInMillis;
+    isTimeForced = true;
+  }
+
+  public long getCurrentTime() {
+    // if time is forced return the time set by user
+    if (isTimeForced) {
+      return currentTime;
+    } else {
+      return System.currentTimeMillis();
+    }
+  }
+
+  public boolean isStarted() {
+    return started;
+  }
+
+  public void start() {
+
+    DateTokenConverter dtc = fileNamePattern.getDateTokenConverter();
+
+    if (dtc == null) {
+      throw new IllegalStateException("FileNamePattern ["
+          + fileNamePattern.getPattern()
+          + "] does not contain a valid DateToken");
+    }
+
+    rc = new RollingCalendar();
+    rc.init(dtc.getDatePattern());
+    addInfo("The date pattern is '" + dtc.getDatePattern()
+        + "' from file name pattern '" + fileNamePattern.getPattern() + "'.");
+    rc.printPeriodicity(this);
+
+    // lastCheck can be set by test classes
+    // if it has not been set, we set it here
+    if (lastCheck == null) {
+      lastCheck = new Date();
+      lastCheck.setTime(getCurrentTime());
+    }
+    nextCheck = rc.getNextTriggeringMillis(lastCheck);
+
+  }
+
+  public void stop() {
+    started = false;
+  }
+
+  // allow Test classes to act on the lastCheck field to simulate old
+  // log files needing rollover
+  void setLastCheck(Date _lastCheck) {
+    this.lastCheck = _lastCheck;
+  }
+
+  public String getElapsedPeriodsFileName() {
+    return elapsedPeriodsFileName;
+  }
+
+  public boolean isTriggeringEvent(File activeFile, final E event) {
+    long time = getCurrentTime();
+
+    if (time >= nextCheck) {
+      // We set the elapsedPeriodsFileName before we set the 'lastCheck'
+      // variable
+      // The elapsedPeriodsFileName corresponds to the file name of the period
+      // that just elapsed.
+      elapsedPeriodsFileName = activeFileNamePattern.convertDate(lastCheck);
+
+      lastCheck.setTime(time);
+      nextCheck = rc.getNextTriggeringMillis(lastCheck);
+      return true;
+    } else {
+      return false;
+    }
+  }
+
+}

Added: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/NamingAndTriggeringPolicy.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/NamingAndTriggeringPolicy.java	Fri Jul 24 10:07:40 2009
@@ -0,0 +1,16 @@
+/**
+ * Logback: the generic, reliable, fast and flexible logging framework.
+ * 
+ * Copyright (C) 2000-2009, 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.core.rolling;
+
+public interface NamingAndTriggeringPolicy<E> extends TriggeringPolicy<E> {
+
+  String getElapsedPeriodsFileName();
+}

Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedRollingPolicy.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedRollingPolicy.java	(original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/rolling/TimeBasedRollingPolicy.java	Fri Jul 24 10:07:40 2009
@@ -17,10 +17,8 @@
 import ch.qos.logback.core.rolling.helper.AsynchronousCompressor;
 import ch.qos.logback.core.rolling.helper.CompressionMode;
 import ch.qos.logback.core.rolling.helper.Compressor;
-import ch.qos.logback.core.rolling.helper.DateTokenConverter;
 import ch.qos.logback.core.rolling.helper.FileNamePattern;
 import ch.qos.logback.core.rolling.helper.RenameUtil;
-import ch.qos.logback.core.rolling.helper.RollingCalendar;
 import ch.qos.logback.core.rolling.helper.TimeBasedCleaner;
 
 /**
@@ -38,13 +36,6 @@
   static final String FNP_NOT_SET = "The FileNamePattern option must be set before using TimeBasedRollingPolicy. ";
   static final int NO_DELETE_HISTORY = 0;
 
-  RollingCalendar rc;
-  long currentTime;
-  long nextCheck;
-  // indicate whether the time has been forced or not
-  boolean isTimeForced = false;
-  Date lastCheck = null;
-  String elapsedPeriodsFileName;
   FileNamePattern activeFileNamePattern;
   Compressor compressor;
   RenameUtil renameUtil = new RenameUtil();
@@ -53,27 +44,32 @@
   int maxHistory = NO_DELETE_HISTORY;
   TimeBasedCleaner tbCleaner;
 
-  public void setCurrentTime(long timeInMillis) {
-    currentTime = timeInMillis;
-    isTimeForced = true;
-  }
-
-  public long getCurrentTime() {
-    // if time is forced return the time set by user
-    if (isTimeForced) {
-      return currentTime;
-    } else {
-      return System.currentTimeMillis();
-    }
-  }
+  DefaultTimeBasedTriggeringPolicy<E> timeBasedTriggering = new DefaultTimeBasedTriggeringPolicy<E>();
+  
+//  public void setCurrentTime(long timeInMillis) {
+//    currentTime = timeInMillis;
+//    isTimeForced = true;
+//  }
+//
+//  public long getCurrentTime() {
+//    // if time is forced return the time set by user
+//    if (isTimeForced) {
+//      return currentTime;
+//    } else {
+//      return System.currentTimeMillis();
+//    }
+//  }
 
   public void start() {
     // set the LR for our utility object
     renameUtil.setContext(this.context);
 
+    timeBasedTriggering.setContext(context);
+    
     // find out period from the filename pattern
     if (fileNamePatternStr != null) {
       fileNamePattern = new FileNamePattern(fileNamePatternStr, this.context);
+      timeBasedTriggering.fileNamePattern = fileNamePattern;
       determineCompressionMode();
     } else {
       addWarn(FNP_NOT_SET);
@@ -82,14 +78,7 @@
           + CoreConstants.SEE_FNP_NOT_SET);
     }
 
-    DateTokenConverter dtc = fileNamePattern.getDateTokenConverter();
-
-    if (dtc == null) {
-      throw new IllegalStateException("FileNamePattern ["
-          + fileNamePattern.getPattern()
-          + "] does not contain a valid DateToken");
-    }
-
+    
     compressor = new Compressor(compressionMode);
     compressor.setContext(context);
 
@@ -107,51 +96,36 @@
     case NONE:
       activeFileNamePattern = fileNamePattern;
     }
-
+    
     addInfo("Will use the pattern " + activeFileNamePattern
         + " for the active file");
 
-    rc = new RollingCalendar();
-    rc.init(dtc.getDatePattern());
-    addInfo("The date pattern is '" + dtc.getDatePattern()
-        + "' from file name pattern '" + fileNamePattern.getPattern() + "'.");
-    rc.printPeriodicity(this);
-
-    // lastCheck can be set by test classes
-    // if it has not been set, we set it here
-    if (lastCheck == null) {
-      lastCheck = new Date();
-      lastCheck.setTime(getCurrentTime());
-      if (getParentsRawFileProperty() != null) {
-        File currentFile = new File(getParentsRawFileProperty());
-        if (currentFile.exists() && currentFile.canRead()) {
-          lastCheck.setTime(currentFile.lastModified());
-        }
-      }
-    }
-    nextCheck = rc.getNextTriggeringMillis(lastCheck);
-
+    timeBasedTriggering.activeFileNamePattern = activeFileNamePattern;
+    timeBasedTriggering.start();
+    
     if (maxHistory != NO_DELETE_HISTORY) {
-      tbCleaner = new TimeBasedCleaner(fileNamePattern, rc, maxHistory);
+      tbCleaner = new TimeBasedCleaner(fileNamePattern, timeBasedTriggering.rc, maxHistory);
     }
   }
 
-  // allow Test classes to act on the lastCheck field to simulate old
-  // log files needing rollover
-  void setLastCheck(Date _lastCheck) {
-    this.lastCheck = _lastCheck;
-  }
 
-  boolean rolloverTargetIsParentFile() {
-    return (getParentsRawFileProperty() != null && getParentsRawFileProperty()
-        .equals(elapsedPeriodsFileName));
+  public long getCurrentTime() {
+    return timeBasedTriggering.getCurrentTime();
   }
-
+  public void setCurrentTime(long timeInMillis) {
+    timeBasedTriggering.setCurrentTime(timeInMillis);
+  }
+  void setLastCheck(Date _lastCheck) {
+    timeBasedTriggering.setLastCheck(_lastCheck);
+  }
+  
   public void rollover() throws RolloverFailure {
 
     // when rollover is called the elapsed period's file has
     // been already closed. This is a working assumption of this method.
 
+    String elapsedPeriodsFileName = timeBasedTriggering.getElapsedPeriodsFileName();
+    
     if (compressionMode == CompressionMode.NONE) {
       if (getParentsRawFileProperty() != null) {
         renameUtil.rename(getParentsRawFileProperty(), elapsedPeriodsFileName);
@@ -165,7 +139,7 @@
     }
 
     if (tbCleaner != null) {
-      tbCleaner.clean(new Date(getCurrentTime()));
+      tbCleaner.clean(new Date(timeBasedTriggering.getCurrentTime()));
     }
   }
 
@@ -204,36 +178,35 @@
    * 
    */
   public String getActiveFileName() {
-    String parentsRawFileProperty = getParentsRawFileProperty();
-
-    if (parentsRawFileProperty != null) {
-      return parentsRawFileProperty;
-    } else {
-      return getLatestPeriodsFileName();
-    }
+    
+      return activeFileNamePattern.convertDate(timeBasedTriggering.lastCheck);
+    
   }
 
-  // get the active file name for the current (latest) period
-  private String getLatestPeriodsFileName() {
-    return activeFileNamePattern.convertDate(lastCheck);
-  }
+//  // get the active file name for the current (latest) period
+//  private String getLatestPeriodsFileName() {
+//    return activeFileNamePattern.convertDate(lastCheck);
+//  }
 
   public boolean isTriggeringEvent(File activeFile, final E event) {
-    long time = getCurrentTime();
-
-    if (time >= nextCheck) {
-      // We set the elapsedPeriodsFileName before we set the 'lastCheck'
-      // variable
-      // The elapsedPeriodsFileName corresponds to the file name of the period
-      // that just elapsed.
-      elapsedPeriodsFileName = activeFileNamePattern.convertDate(lastCheck);
-
-      lastCheck.setTime(time);
-      nextCheck = rc.getNextTriggeringMillis(lastCheck);
-      return true;
-    } else {
-      return false;
-    }
+    
+    return timeBasedTriggering.isTriggeringEvent(activeFile, event);
+    
+//    long time = getCurrentTime();
+//
+//    if (time >= nextCheck) {
+//      // We set the elapsedPeriodsFileName before we set the 'lastCheck'
+//      // variable
+//      // The elapsedPeriodsFileName corresponds to the file name of the period
+//      // that just elapsed.
+//      elapsedPeriodsFileName = activeFileNamePattern.convertDate(lastCheck);
+//
+//      lastCheck.setTime(time);
+//      nextCheck = rc.getNextTriggeringMillis(lastCheck);
+//      return true;
+//    } else {
+//      return false;
+//    }
   }
 
   /**

Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/RenamingTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/RenamingTest.java	(original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/RenamingTest.java	Fri Jul 24 10:07:40 2009
@@ -54,7 +54,6 @@
     RollingFileAppender<Object> rfa = new RollingFileAppender<Object>();
     rfa.setLayout(layout);
     rfa.setContext(context);
-    rfa.setFile(CoreTestConstants.OUTPUT_DIR_PREFIX + "test.log");
 
     // rollover by the second
     String datePattern = "yyyy-MM-dd_HH_mm_ss";
@@ -64,7 +63,6 @@
     TimeBasedRollingPolicy tbrp = new TimeBasedRollingPolicy();
     tbrp.setFileNamePattern(CoreTestConstants.OUTPUT_DIR_PREFIX + "test-%d{"
         + datePattern + "}");
-    // tbrp.setActiveFileName("src/test/output/test.log");
     tbrp.setContext(context);
     tbrp.setParent(rfa);
     tbrp.start();
@@ -72,22 +70,24 @@
     rfa.setRollingPolicy(tbrp);
     rfa.start();
 
-    // StatusPrinter.print(context.getStatusManager());
-    Calendar cal = Calendar.getInstance();
 
+    Calendar cal0 = Calendar.getInstance();
     rfa.doAppend("Hello 0");
+    
     DelayerUtil.delayUntilNextSecond(50);
+    
+    Calendar cal1 = Calendar.getInstance();
     rfa.doAppend("Hello 1");
 
     filenames[0] = CoreTestConstants.OUTPUT_DIR_PREFIX + "test-"
-        + sdf.format(cal.getTime());
-    filenames[1] = CoreTestConstants.OUTPUT_DIR_PREFIX + "test.log";
-
+        + sdf.format(cal0.getTime());
+    filenames[1] = CoreTestConstants.OUTPUT_DIR_PREFIX + "test-"
+        + sdf.format(cal1.getTime());
+    
+  
     for (int i = 0; i < filenames.length; i++) {
-      // System.out.println("before i=" + i);
       assertTrue(Compare.compare(filenames[i], CoreTestConstants.TEST_DIR_PREFIX
           + "witness/rolling/renaming." + i));
-      // System.out.println("post i=" + i);
     }
   }
 }

Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingTest.java	(original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingTest.java	Fri Jul 24 10:07:40 2009
@@ -42,8 +42,8 @@
  * <pre>
  *               Compression     file option    Stop/Restart 
  *    Test1      NO              BLANK           NO
- *    Test2      NO              BLANK           YES
- *    Test3      YES             BLANK           NO
+ *    Test2      YES             BLANK           NO
+ *    Test3      NO              BLANK           YES
  *    Test4      NO              SET             YES 
  *    Test5      NO              SET             NO
  *    Test6      YES             SET             NO
@@ -148,55 +148,11 @@
   }
 
   /**
-   * No compression, file option left blank, with stop/restart,
-   */
-  @Test
-  public void noCompression_FileBlank_StopRestart_2() throws Exception {
-    String testId = "test2";
-
-    initRFA(rfa1, null);
-    initTRBP(rfa1, tbrp1, CoreTestConstants.OUTPUT_DIR_PREFIX + testId + "-%d{"
-        + DATE_PATTERN + "}", currentTime, 0);
-
-    // a new file is created by virtue of rfa.start();
-    addExpectedFileName_ByDate(testId, getDateOfCurrentPeriodsStart(), false);
-
-    incCurrentTime(1100);
-    tbrp1.setCurrentTime(currentTime);
-
-    for (int i = 0; i <= 2; i++) {
-      rfa1.doAppend("Hello---" + i);
-      addExpectedFileNamedIfItsTime_ByDate(testId, false);
-      incCurrentTime(500);
-      tbrp1.setCurrentTime(currentTime);
-    }
-
-    rfa1.stop();
-
-    initRFA(rfa2, null);
-    initTRBP(rfa2, tbrp2, CoreTestConstants.OUTPUT_DIR_PREFIX + testId + "-%d{"
-        + DATE_PATTERN + "}", tbrp1.getCurrentTime(), 0);
-
-    for (int i = 0; i <= 2; i++) {
-      addExpectedFileNamedIfItsTime_ByDate(testId, false);
-      rfa2.doAppend("World---" + i);
-      incCurrentTime(100);
-      tbrp2.setCurrentTime(currentTime);
-    }
-
-    int i = 0;
-    for (String fn : expectedFilenameList) {
-      assertTrue(Compare.compare(fn, CoreTestConstants.TEST_DIR_PREFIX
-          + "witness/rolling/tbr-" + testId + "." + i++));
-    }
-  }
-
-  /**
    * With compression, file option left blank, no stop/restart
    */
   @Test
-  public void withCompression_FileBlank_NoRestart_3() throws Exception {
-    String testId = "test3";
+  public void withCompression_FileBlank_NoRestart_2() throws Exception {
+    String testId = "test2";
     initRFA(rfa1, null);
     initTRBP(rfa1, tbrp1, CoreTestConstants.OUTPUT_DIR_PREFIX + testId + "-%d{"
         + DATE_PATTERN + "}.gz", currentTime, 0);
@@ -224,15 +180,17 @@
   }
 
   /**
-   * Without compression, file option set, with stop/restart
+   * No compression, file option left blank, with stop/restart,
    */
   @Test
-  public void noCompression_FileSet_StopRestart_4() throws Exception {
-    String testId = "test4";
-    initRFA(rfa1, testId2FileName(testId));
+  public void noCompression_FileBlank_StopRestart_3() throws Exception {
+    String testId = "test3";
+
+    initRFA(rfa1, null);
     initTRBP(rfa1, tbrp1, CoreTestConstants.OUTPUT_DIR_PREFIX + testId + "-%d{"
         + DATE_PATTERN + "}", currentTime, 0);
 
+    // a new file is created by virtue of rfa.start();
     addExpectedFileName_ByDate(testId, getDateOfCurrentPeriodsStart(), false);
 
     incCurrentTime(1100);
@@ -247,140 +205,182 @@
 
     rfa1.stop();
 
-    initRFA(rfa2, testId2FileName(testId));
+    initRFA(rfa2, null);
     initTRBP(rfa2, tbrp2, CoreTestConstants.OUTPUT_DIR_PREFIX + testId + "-%d{"
-        + DATE_PATTERN + "}", currentTime, currentTime);
-
-    for (int i = 0; i <= 2; i++) {
-      rfa2.doAppend("World---" + i);
-      addExpectedFileNamedIfItsTime_ByDate(testId, false);
-      incCurrentTime(100);
-      tbrp2.setCurrentTime(currentTime);
-    }
-
-    massageExpectedFilesToCorresponToCurrentTarget("test4.log");
-
-    int i = 0;
-    for (String fn : expectedFilenameList) {
-      assertTrue(Compare.compare(fn, CoreTestConstants.TEST_DIR_PREFIX
-          + "witness/rolling/tbr-" + testId + "." + i++));
-    }
-  }
-
-  @Test
-  public void noCompression_FileSet_StopRestart_WithLongWait_4B()
-      throws Exception {
-    String testId = "test4B";
-    initRFA(rfa1, testId2FileName(testId));
-    initTRBP(rfa1, tbrp1, CoreTestConstants.OUTPUT_DIR_PREFIX + testId + "-%d{"
-        + DATE_PATTERN + "}", currentTime, 0);
-
-    addExpectedFileName_ByDate(testId, getDateOfCurrentPeriodsStart(), false);
-
-    incCurrentTime(1100);
-    tbrp1.setCurrentTime(currentTime);
+        + DATE_PATTERN + "}", tbrp1.getCurrentTime(), 0);
 
     for (int i = 0; i <= 2; i++) {
-      rfa1.doAppend("Hello---" + i);
       addExpectedFileNamedIfItsTime_ByDate(testId, false);
-      incCurrentTime(500);
-      tbrp1.setCurrentTime(currentTime);
-    }
-
-    rfa1.stop();
-
-    long fileTimestamp = currentTime;
-    incCurrentTime(2000);
-
-    initRFA(rfa2, CoreTestConstants.OUTPUT_DIR_PREFIX + "test4B.log");
-    initTRBP(rfa2, tbrp2, CoreTestConstants.OUTPUT_DIR_PREFIX + testId +"-%d{"
-        + DATE_PATTERN + "}", currentTime, fileTimestamp);
-
-    for (int i = 0; i <= 2; i++) {
       rfa2.doAppend("World---" + i);
-      addExpectedFileNamedIfItsTime_ByDate(testId, false);
       incCurrentTime(100);
       tbrp2.setCurrentTime(currentTime);
     }
 
-    massageExpectedFilesToCorresponToCurrentTarget("test4B.log");
-
-    int i = 0;
-    for (String fn : expectedFilenameList) {
-      assertTrue(Compare.compare(fn, CoreTestConstants.TEST_DIR_PREFIX
-          + "witness/rolling/tbr-test4B." + i++));
-    }
-
-  }
-
-  /**
-   * No compression, file option set, without stop/restart
-   */
-  @Test
-  public void noCompression_FileSet_NoRestart_5() throws Exception {
-    String testId = "test5";
-
-    initRFA(rfa1, testId2FileName(testId));
-    initTRBP(rfa1, tbrp1, CoreTestConstants.OUTPUT_DIR_PREFIX + testId + "-%d{"
-        + DATE_PATTERN + "}", currentTime, 0);
-
-    addExpectedFileName_ByDate(testId, getDateOfCurrentPeriodsStart(), false);
-
-    incCurrentTime(1100);
-    tbrp1.setCurrentTime(currentTime);
-
-    for (int i = 0; i < 3; i++) {
-      rfa1.doAppend("Hello---" + i);
-      addExpectedFileNamedIfItsTime_ByDate(testId, false);
-      incCurrentTime(500);
-      tbrp1.setCurrentTime(currentTime);
-    }
-
-    massageExpectedFilesToCorresponToCurrentTarget("test5.log");
-
-    int i = 0;
-    for (String fn : expectedFilenameList) {
-      assertTrue(Compare.compare(fn, CoreTestConstants.TEST_DIR_PREFIX
-          + "witness/rolling/tbr-test5." + i++));
-    }
-  }
-
-  /**
-   * With compression, file option set, no stop/restart,
-   */
-  @Test
-  public void withCompression_FileSet_NoRestart_6() throws Exception {
-
-    String testId = "test6";
-
-    initRFA(rfa1, testId2FileName(testId));
-    initTRBP(rfa1, tbrp1, CoreTestConstants.OUTPUT_DIR_PREFIX + testId + "-%d{"
-        + DATE_PATTERN + "}.gz", currentTime, 0);
-
-    addExpectedFileName_ByDate(testId, getDateOfCurrentPeriodsStart(), true);
-
-    incCurrentTime(1100);
-    tbrp1.setCurrentTime(currentTime);
-
-    for (int i = 0; i < 3; i++) {
-      rfa1.doAppend("Hello---" + i);
-      addExpectedFileNamedIfItsTime_ByDate(testId, true);
-      incCurrentTime(500);
-      tbrp1.setCurrentTime(currentTime);
-    }
-
-    // wait for the compression task to finish
-    tbrp1.future.get(1000, TimeUnit.MILLISECONDS);
-
-    massageExpectedFilesToCorresponToCurrentTarget("test6.log");
-
     int i = 0;
     for (String fn : expectedFilenameList) {
       assertTrue(Compare.compare(fn, CoreTestConstants.TEST_DIR_PREFIX
-          + "witness/rolling/tbr-" + testId + "." + i + addGZIfNotLast(i)));
-      i++;
+          + "witness/rolling/tbr-" + testId + "." + i++));
     }
   }
+//  
+//  /**
+//   * Without compression, file option set, with stop/restart
+//   */
+//  @Test
+//  public void noCompression_FileSet_StopRestart_4() throws Exception {
+//    String testId = "test4";
+//    initRFA(rfa1, testId2FileName(testId));
+//    initTRBP(rfa1, tbrp1, CoreTestConstants.OUTPUT_DIR_PREFIX + testId + "-%d{"
+//        + DATE_PATTERN + "}", currentTime, 0);
+//
+//    addExpectedFileName_ByDate(testId, getDateOfCurrentPeriodsStart(), false);
+//
+//    incCurrentTime(1100);
+//    tbrp1.setCurrentTime(currentTime);
+//
+//    for (int i = 0; i <= 2; i++) {
+//      rfa1.doAppend("Hello---" + i);
+//      addExpectedFileNamedIfItsTime_ByDate(testId, false);
+//      incCurrentTime(500);
+//      tbrp1.setCurrentTime(currentTime);
+//    }
+//
+//    rfa1.stop();
+//
+//    initRFA(rfa2, testId2FileName(testId));
+//    initTRBP(rfa2, tbrp2, CoreTestConstants.OUTPUT_DIR_PREFIX + testId + "-%d{"
+//        + DATE_PATTERN + "}", currentTime, currentTime);
+//
+//    for (int i = 0; i <= 2; i++) {
+//      rfa2.doAppend("World---" + i);
+//      addExpectedFileNamedIfItsTime_ByDate(testId, false);
+//      incCurrentTime(100);
+//      tbrp2.setCurrentTime(currentTime);
+//    }
+//
+//    massageExpectedFilesToCorresponToCurrentTarget("test4.log");
+//
+//    int i = 0;
+//    for (String fn : expectedFilenameList) {
+//      assertTrue(Compare.compare(fn, CoreTestConstants.TEST_DIR_PREFIX
+//          + "witness/rolling/tbr-" + testId + "." + i++));
+//    }
+//  }
+//
+//  @Test
+//  public void noCompression_FileSet_StopRestart_WithLongWait_4B()
+//      throws Exception {
+//    String testId = "test4B";
+//    initRFA(rfa1, testId2FileName(testId));
+//    initTRBP(rfa1, tbrp1, CoreTestConstants.OUTPUT_DIR_PREFIX + testId + "-%d{"
+//        + DATE_PATTERN + "}", currentTime, 0);
+//
+//    addExpectedFileName_ByDate(testId, getDateOfCurrentPeriodsStart(), false);
+//
+//    incCurrentTime(1100);
+//    tbrp1.setCurrentTime(currentTime);
+//
+//    for (int i = 0; i <= 2; i++) {
+//      rfa1.doAppend("Hello---" + i);
+//      addExpectedFileNamedIfItsTime_ByDate(testId, false);
+//      incCurrentTime(500);
+//      tbrp1.setCurrentTime(currentTime);
+//    }
+//
+//    rfa1.stop();
+//
+//    long fileTimestamp = currentTime;
+//    incCurrentTime(2000);
+//
+//    initRFA(rfa2, CoreTestConstants.OUTPUT_DIR_PREFIX + "test4B.log");
+//    initTRBP(rfa2, tbrp2, CoreTestConstants.OUTPUT_DIR_PREFIX + testId +"-%d{"
+//        + DATE_PATTERN + "}", currentTime, fileTimestamp);
+//
+//    for (int i = 0; i <= 2; i++) {
+//      rfa2.doAppend("World---" + i);
+//      addExpectedFileNamedIfItsTime_ByDate(testId, false);
+//      incCurrentTime(100);
+//      tbrp2.setCurrentTime(currentTime);
+//    }
+//
+//    massageExpectedFilesToCorresponToCurrentTarget("test4B.log");
+//
+//    int i = 0;
+//    for (String fn : expectedFilenameList) {
+//      assertTrue(Compare.compare(fn, CoreTestConstants.TEST_DIR_PREFIX
+//          + "witness/rolling/tbr-test4B." + i++));
+//    }
+//
+//  }
+//
+//  /**
+//   * No compression, file option set, without stop/restart
+//   */
+//  @Test
+//  public void noCompression_FileSet_NoRestart_5() throws Exception {
+//    String testId = "test5";
+//
+//    initRFA(rfa1, testId2FileName(testId));
+//    initTRBP(rfa1, tbrp1, CoreTestConstants.OUTPUT_DIR_PREFIX + testId + "-%d{"
+//        + DATE_PATTERN + "}", currentTime, 0);
+//
+//    addExpectedFileName_ByDate(testId, getDateOfCurrentPeriodsStart(), false);
+//
+//    incCurrentTime(1100);
+//    tbrp1.setCurrentTime(currentTime);
+//
+//    for (int i = 0; i < 3; i++) {
+//      rfa1.doAppend("Hello---" + i);
+//      addExpectedFileNamedIfItsTime_ByDate(testId, false);
+//      incCurrentTime(500);
+//      tbrp1.setCurrentTime(currentTime);
+//    }
+//
+//    massageExpectedFilesToCorresponToCurrentTarget("test5.log");
+//
+//    int i = 0;
+//    for (String fn : expectedFilenameList) {
+//      assertTrue(Compare.compare(fn, CoreTestConstants.TEST_DIR_PREFIX
+//          + "witness/rolling/tbr-test5." + i++));
+//    }
+//  }
+//
+//  /**
+//   * With compression, file option set, no stop/restart,
+//   */
+//  @Test
+//  public void withCompression_FileSet_NoRestart_6() throws Exception {
+//
+//    String testId = "test6";
+//
+//    initRFA(rfa1, testId2FileName(testId));
+//    initTRBP(rfa1, tbrp1, CoreTestConstants.OUTPUT_DIR_PREFIX + testId + "-%d{"
+//        + DATE_PATTERN + "}.gz", currentTime, 0);
+//
+//    addExpectedFileName_ByDate(testId, getDateOfCurrentPeriodsStart(), true);
+//
+//    incCurrentTime(1100);
+//    tbrp1.setCurrentTime(currentTime);
+//
+//    for (int i = 0; i < 3; i++) {
+//      rfa1.doAppend("Hello---" + i);
+//      addExpectedFileNamedIfItsTime_ByDate(testId, true);
+//      incCurrentTime(500);
+//      tbrp1.setCurrentTime(currentTime);
+//    }
+//
+//    // wait for the compression task to finish
+//    tbrp1.future.get(1000, TimeUnit.MILLISECONDS);
+//
+//    massageExpectedFilesToCorresponToCurrentTarget("test6.log");
+//
+//    int i = 0;
+//    for (String fn : expectedFilenameList) {
+//      assertTrue(Compare.compare(fn, CoreTestConstants.TEST_DIR_PREFIX
+//          + "witness/rolling/tbr-" + testId + "." + i + addGZIfNotLast(i)));
+//      i++;
+//    }
+//  }
 
   // =========================================================================
   // utility methods

Added: logback/trunk/logback-core/src/test/witness/rolling/tbr-test2.0.gz
==============================================================================
Binary file. No diff available.

Added: logback/trunk/logback-core/src/test/witness/rolling/tbr-test2.1.gz
==============================================================================
Binary file. No diff available.

Added: logback/trunk/logback-core/src/test/witness/rolling/tbr-test2.2
==============================================================================
--- (empty file)
+++ logback/trunk/logback-core/src/test/witness/rolling/tbr-test2.2	Fri Jul 24 10:07:40 2009
@@ -0,0 +1 @@
+Hello---2


More information about the logback-dev mailing list