[logback-dev] svn commit: r1051 - in logback/trunk: logback-classic/src/test/java/ch/qos/logback/classic/util logback-core/src/test/java/ch/qos/logback/core/rolling logback-core/src/test/java/ch/qos/logback/core/util

noreply.seb at qos.ch noreply.seb at qos.ch
Fri Dec 1 17:13:48 CET 2006


Author: seb
Date: Fri Dec  1 17:13:48 2006
New Revision: 1051

Modified:
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/util/Constants.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
   logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/Constants.java
   logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/TimeUtilTest.java

Log:
Modified test dir prefix to allow eclipse and idea to reach the files with different base directories

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/util/Constants.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/util/Constants.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/util/Constants.java	Fri Dec  1 17:13:48 2006
@@ -1,7 +1,19 @@
 package ch.qos.logback.classic.util;
 
+import java.io.File;
+
 public class Constants {
 	
-	public static final String TEST_DIR_PREFIX = "src/test/";
+  static {
+    File f = new File("");
+    String path = "";
+    String absolute = f.getAbsolutePath();
+    if (!absolute.endsWith("logback-classic")) {
+      path = "logback-classic/";
+    }
+    TEST_DIR_PREFIX = path + "src/test/";
+  }
+
+  public static final String TEST_DIR_PREFIX;
 
 }

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 Dec  1 17:13:48 2006
@@ -10,16 +10,17 @@
 
 package ch.qos.logback.core.rolling;
 
-import java.io.File;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-
-import junit.framework.TestCase;
 import ch.qos.logback.core.Context;
 import ch.qos.logback.core.ContextBase;
 import ch.qos.logback.core.Layout;
 import ch.qos.logback.core.layout.EchoLayout;
 import ch.qos.logback.core.util.Compare;
+import ch.qos.logback.core.util.Constants;
+import junit.framework.TestCase;
+
+import java.io.File;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
 
 /**
  * 
@@ -56,7 +57,7 @@
     RollingFileAppender rfa = new RollingFileAppender();
     rfa.setLayout(layout);
     rfa.setContext(context);
-    rfa.setFile("src/test/output/test.log");
+    rfa.setFile(Constants.TEST_DIR_PREFIX + "output/test.log");
     
     // rollover by the second
     String datePattern = "yyyy-MM-dd_HH_mm_ss";
@@ -64,7 +65,7 @@
     String[] filenames = new String[2];
 
     TimeBasedRollingPolicy tbrp = new TimeBasedRollingPolicy();
-    tbrp.setFileNamePattern("src/test/output/test-%d{" + datePattern + "}");
+    tbrp.setFileNamePattern(Constants.TEST_DIR_PREFIX + "/output/test-%d{" + datePattern + "}");
     //tbrp.setActiveFileName("src/test/output/test.log");
     tbrp.setContext(context);
     tbrp.setParent(rfa);
@@ -80,13 +81,13 @@
     DelayerUtil.delayUntilNextSecond(50);
     rfa.doAppend("Hello 1");
 
-    filenames[0] = "src/test/output/test-" + sdf.format(cal.getTime());
-    filenames[1] = "src/test/output/test.log";
+    filenames[0] = Constants.TEST_DIR_PREFIX + "output/test-" + sdf.format(cal.getTime());
+    filenames[1] = Constants.TEST_DIR_PREFIX + "/output/test.log";
 
     for (int i = 0; i < filenames.length; i++) {
       //System.out.println("before i=" + i);
       assertTrue(Compare.compare(filenames[i],
-          "src/test/witness/rolling/renaming." + i));
+          Constants.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 Dec  1 17:13:48 2006
@@ -10,18 +10,18 @@
 
 package ch.qos.logback.core.rolling;
 
-import java.io.File;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
 import ch.qos.logback.core.Context;
 import ch.qos.logback.core.ContextBase;
 import ch.qos.logback.core.layout.EchoLayout;
 import ch.qos.logback.core.util.Compare;
 import ch.qos.logback.core.util.Constants;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import java.io.File;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
 
 /**
  * A rather exhaustive set of tests. Tests include leaving the file option
@@ -217,7 +217,7 @@
       cal.add(Calendar.SECOND, 1);
     }
 
-    filenames[3] = "src/test/output/test3-" + sdf.format(cal.getTime());
+    filenames[3] = Constants.TEST_DIR_PREFIX + "output/test3-" + sdf.format(cal.getTime());
 
     //System.out.println("Waiting until next second and 100 millis.");
     DelayerUtil.delayUntilNextSecond(100);

Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/Constants.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/Constants.java	(original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/Constants.java	Fri Dec  1 17:13:48 2006
@@ -1,7 +1,19 @@
 package ch.qos.logback.core.util;
 
+import java.io.File;
+
 public class Constants {
-	
-	public static final String TEST_DIR_PREFIX = "src/test/";
+  
+  static {
+    File f = new File("");
+    String path = "";
+    String absolute = f.getAbsolutePath();
+    if (!absolute.endsWith("logback-core")) {
+      path = "logback-core/";
+    }
+    TEST_DIR_PREFIX = path + "src/test/";
+  }
+
+  public static final String TEST_DIR_PREFIX;
 
 }

Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/TimeUtilTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/TimeUtilTest.java	(original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/TimeUtilTest.java	Fri Dec  1 17:13:48 2006
@@ -1,10 +1,10 @@
 package ch.qos.logback.core.util;
 
+import junit.framework.TestCase;
+
 import java.util.Calendar;
 import java.util.Date;
 
-import junit.framework.TestCase;
-
 public class TimeUtilTest extends TestCase {
 
   public TimeUtilTest(String arg0) {
@@ -44,7 +44,7 @@
     long now = 1164042317522L;
     // Mon Nov 20 19:00:00 CET 2006
     long expected = 1164045600000L;
-    System.out.println(new Date(expected));
+    //System.out.println(new Date(expected));
     long computed = TimeUtil.computeStartOfNextHour(now);
     assertEquals(expected - now, 1000*(42+60*54)+478); 
     assertEquals(expected, computed);



More information about the logback-dev mailing list