From bdea10de42624a8a031f05665fc8e5037b436740 Mon Sep 17 00:00:00 2001 From: mamadou lamine ba Date: Thu, 28 Nov 2019 21:01:31 +0100 Subject: [PATCH] updating the FileWatcherTest case --- src/test/java/org/gservlet/FileWatcherTest.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/test/java/org/gservlet/FileWatcherTest.java b/src/test/java/org/gservlet/FileWatcherTest.java index dd45228..afb70d5 100644 --- a/src/test/java/org/gservlet/FileWatcherTest.java +++ b/src/test/java/org/gservlet/FileWatcherTest.java @@ -29,16 +29,20 @@ public void onDeleted(String name) { }).watch(); assertEquals(1, watcher.getListeners().size()); - Thread.sleep(2000); + wait(2000); File file = new File("src/test/resources/test.txt"); PrintWriter printWriter = new PrintWriter(new FileWriter(file)); printWriter.print("Some String"); printWriter.close(); - Thread.sleep(2000); + wait(2000); file.delete(); - Thread.sleep(2000); + wait(2000); assertEquals(file.getName(), map.get("file.created")); assertEquals(file.getName(), map.get("file.deleted")); } + + public void wait(int seconds) throws InterruptedException { + Thread.sleep(seconds); + } } \ No newline at end of file