[LOGBack-dev] svn commit: r64 - logback/core/trunk/src/test/java/ch/qos/logback/core/rolling

noreply.seb at qos.ch noreply.seb at qos.ch
Thu Jul 13 16:35:56 CEST 2006


Author: seb
Date: Thu Jul 13 16:35:55 2006
New Revision: 64

Modified:
   logback/core/trunk/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingTest.java
Log:
using new paths to access files + deleting old .log files in setUp()

Modified: logback/core/trunk/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingTest.java
==============================================================================
--- logback/core/trunk/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingTest.java	(original)
+++ logback/core/trunk/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingTest.java	Thu Jul 13 16:35:55 2006
@@ -10,6 +10,7 @@
 
 package ch.qos.logback.core.rolling;
 
+import java.io.File;
 import java.text.SimpleDateFormat;
 import java.util.Calendar;
 import java.util.Date;
@@ -17,10 +18,7 @@
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
-
 import ch.qos.logback.core.layout.EchoLayout;
-import ch.qos.logback.core.rolling.RollingFileAppender;
-import ch.qos.logback.core.rolling.TimeBasedRollingPolicy;
 import ch.qos.logback.core.util.Compare;
 
 
@@ -56,6 +54,22 @@
   }
 
   public void setUp() {
+	  //Delete .log files
+	  {
+		  File target = new File("src/test/output/test4.log");
+		  target.mkdirs();
+		  target.delete();
+	  }
+	  {
+		  File target = new File("src/test/output/test5.log");
+		  target.mkdirs();
+		  target.delete();
+	  }
+	  {
+		  File target = new File("src/test/output/test6.log");
+		  target.mkdirs();
+		  target.delete();
+	  }
   }
 
   public void tearDown() {
@@ -69,10 +83,8 @@
     RollingFileAppender rfa = new RollingFileAppender();
     rfa.setLayout(layout);
 
-   
-
     TimeBasedRollingPolicy tbrp = new TimeBasedRollingPolicy();
-    tbrp.setFileNamePattern("output/test1-%d{" + DATE_PATTERN + "}");
+    tbrp.setFileNamePattern("src/test/output/test1-%d{" + DATE_PATTERN + "}");
     tbrp.start();
     rfa.setRollingPolicy(tbrp);
     rfa.start();
@@ -84,7 +96,7 @@
     Calendar cal = Calendar.getInstance();
 
     for (int i = 0; i < 4; i++) {
-      filenames[i] = "output/test1-" + sdf.format(cal.getTime());
+      filenames[i] = "src/test/output/test1-" + sdf.format(cal.getTime());
       cal.add(Calendar.SECOND, 1);
     }
 
@@ -102,7 +114,7 @@
     }
 
     for (int i = 0; i < 4; i++) {
-      assertTrue(Compare.compare(filenames[i], "witness/rolling/tbr-test1." + i));
+      assertTrue(Compare.compare(filenames[i], "src/test/witness/rolling/tbr-test1." + i));
     }
   }
 
@@ -114,7 +126,7 @@
     rfa1.setLayout(layout);
 
     TimeBasedRollingPolicy tbrp1 = new TimeBasedRollingPolicy();
-    tbrp1.setFileNamePattern("output/test2-%d{" + DATE_PATTERN + "}");
+    tbrp1.setFileNamePattern("src/test/output/test2-%d{" + DATE_PATTERN + "}");
     tbrp1.start();
     rfa1.setRollingPolicy(tbrp1);
     rfa1.start();
@@ -126,7 +138,7 @@
     Calendar cal = Calendar.getInstance();
 
     for (int i = 0; i < 4; i++) {
-      filenames[i] = "output/test2-" + sdf.format(cal.getTime());
+      filenames[i] = "src/test/output/test2-" + sdf.format(cal.getTime());
       cal.add(Calendar.SECOND, 1);
     }
 
@@ -146,7 +158,7 @@
     rfa2.setLayout(layout);
 
     TimeBasedRollingPolicy tbrp2 = new TimeBasedRollingPolicy();
-    tbrp2.setFileNamePattern("output/test2-%d{" + DATE_PATTERN + "}");
+    tbrp2.setFileNamePattern("src/test/output/test2-%d{" + DATE_PATTERN + "}");
     tbrp2.start();
     rfa2.setRollingPolicy(tbrp2);
     rfa2.start();
@@ -158,7 +170,7 @@
     }
 
     for (int i = 0; i < 4; i++) {
-      assertTrue(Compare.compare(filenames[i], "witness/rolling/tbr-test2." + i));
+      assertTrue(Compare.compare(filenames[i], "src/test/witness/rolling/tbr-test2." + i));
     }
   }
 
@@ -171,7 +183,7 @@
 
 
     TimeBasedRollingPolicy tbrp = new TimeBasedRollingPolicy();
-    tbrp.setFileNamePattern("output/test3-%d{" + DATE_PATTERN + "}.gz");
+    tbrp.setFileNamePattern("src/test/output/test3-%d{" + DATE_PATTERN + "}.gz");
     tbrp.start();
     rfa.setRollingPolicy(tbrp);
     rfa.start();
@@ -183,11 +195,11 @@
     Calendar cal = Calendar.getInstance();
 
     for (int i = 0; i < 3; i++) {
-      filenames[i] = "output/test3-" + sdf.format(cal.getTime()) + ".gz";
+      filenames[i] = "src/test/output/test3-" + sdf.format(cal.getTime()) + ".gz";
       cal.add(Calendar.SECOND, 1);
     }
 
-    filenames[3] = "output/test3-" + sdf.format(cal.getTime());
+    filenames[3] = "src/test/output/test3-" + sdf.format(cal.getTime());
 
     System.out.println("Waiting until next second and 100 millis.");
     delayUntilNextSecond(100);
@@ -203,10 +215,10 @@
     }
 
     for (int i = 0; i < 3; i++) {
-      assertTrue(Compare.gzCompare(filenames[i], "witness/rolling/tbr-test3." + i + ".gz"));
+      assertTrue(Compare.gzCompare(filenames[i], "src/test/witness/rolling/tbr-test3." + i + ".gz"));
     }
 
-    assertTrue(Compare.compare(filenames[3], "witness/rolling/tbr-test3.3"));
+    assertTrue(Compare.compare(filenames[3], "src/test/witness/rolling/tbr-test3.3"));
   }
 
   /**
@@ -215,10 +227,10 @@
   public void test4() throws Exception {
     RollingFileAppender rfa1 = new RollingFileAppender();
     rfa1.setLayout(layout);
-
+    
     TimeBasedRollingPolicy tbrp1 = new TimeBasedRollingPolicy();
-    tbrp1.setActiveFileName("output/test4.log");
-    tbrp1.setFileNamePattern("output/test4-%d{" + DATE_PATTERN + "}");
+    tbrp1.setActiveFileName("src/test/output/test4.log");
+    tbrp1.setFileNamePattern("src/test/output/test4-%d{" + DATE_PATTERN + "}");
     tbrp1.start();
     rfa1.setRollingPolicy(tbrp1);
     rfa1.start();
@@ -230,10 +242,10 @@
     Calendar cal = Calendar.getInstance();
 
     for (int i = 0; i < 3; i++) {
-      filenames[i] = "output/test4-" + sdf.format(cal.getTime());
+      filenames[i] = "src/test/output/test4-" + sdf.format(cal.getTime());
       cal.add(Calendar.SECOND, 1);
     }
-    filenames[3] = "output/test4.log";
+    filenames[3] = "src/test/output/test4.log";
     
     System.out.println("Waiting until next second and 100 millis.");
     delayUntilNextSecond(100);
@@ -250,8 +262,8 @@
     rfa2.setLayout(layout);
 
     TimeBasedRollingPolicy tbrp2 = new TimeBasedRollingPolicy();
-    tbrp2.setFileNamePattern("output/test4-%d{" + DATE_PATTERN + "}");
-    tbrp2.setActiveFileName("output/test4.log");
+    tbrp2.setFileNamePattern("src/test/output/test4-%d{" + DATE_PATTERN + "}");
+    tbrp2.setActiveFileName("src/test/output/test4.log");
     tbrp2.start();
     rfa2.setRollingPolicy(tbrp2);
     rfa2.start();
@@ -262,7 +274,7 @@
     }
 
     for (int i = 0; i < 4; i++) {
-      assertTrue(Compare.compare(filenames[i], "witness/rolling/tbr-test4." + i));
+      assertTrue(Compare.compare(filenames[i], "src/test/witness/rolling/tbr-test4." + i));
     }
   }
 
@@ -274,8 +286,8 @@
     rfa.setLayout(layout);
 
     TimeBasedRollingPolicy tbrp = new TimeBasedRollingPolicy();
-    tbrp.setFileNamePattern("output/test5-%d{" + DATE_PATTERN + "}");
-    tbrp.setActiveFileName("output/test5.log");
+    tbrp.setFileNamePattern("src/test/output/test5-%d{" + DATE_PATTERN + "}");
+    tbrp.setActiveFileName("src/test/output/test5.log");
     tbrp.start();
     rfa.setRollingPolicy(tbrp);
     rfa.start();
@@ -286,11 +298,11 @@
     Calendar cal = Calendar.getInstance();
 
     for (int i = 0; i < 3; i++) {
-      filenames[i] = "output/test5-" + sdf.format(cal.getTime());
+      filenames[i] = "src/test/output/test5-" + sdf.format(cal.getTime());
       cal.add(Calendar.SECOND, 1);
     }
 
-    filenames[3] = "output/test5.log";
+    filenames[3] = "src/test/output/test5.log";
 
     System.out.println("Waiting until next second and 100 millis.");
     delayUntilNextSecond(100);
@@ -302,7 +314,7 @@
     }
 
     for (int i = 0; i < 4; i++) {
-      assertTrue(Compare.compare(filenames[i], "witness/rolling/tbr-test5." + i));
+      assertTrue(Compare.compare(filenames[i], "src/test/witness/rolling/tbr-test5." + i));
     }
   }
 
@@ -314,8 +326,8 @@
     rfa.setLayout(layout);
 
     TimeBasedRollingPolicy tbrp = new TimeBasedRollingPolicy();
-    tbrp.setFileNamePattern("output/test6-%d{" + DATE_PATTERN + "}.gz");
-    tbrp.setActiveFileName("output/test6.log");
+    tbrp.setFileNamePattern("src/test/output/test6-%d{" + DATE_PATTERN + "}.gz");
+    tbrp.setActiveFileName("src/test/output/test6.log");
     tbrp.start();
     rfa.setRollingPolicy(tbrp);
     rfa.start();
@@ -326,11 +338,11 @@
     Calendar cal = Calendar.getInstance();
 
     for (int i = 0; i < 3; i++) {
-      filenames[i] = "output/test6-" + sdf.format(cal.getTime()) + ".gz";
+      filenames[i] = "src/test/output/test6-" + sdf.format(cal.getTime()) + ".gz";
       cal.add(Calendar.SECOND, 1);
     }
 
-    filenames[3] = "output/test6.log";
+    filenames[3] = "src/test/output/test6.log";
 
     System.out.println("Waiting until next second and 100 millis.");
     delayUntilNextSecond(100);
@@ -346,10 +358,10 @@
     }
 
     for (int i = 0; i < 3; i++) {
-      assertTrue(Compare.gzCompare(filenames[i], "witness/rolling/tbr-test6." + i + ".gz"));
+      assertTrue(Compare.gzCompare(filenames[i], "src/test/witness/rolling/tbr-test6." + i + ".gz"));
     }
 
-    assertTrue(Compare.compare(filenames[3], "witness/rolling/tbr-test6.3"));
+    assertTrue(Compare.compare(filenames[3], "src/test/witness/rolling/tbr-test6.3"));
   }
 
 //  public void testWithJoran1() throws Exception {



More information about the logback-dev mailing list