@Override public void execute() { Idles.idle(duration, unit); } }
public void register(final File file, final Function<File, Void> listener) { Path directory = Files.directoryOf(file).toPath(); WatchKey key = registerDirectory(directory); Path path = file.toPath(); keys.put(key, path); listeners.put(path, listener); directoryToFiles.put(directory, path); idle(REGISTER_INTERVAL, TimeUnit.MILLISECONDS); }
protected void waitChangeHappens() { try { idle(INTERVAL * 3, TimeUnit.MILLISECONDS); } catch (Exception e) { fail(format("failed to wait change happens: %s", e.getMessage())); } }
@Test public void should_fire_event_with_post_url_template() throws IOException { runWithConfiguration("event.json"); File file = folder.newFile(); System.setOut(new PrintStream(new FileOutputStream(file))); assertThat(helper.get(remoteUrl("/post-event-with-template-url")), is("post_foo")); idle(IDLE, TimeUnit.MILLISECONDS); assertThat(Files.toString(file, Charset.defaultCharset()), containsString("0XCAFEBABE")); }
@Override public void run() throws Exception { assertThat(helper.get(remoteUrl("/event")), is("event")); verify(handler, never()).writeToResponse(any(SessionContext.class)); Idles.idle(2, TimeUnit.SECONDS); } });
@Override public void run() throws Exception { assertThat(helper.get(remoteUrl("/event")), is("event")); verify(handler, never()).writeToResponse(any(SessionContext.class)); Idles.idle(2, TimeUnit.SECONDS); } });
@Test public void should_fire_get_event() throws IOException { runWithConfiguration("event.json"); File file = folder.newFile(); System.setOut(new PrintStream(new FileOutputStream(file))); assertThat(helper.get(remoteUrl("/get_event")), is("get_foo")); idle(IDLE, TimeUnit.MILLISECONDS); assertThat(Files.toString(file, Charset.defaultCharset()), containsString("0XCAFEBABE")); }
@Test public void should_fire_get_event_with_template() throws IOException { runWithConfiguration("event.json"); File file = folder.newFile(); System.setOut(new PrintStream(new FileOutputStream(file))); assertThat(helper.get(remoteUrl("/get_event_template")), is("get_foo")); idle(IDLE, TimeUnit.MILLISECONDS); assertThat(Files.toString(file, Charset.defaultCharset()), containsString("0XCAFEBABE")); }
@Test public void should_fire_event() throws IOException { runWithConfiguration("event.json"); File file = folder.newFile(); System.setOut(new PrintStream(new FileOutputStream(file))); assertThat(helper.get(remoteUrl("/event")), is("post_foo")); idle(IDLE, TimeUnit.MILLISECONDS); assertThat(Files.toString(file, Charset.defaultCharset()), containsString("0XCAFEBABE")); }
@Test public void should_fire_event_with_unit() throws IOException { runWithConfiguration("event.json"); File file = folder.newFile(); System.setOut(new PrintStream(new FileOutputStream(file))); assertThat(helper.get(remoteUrl("/event-with-unit")), is("post_foo")); idle(IDLE, TimeUnit.MILLISECONDS); assertThat(Files.toString(file, Charset.defaultCharset()), containsString("0XCAFEBABE")); }
@Test public void should_fire_event_with_post_content_template() throws IOException { runWithConfiguration("event.json"); File file = folder.newFile(); System.setOut(new PrintStream(new FileOutputStream(file))); assertThat(helper.get(remoteUrl("/post-event-with-template-content")), is("post_foo")); idle(IDLE, TimeUnit.MILLISECONDS); assertThat(Files.toString(file, Charset.defaultCharset()), containsString("0XCAFEBABE")); }
@Test public void should_fire_event_with_post_json() throws IOException { runWithConfiguration("event.json"); File file = folder.newFile(); System.setOut(new PrintStream(new FileOutputStream(file))); assertThat(helper.get(remoteUrl("/event-with-json-post")), is("post_json_foo")); idle(IDLE, TimeUnit.MILLISECONDS); assertThat(Files.toString(file, Charset.defaultCharset()), containsString("0XMOCOJSON")); } }
public void register(final File file, final Function<File, Void> listener) { Path directory = Files.directoryOf(file).toPath(); WatchKey key = registerDirectory(directory); Path path = file.toPath(); keys.put(key, path); listeners.put(path, listener); directoryToFiles.put(directory, path); idle(REGISTER_INTERVAL, TimeUnit.MILLISECONDS); }