commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r752699 - /commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/impl/test/DefaultFileMonitorTests.java
Date Wed, 11 Mar 2009 23:52:04 GMT
Author: rgoers
Date: Wed Mar 11 23:52:04 2009
New Revision: 752699

URL: http://svn.apache.org/viewvc?rev=752699&view=rev
Log:
Add a recreate test

Modified:
    commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/impl/test/DefaultFileMonitorTests.java

Modified: commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/impl/test/DefaultFileMonitorTests.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/impl/test/DefaultFileMonitorTests.java?rev=752699&r1=752698&r2=752699&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/impl/test/DefaultFileMonitorTests.java
(original)
+++ commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/impl/test/DefaultFileMonitorTests.java
Wed Mar 11 23:52:04 2009
@@ -52,7 +52,7 @@
         monitor.addFile(fileObj);
         monitor.start();
         writeToFile(testFile);
-        Thread.sleep(500);
+        Thread.sleep(300);
         assertTrue("No event occurred", changeStatus != 0);
         assertTrue("Incorrect event", changeStatus == 3);
         monitor.stop();
@@ -67,7 +67,7 @@
         monitor.addFile(fileObj);
         monitor.start();
         testFile.delete();
-        Thread.sleep(500);
+        Thread.sleep(300);
         assertTrue("No event occurred", changeStatus != 0);
         assertTrue("Incorrect event", changeStatus == 2);
         monitor.stop();
@@ -92,6 +92,33 @@
         monitor.stop();
     }
 
+
+    public void testFileRecreated() throws Exception
+    {
+        FileObject fileObj = fsManager.resolveFile(testFile.toURL().toString());
+        DefaultFileMonitor monitor = new DefaultFileMonitor(new TestFileListener());
+        monitor.setDelay(100);
+        monitor.addFile(fileObj);
+        monitor.start();
+        writeToFile(testFile);
+        Thread.sleep(300);
+        assertTrue("No event occurred", changeStatus != 0);
+        assertTrue("Incorrect event " + changeStatus, changeStatus == 3);
+        changeStatus = 0;
+        testFile.delete();
+        Thread.sleep(300);
+        assertTrue("No event occurred", changeStatus != 0);
+        assertTrue("Incorrect event " + changeStatus, changeStatus == 2);
+        changeStatus = 0;
+        Thread.sleep(500);
+        monitor.addFile(fileObj);
+        writeToFile(testFile);
+        Thread.sleep(300);
+        assertTrue("No event occurred", changeStatus != 0);
+        assertTrue("Incorrect event " + changeStatus, changeStatus == 3);
+        monitor.stop();
+    }
+
     private void writeToFile(File file) throws Exception
     {
         FileWriter out = new FileWriter(file);



Mime
View raw message