[LOGBack-dev] svn commit: r63 - 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:17 CEST 2006
Author: seb
Date: Thu Jul 13 16:35:16 2006
New Revision: 63
Modified:
logback/core/trunk/src/test/java/ch/qos/logback/core/rolling/SizeBasedRollingTest.java
Log:
using new paths to access files + deleting old .log in setUp()
Modified: logback/core/trunk/src/test/java/ch/qos/logback/core/rolling/SizeBasedRollingTest.java
==============================================================================
--- logback/core/trunk/src/test/java/ch/qos/logback/core/rolling/SizeBasedRollingTest.java (original)
+++ logback/core/trunk/src/test/java/ch/qos/logback/core/rolling/SizeBasedRollingTest.java Thu Jul 13 16:35:16 2006
@@ -21,12 +21,8 @@
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
-
import ch.qos.logback.core.Layout;
import ch.qos.logback.core.layout.DummyLayout;
-import ch.qos.logback.core.rolling.FixedWindowRollingPolicy;
-import ch.qos.logback.core.rolling.RollingFileAppender;
-import ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy;
import ch.qos.logback.core.util.Compare;
@@ -42,8 +38,18 @@
public SizeBasedRollingTest(String name) {
super(name);
}
-
+
public void setUp() {
+ {
+ File target = new File("src/test/output/sizeBased-test2.log");
+ target.mkdirs();
+ target.delete();
+ }
+ {
+ File target = new File("src/test/output/sbr-test3.log");
+ target.mkdirs();
+ target.delete();
+ }
}
public void tearDown() {
@@ -64,7 +70,7 @@
SizeBasedTriggeringPolicy sbtp = new SizeBasedTriggeringPolicy();
sbtp.setMaxFileSize(100);
sbtp.start();
- fwrp.setFileNamePattern("output/sizeBased-test1.%i");
+ fwrp.setFileNamePattern("src/test/output/sizeBased-test1.%i");
try {
fwrp.start();
fail("The absence of activeFileName option should have caused an exception.");
@@ -77,6 +83,7 @@
* Test basic rolling functionality.
*/
public void test2() throws Exception {
+
DummyLayout layout = new DummyLayout();
RollingFileAppender rfa = new RollingFileAppender();
rfa.setName("ROLLING");
@@ -87,39 +94,41 @@
sbtp.setMaxFileSize(100);
swrp.setMinIndex(0);
- swrp.setActiveFileName("output/sizeBased-test2.log");
+ swrp.setActiveFileName("src/test/output/sizeBased-test2.log");
- swrp.setFileNamePattern("output/sizeBased-test2.%i");
+ swrp.setFileNamePattern("src/test/output/sizeBased-test2.%i");
swrp.start();
rfa.setRollingPolicy(swrp);
rfa.setTriggeringPolicy(sbtp);
rfa.start();
-
+
// Write exactly 10 bytes with each log
for (int i = 0; i < 25; i++) {
Thread.sleep(100);
if (i < 10) {
+ rfa.doAppend("Hello---" + i);
//logger.debug("Hello---" + i);
} else if (i < 100) {
+ rfa.doAppend("Hello---" + i);
//logger.debug("Hello--" + i);
}
}
- assertTrue(new File("output/sizeBased-test2.log").exists());
- assertTrue(new File("output/sizeBased-test2.0").exists());
- assertTrue(new File("output/sizeBased-test2.1").exists());
+ assertTrue(new File("src/test/output/sizeBased-test2.log").exists());
+ assertTrue(new File("src/test/output/sizeBased-test2.0").exists());
+ assertTrue(new File("src/test/output/sizeBased-test2.1").exists());
// The File.length() method is not accurate under Windows
if (!isWindows()) {
- assertTrue(Compare.compare("output/sizeBased-test2.log",
- "witness/rolling/sbr-test2.log"));
- assertTrue(Compare.compare("output/sizeBased-test2.0",
- "witness/rolling/sbr-test2.0"));
- assertTrue(Compare.compare("output/sizeBased-test2.1",
- "witness/rolling/sbr-test2.1"));
+ assertTrue(Compare.compare("src/test/output/sizeBased-test2.log",
+ "src/test/witness/rolling/sbr-test2.log"));
+ assertTrue(Compare.compare("src/test/output/sizeBased-test2.0",
+ "src/test/witness/rolling/sbr-test2.0"));
+ assertTrue(Compare.compare("src/test/output/sizeBased-test2.1",
+ "src/test/witness/rolling/sbr-test2.1"));
}
}
@@ -136,8 +145,8 @@
sbtp.setMaxFileSize(100);
fwrp.setMinIndex(0);
- fwrp.setActiveFileName("output/sbr-test3.log");
- fwrp.setFileNamePattern("output/sbr-test3.%i.gz");
+ fwrp.setActiveFileName("src/test/output/sbr-test3.log");
+ fwrp.setFileNamePattern("src/test/output/sbr-test3.%i.gz");
fwrp.start();
rfa.setRollingPolicy(fwrp);
rfa.setTriggeringPolicy(sbtp);
@@ -147,24 +156,26 @@
for (int i = 0; i < 25; i++) {
Thread.sleep(100);
if (i < 10) {
+ rfa.doAppend("Hello---" + i);
//logger.debug("Hello---" + i);
} else if (i < 100) {
+ rfa.doAppend("Hello---" + i);
//logger.debug("Hello--" + i);
}
}
- assertTrue(new File("output/sbr-test3.log").exists());
- assertTrue(new File("output/sbr-test3.0.gz").exists());
- assertTrue(new File("output/sbr-test3.1.gz").exists());
+ assertTrue(new File("src/test/output/sbr-test3.log").exists());
+ assertTrue(new File("src/test/output/sbr-test3.0.gz").exists());
+ assertTrue(new File("src/test/output/sbr-test3.1.gz").exists());
if (!isWindows()) {
- assertTrue(Compare.compare("output/sbr-test3.log",
- "witness/rolling/sbr-test3.log"));
- assertTrue(Compare.gzCompare("output/sbr-test3.0.gz",
- "witness/rolling/sbr-test3.0.gz"));
- assertTrue(Compare.gzCompare("output/sbr-test3.1.gz",
- "witness/rolling/sbr-test3.1.gz"));
+ assertTrue(Compare.compare("src/test/output/sbr-test3.log",
+ "src/test/witness/rolling/sbr-test3.log"));
+ assertTrue(Compare.gzCompare("src/test/output/sbr-test3.0.gz",
+ "src/test/witness/rolling/sbr-test3.0.gz"));
+ assertTrue(Compare.gzCompare("src/test/output/sbr-test3.1.gz",
+ "src/test/witness/rolling/sbr-test3.1.gz"));
}
}
More information about the logback-dev
mailing list