|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
/*
|
|
|
|
|
* Copyright 2012-2017 the original author or authors.
|
|
|
|
|
* Copyright 2012-2018 the original author or authors.
|
|
|
|
|
*
|
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
@ -106,21 +106,11 @@ public class FileSystemWatcherTests {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void sourceFolderMustExist() {
|
|
|
|
|
File folder = new File("does/not/exist");
|
|
|
|
|
assertThat(folder.exists()).isFalse();
|
|
|
|
|
this.thrown.expect(IllegalArgumentException.class);
|
|
|
|
|
this.thrown.expectMessage(
|
|
|
|
|
"Folder '" + folder + "' must exist and must be a directory");
|
|
|
|
|
this.watcher.addSourceFolder(folder);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void sourceFolderMustBeADirectory() {
|
|
|
|
|
public void sourceFolderMustNotBeAFile() {
|
|
|
|
|
File folder = new File("pom.xml");
|
|
|
|
|
assertThat(folder.isFile()).isTrue();
|
|
|
|
|
this.thrown.expect(IllegalArgumentException.class);
|
|
|
|
|
this.thrown.expectMessage("Folder 'pom.xml' must exist and must be a directory");
|
|
|
|
|
this.thrown.expectMessage("Folder 'pom.xml' must not be a file");
|
|
|
|
|
this.watcher.addSourceFolder(new File("pom.xml"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -152,6 +142,19 @@ public class FileSystemWatcherTests {
|
|
|
|
|
assertThat(changedFiles.getFiles()).contains(expected);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void createSourceFolderAndAddFile() throws IOException {
|
|
|
|
|
File folder = new File(this.temp.getRoot(), "does/not/exist");
|
|
|
|
|
assertThat(folder.exists()).isFalse();
|
|
|
|
|
this.watcher.addSourceFolder(folder);
|
|
|
|
|
this.watcher.start();
|
|
|
|
|
folder.mkdirs();
|
|
|
|
|
touch(new File(folder, "text.txt"));
|
|
|
|
|
this.watcher.stopAfter(1);
|
|
|
|
|
ChangedFiles changedFiles = getSingleChangedFiles();
|
|
|
|
|
System.out.println(changedFiles);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void waitsForPollingInterval() throws Exception {
|
|
|
|
|
setupWatcher(10, 1);
|
|
|
|
|