You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2010/09/30 18:56:55 UTC

svn commit: r1003158 - /commons/proper/io/trunk/src/test/org/apache/commons/io/input/TailerTest.java

Author: sebb
Date: Thu Sep 30 16:56:55 2010
New Revision: 1003158

URL: http://svn.apache.org/viewvc?rev=1003158&view=rev
Log:
Test static method and Executor method

Modified:
    commons/proper/io/trunk/src/test/org/apache/commons/io/input/TailerTest.java

Modified: commons/proper/io/trunk/src/test/org/apache/commons/io/input/TailerTest.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/org/apache/commons/io/input/TailerTest.java?rev=1003158&r1=1003157&r2=1003158&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/org/apache/commons/io/input/TailerTest.java (original)
+++ commons/proper/io/trunk/src/test/org/apache/commons/io/input/TailerTest.java Thu Sep 30 16:56:55 2010
@@ -20,6 +20,8 @@ import java.io.File;
 import java.io.FileWriter;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.concurrent.Executor;
+import java.util.concurrent.ScheduledThreadPoolExecutor;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
@@ -120,7 +122,25 @@ public class TailerTest extends FileBase
         TestTailerListener listener = new TestTailerListener();
         int delay = 100;
         int idle = 50; // allow time for thread to work
-        Tailer tailer = start(file, listener, delay, false);
+        Tailer tailer = Tailer.create(file, listener, delay, false);
+        Thread.sleep(idle);
+        tailer.stop();
+        Thread.sleep(delay+idle);
+        assertNull("Should not generate Exception", listener.exception);
+        assertEquals("Expected init to be called", 1 , listener.initialised);
+        assertEquals("fileNotFound should be called", 1 , listener.notFound);
+        assertEquals("fileRotated should be not be called", 0 , listener.rotated);
+    }
+
+    public void testStopWithNoFileUsingExecutor() throws Exception {
+        File file = new File(getTestDirectory(),"nosuchfile");
+        assertFalse("nosuchfile should not exist", file.exists());
+        TestTailerListener listener = new TestTailerListener();
+        int delay = 100;
+        int idle = 50; // allow time for thread to work
+        Tailer tailer = new Tailer(file, listener, delay, false);
+        Executor exec = new ScheduledThreadPoolExecutor(1);
+        exec.execute(tailer);
         Thread.sleep(idle);
         tailer.stop();
         Thread.sleep(delay+idle);