-
Notifications
You must be signed in to change notification settings - Fork 57
/
OutputDirectoryWatcherTest.groovy
61 lines (37 loc) · 1.54 KB
/
OutputDirectoryWatcherTest.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package bpipe
import java.nio.file.Path
import org.junit.BeforeClass
import org.junit.Test;
class OutputDirectoryWatcherTest {
@BeforeClass
static void before() {
Config.userConfig = new ConfigObject()
}
@Test
void testOutputDirectoryWatcher() {
File testDir = new File("tests/odw.tmp")
Path dir = testDir.toPath()
dir.toFile().mkdirs()
OutputDirectoryWatcher odw = new OutputDirectoryWatcher(testDir.path, dir)
odw.start()
long startMs = System.currentTimeMillis()
Thread.sleep(1100)
new File(testDir, "foo.txt").text = (new Date()).toString()
println "Created file foo.txt"
Thread.sleep(10000)
println "Files are: " + odw.files
println "File timestamp for foo.txt = " + odw.files["foo.txt"]
long updateMs = odw.files["foo.txt"]
println odw.timestamps.higherEntry(startMs)
new File(testDir, "foo.txt").text = (new Date()).toString()
Thread.sleep(100)
new File(testDir, "bar.txt").text = (new Date()).toString()
Thread.sleep(10000)
assert odw.timestamps[updateMs] == null
println "Ending timestamps: " + odw.timestamps
println odw.timestamps.higherEntry(updateMs)
assert "foo.txt" in odw.modifiedSince(updateMs)
assert "bar.txt" in odw.modifiedSince(updateMs)
odw.stop = true
}
}