Notice to GitKraken users: A vulnerability has been found in the SSH key generation of GitKraken versions 7.6.0 to 8.0.0 (https://www.gitkraken.com/blog/weak-ssh-key-fix). If you use GitKraken and have generated a SSH key using one of these versions, please remove it both from your local workstation and from your LRZ GitLab profile.

21.10.2021, 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

Commit 31ffb963 authored by Stefan Schuhbaeck's avatar Stefan Schuhbaeck
Browse files

Add register method which provides a List of directories

parent d71711f5
...@@ -65,7 +65,7 @@ public class OutputDirWatcherBuilder { ...@@ -65,7 +65,7 @@ public class OutputDirWatcherBuilder {
return outputDirWatcher; return outputDirWatcher;
} }
private void addDefaultEventHandler() { public void addDefaultEventHandler() {
WatchEventHandler simulationOutputDirCreated = (dir, ev) -> { WatchEventHandler simulationOutputDirCreated = (dir, ev) -> {
if ((ev.length == 1) && (ev[0].kind() == ENTRY_CREATE)) { if ((ev.length == 1) && (ev[0].kind() == ENTRY_CREATE)) {
...@@ -130,6 +130,12 @@ public class OutputDirWatcherBuilder { ...@@ -130,6 +130,12 @@ public class OutputDirWatcherBuilder {
} }
public void register(List<Path> dirs, WatchEvent.Kind<?>... events) throws IOException {
for(Path dir : dirs){
register(dir, events);
}
}
public void register(Path dir, WatchEvent.Kind<?>... events) throws IOException { public void register(Path dir, WatchEvent.Kind<?>... events) throws IOException {
WatchEvent.Kind<?>[] selectedEvents; WatchEvent.Kind<?>[] selectedEvents;
......
...@@ -13,6 +13,8 @@ import java.io.PrintStream; ...@@ -13,6 +13,8 @@ import java.io.PrintStream;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotEquals;
...@@ -49,7 +51,7 @@ public class OutputDirWatcherBuilderTest { ...@@ -49,7 +51,7 @@ public class OutputDirWatcherBuilderTest {
assertEquals("There should be three default Handlers", assertEquals("There should be three default Handlers",
5,builder.getHandlers().size()); 5,builder.getHandlers().size());
assertEquals("There should be 15 directories in the watch list", assertEquals("There should be 15 directories in the watch list",
14, builder.getKeys().size()); 15, builder.getKeys().size());
Path corruptedDir = project.getOutputDir().resolve(IOUtils.CORRUPT_DIR); Path corruptedDir = project.getOutputDir().resolve(IOUtils.CORRUPT_DIR);
builder.getKeys().forEach((k,v) -> { builder.getKeys().forEach((k,v) -> {
...@@ -97,7 +99,17 @@ public class OutputDirWatcherBuilderTest { ...@@ -97,7 +99,17 @@ public class OutputDirWatcherBuilderTest {
public void registerAll() throws Exception { public void registerAll() throws Exception {
builder.initOutputDirWatcher(project).registerAll(project.getOutputDir()); builder.initOutputDirWatcher(project).registerAll(project.getOutputDir());
assertEquals("There should be 15 directories in the watch list", assertEquals("There should be 15 directories in the watch list",
14, builder.getKeys().size()); 15, builder.getKeys().size());
} }
@Test
public void register1() throws Exception {
List<Path> paths = new ArrayList<>();
paths.add(project.getOutputDir().resolve("test_postvis_2018-01-17_16-57-06.272"));
paths.add(project.getOutputDir().resolve("test_postvis_2018-01-19_13-23-14.675"));
builder.initOutputDirWatcher(project).register(paths);
assertEquals("", 2, builder.getKeys().size());
}
} }
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment