@@ -29,39 +29,43 @@ final class DirectoryWatcherSpec extends AsyncWordSpec with Matchers with Before
2929 var processedDir : Path = _
3030
3131 " DirectoryWatcher" should {
32- " detect_files_on_startup " in {
32+ " detect_files_on_startup_in_parent_dir " in {
3333 watcher = DirectoryWatcher (uploadDir, processedDir)
3434 waitForCondition(3 .seconds)(watcher.countFilesProcessed() == 2 ) shouldBe true
3535 }
3636
37- " detect_added_files_at_runtime_in_parent" in {
38- copyTestFileToDir(uploadDir)
37+ " detect_added_file_at_runtime_in_parent_dir" in {
3938 watcher = DirectoryWatcher (uploadDir, processedDir)
39+ copyTestFileToDir(uploadDir)
4040 waitForCondition(3 .seconds)(watcher.countFilesProcessed() == 2 + 1 ) shouldBe true
4141 }
4242
43- " detect_added_files_at_runtime_in_subdir" in {
44- copyTestFileToDir(uploadDir.resolve(" subdir" ))
43+ " detect_added_files_at_runtime_in_sub_dir" in {
4544 watcher = DirectoryWatcher (uploadDir, processedDir)
45+ copyTestFileToDir(uploadDir.resolve(" subdir" ))
4646 waitForCondition(3 .seconds)(watcher.countFilesProcessed() == 2 + 1 ) shouldBe true
4747 }
4848
4949 " detect_added_nested_subdir_at_runtime_with_files_in_subdir" in {
50+ watcher = DirectoryWatcher (uploadDir, processedDir)
5051 val tmpDir = Files .createTempDirectory(" tmp" )
5152 val sourcePath = Paths .get(" src/main/resources/testfile.jpg" )
5253 val targetPath = tmpDir.resolve(createUniqueFileName(sourcePath.getFileName))
5354 val targetPath2 = tmpDir.resolve(createUniqueFileName(sourcePath.getFileName))
5455 Files .copy(sourcePath, targetPath)
5556 Files .copy(sourcePath, targetPath2)
56-
5757 val targetDir = Files .createDirectories(uploadDir.resolve(" subdir" ).resolve(" nestedDirWithFiles" ))
5858 FileUtils .copyDirectory(tmpDir.toFile, targetDir.toFile)
59+ waitForCondition(3 .seconds)(watcher.countFilesProcessed() == 2 + 2 ) shouldBe true
60+ }
5961
62+ " handle_large_number_of_files_in_parent_dir" in {
63+ (1 to 1000 ).foreach(_ => copyTestFileToDir(uploadDir))
6064 watcher = DirectoryWatcher (uploadDir, processedDir)
61- waitForCondition(3 .seconds)(watcher.countFilesProcessed() == 2 + 2 ) shouldBe true
65+ waitForCondition(5 .seconds)(watcher.countFilesProcessed() == 2 + 1000 ) shouldBe true
6266 }
6367
64- " handle invalid parent directory path " in {
68+ " handle_invalid_parent_directory_path " in {
6569 val invalidParentDir = Paths .get(" /path/to/non-existent/directory" )
6670 val processedDir = Files .createTempDirectory(" processed" )
6771
0 commit comments