[logback-dev] branch, master, updated. 6104cf6a8f59bddcfba11e95965fbc98a8bad93e
added by portage for gitosis-gentoo
git-noreply at pixie.qos.ch
Wed Dec 2 15:27:39 CET 2009
The branch, master has been updated
via 6104cf6a8f59bddcfba11e95965fbc98a8bad93e (commit)
from 1c840c987eca8712860eab12cfc7dbe09441faf5 (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=6104cf6a8f59bddcfba11e95965fbc98a8bad93e
http://github.com/ceki/logback/commit/6104cf6a8f59bddcfba11e95965fbc98a8bad93e
commit 6104cf6a8f59bddcfba11e95965fbc98a8bad93e
Author: Ceki Gulcu <ceki at qos.ch>
Date: Wed Dec 2 15:26:06 2009 +0100
fixed intermittent failures in TimeBasedRollingTest
diff --git a/logback-core/src/test/java/ch/qos/logback/core/rolling/ScaffoldingForRollingTests.java b/logback-core/src/test/java/ch/qos/logback/core/rolling/ScaffoldingForRollingTests.java
index 54a7e1b..561dc55 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/rolling/ScaffoldingForRollingTests.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/rolling/ScaffoldingForRollingTests.java
@@ -23,6 +23,9 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
import ch.qos.logback.core.Context;
import ch.qos.logback.core.ContextBase;
@@ -147,6 +150,13 @@ public class ScaffoldingForRollingTests {
return new Date(currentTime - delta - 1000);
}
+ static void waitForCompression(TimeBasedRollingPolicy<Object> tbrp)
+ throws InterruptedException, ExecutionException, TimeoutException {
+ if (tbrp.future != null && !tbrp.future.isDone()) {
+ tbrp.future.get(200, TimeUnit.MILLISECONDS);
+ }
+ }
+
protected void addExpectedFileName_ByDate(String testId, Date date,
boolean gzExtension) {
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 c50fab9..46b3c2c 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
@@ -16,7 +16,6 @@ package ch.qos.logback.core.rolling;
import static org.junit.Assert.assertTrue;
import java.io.File;
-import java.util.concurrent.TimeUnit;
import org.junit.After;
import org.junit.Before;
@@ -54,14 +53,12 @@ public class TimeBasedRollingTest extends ScaffoldingForRollingTests {
RollingFileAppender<Object> rfa2 = new RollingFileAppender<Object>();
TimeBasedRollingPolicy<Object> tbrp2 = new TimeBasedRollingPolicy<Object>();
-
@Before
@Override
public void setUp() {
super.setUp();
}
-
@After
public void tearDown() {
}
@@ -74,8 +71,9 @@ public class TimeBasedRollingTest extends ScaffoldingForRollingTests {
}
}
- void initTRBP(RollingFileAppender<Object> rfa, TimeBasedRollingPolicy<Object> tbrp,
- String filenamePattern, long givenTime) {
+ void initTRBP(RollingFileAppender<Object> rfa,
+ TimeBasedRollingPolicy<Object> tbrp, String filenamePattern,
+ long givenTime) {
tbrp.setContext(context);
tbrp.setFileNamePattern(filenamePattern);
tbrp.setParent(rfa);
@@ -136,10 +134,9 @@ public class TimeBasedRollingTest extends ScaffoldingForRollingTests {
rfa1.doAppend("Hello---" + i);
incCurrentTime(500);
tbrp1.timeBasedTriggering.setCurrentTime(currentTime);
+ waitForCompression(tbrp1);
}
- tbrp1.future.get(2000, TimeUnit.MILLISECONDS);
-
int i = 0;
for (String fn : expectedFilenameList) {
assertTrue(Compare.compare(fn, CoreTestConstants.TEST_DIR_PREFIX
@@ -176,7 +173,8 @@ public class TimeBasedRollingTest extends ScaffoldingForRollingTests {
initRFA(rfa2, null);
initTRBP(rfa2, tbrp2, randomOutputDir + testId + "-%d{"
- + DATE_PATTERN_WITH_SECONDS + "}", tbrp1.timeBasedTriggering.getCurrentTime());
+ + DATE_PATTERN_WITH_SECONDS + "}", tbrp1.timeBasedTriggering
+ .getCurrentTime());
for (int i = 0; i <= 2; i++) {
addExpectedFileNamedIfItsTime_ByDate(testId, false);
@@ -219,8 +217,7 @@ public class TimeBasedRollingTest extends ScaffoldingForRollingTests {
// change the timestamp of the currently actively file
File activeFile = new File(rfa1.getFile());
activeFile.setLastModified(currentTime);
-
-
+
initRFA(rfa2, testId2FileName(testId));
initTRBP(rfa2, tbrp2, randomOutputDir + testId + "-%d{"
+ DATE_PATTERN_WITH_SECONDS + "}", currentTime);
@@ -266,7 +263,7 @@ public class TimeBasedRollingTest extends ScaffoldingForRollingTests {
// change the timestamp of the currently actively file
File activeFile = new File(rfa1.getFile());
activeFile.setLastModified(currentTime);
-
+
incCurrentTime(2000);
initRFA(rfa2, randomOutputDir + "test4B.log");
@@ -344,11 +341,9 @@ public class TimeBasedRollingTest extends ScaffoldingForRollingTests {
addExpectedFileNamedIfItsTime_ByDate(testId, true);
incCurrentTime(500);
tbrp1.timeBasedTriggering.setCurrentTime(currentTime);
+ waitForCompression(tbrp1);
}
- // wait for the compression task to finish
- tbrp1.future.get(1000, TimeUnit.MILLISECONDS);
-
massageExpectedFilesToCorresponToCurrentTarget("test6.log");
int i = 0;
@@ -363,7 +358,6 @@ public class TimeBasedRollingTest extends ScaffoldingForRollingTests {
// utility methods
// =========================================================================
-
void massageExpectedFilesToCorresponToCurrentTarget(String file) {
// we added one too many files by date
expectedFilenameList.remove(expectedFilenameList.size() - 1);
diff --git a/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingWithArchiveRemovalTest.java b/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingWithArchiveRemovalTest.java
index 679afed..ce708d5 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingWithArchiveRemovalTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingWithArchiveRemovalTest.java
@@ -65,7 +65,7 @@ public class TimeBasedRollingWithArchiveRemovalTest {
TimeBasedFileNamingAndTriggeringPolicy<Object> tbfnatp = new DefaultTimeBasedFileNamingAndTriggeringPolicy<Object>();
@Before
- public void setUp() throws Exception {
+ public void setUp() {
context.setName("test");
}
@@ -192,8 +192,7 @@ public class TimeBasedRollingWithArchiveRemovalTest {
int ticksPerPeriod = 512;
long runLength = simulatedNumberOfPeriods * ticksPerPeriod;
- long i = 0;
- for (; i < runLength; i++) {
+ for (long i = 0; i < runLength; i++) {
rfa
.doAppend("Hello ----------------------------------------------------------"
+ i);
-----------------------------------------------------------------------
Summary of changes:
.../core/rolling/ScaffoldingForRollingTests.java | 10 ++++++++
.../logback/core/rolling/TimeBasedRollingTest.java | 24 +++++++------------
.../TimeBasedRollingWithArchiveRemovalTest.java | 5 +--
3 files changed, 21 insertions(+), 18 deletions(-)
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
More information about the logback-dev
mailing list