added a testcase specifically for the modification time.
[utils] / support / general / src / test / java / org / wamblee / io / DirectoryMonitorTest.java
index b148fafebae6c98931d35a3adeca68aec1809db3..1bb4d02017d902bec371a05e13fce0ca87dcf5bc 100644 (file)
@@ -75,6 +75,19 @@ public class DirectoryMonitorTest extends TestCase {
         verifyNoMoreInteractions(listener);
     }
 
+    public void testFileModificationTimeChanged() throws InterruptedException {
+        data.createFile(FILE1, "hello");
+        monitor.poll();
+        reset(listener);
+        data.deleteFile(FILE1);
+        Thread.sleep(2000);
+        data.createFile(FILE1, "hello");
+
+        monitor.poll();
+        verify(listener).fileChanged(data.getFile(FILE1));
+        verifyNoMoreInteractions(listener);
+    }
+
     public void testFileFilterIsUsed() {
         monitor.poll();
 
@@ -94,8 +107,8 @@ public class DirectoryMonitorTest extends TestCase {
         monitor.poll();
         data.createFile(FILE1, "hello");
 
-        stubVoid(listener).toThrow(new RuntimeException()).on().fileCreated(
-            data.getFile(FILE1));
+        stubVoid(listener).toThrow(new RuntimeException()).on()
+            .fileCreated(data.getFile(FILE1));
 
         try {
             monitor.poll();