Skip to content

Commit 9b17030

Browse files
committed
Make the test sleep longer waiting for the Tailer to do its work.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/io/trunk@1178227 13f79535-47bb-0310-9956-ffa450edef68
1 parent 0d703c9 commit 9b17030

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

src/test/java/org/apache/commons/io/input/TailerTest.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,18 @@ public void testTailerEof() throws Exception {
8989
public void testTailer() throws Exception {
9090

9191
// Create & start the Tailer
92-
long delay = 50;
92+
long delayMillis = 50;
9393
final File file = new File(getTestDirectory(), "tailer1-test.txt");
9494
createFile(file, 0);
9595
final TestTailerListener listener = new TestTailerListener();
96-
tailer = new Tailer(file, listener, delay, false);
96+
tailer = new Tailer(file, listener, delayMillis, false);
9797
final Thread thread = new Thread(tailer);
9898
thread.start();
9999

100100
// Write some lines to the file
101101
write(file, "Line one", "Line two");
102-
Thread.sleep(delay * 2);
102+
final long testDelayMillis = delayMillis * 10;
103+
Thread.sleep(testDelayMillis);
103104
List<String> lines = listener.getLines();
104105
assertEquals("1 line count", 2, lines.size());
105106
assertEquals("1 line 1", "Line one", lines.get(0));
@@ -108,7 +109,7 @@ public void testTailer() throws Exception {
108109

109110
// Write another line to the file
110111
write(file, "Line three");
111-
Thread.sleep(delay * 2);
112+
Thread.sleep(testDelayMillis);
112113
lines = listener.getLines();
113114
assertEquals("2 line count", 1, lines.size());
114115
assertEquals("2 line 3", "Line three", lines.get(0));
@@ -128,11 +129,11 @@ public void testTailer() throws Exception {
128129
boolean isWindows = osname.startsWith("Windows");
129130
assertFalse("File should not exist (except on Windows)", exists && !isWindows);
130131
createFile(file, 0);
131-
Thread.sleep(delay * 2);
132+
Thread.sleep(testDelayMillis);
132133

133134
// Write another line
134135
write(file, "Line four");
135-
Thread.sleep(delay * 2);
136+
Thread.sleep(testDelayMillis);
136137
lines = listener.getLines();
137138
assertEquals("4 line count", 1, lines.size());
138139
assertEquals("4 line 3", "Line four", lines.get(0));
@@ -142,7 +143,7 @@ public void testTailer() throws Exception {
142143
tailer.stop();
143144
tailer=null;
144145
thread.interrupt();
145-
Thread.sleep(delay * 2);
146+
Thread.sleep(testDelayMillis);
146147
write(file, "Line five");
147148
assertEquals("4 line count", 0, listener.getLines().size());
148149
assertNull("Should not generate Exception", listener.exception);

0 commit comments

Comments
 (0)