/** * Specifies the duration window which has to be satisfied during operation execution. In case operation is executed * before <code>atLeastDuration</code> or after <code>atMostDuration</code> timeout exception is thrown. * * @param atLeastDuration lower part of execution window * @param atMostDuration upper part of execution window * @return the condition factory */ public ConditionFactory between(long atLeastDuration, TimeUnit atLeastTimeUnit, long atMostDuration, TimeUnit atMostTimeUnit) { return between(new Duration(atLeastDuration, atLeastTimeUnit), new Duration(atMostDuration, atMostTimeUnit)); }
/** * Specifies the duration window which has to be satisfied during operation execution. In case operation is executed * before <code>atLeastDuration</code> or after <code>atMostDuration</code> timeout exception is thrown. * * @param atLeastDuration lower part of execution window * @param atMostDuration upper part of execution window * @return the condition factory */ public ConditionFactory between(long atLeastDuration, TimeUnit atLeastTimeUnit, long atMostDuration, TimeUnit atMostTimeUnit) { return between(new Duration(atLeastDuration, atLeastTimeUnit), new Duration(atMostDuration, atMostTimeUnit)); }
@Test public void watchFileTimeout() { final HttpHeaders headers = HttpHeaders.of(HttpMethod.GET, CONTENTS_PREFIX + "/foo.json") .add(HttpHeaderNames.IF_NONE_MATCH, "-1") .add(HttpHeaderNames.PREFER, "wait=5"); // 5 seconds final CompletableFuture<AggregatedHttpMessage> future = httpClient().execute(headers).aggregate(); await().between(4, TimeUnit.SECONDS, 6, TimeUnit.SECONDS).until(future::isDone); assertThat(future.join().headers().status()).isSameAs(HttpStatus.NOT_MODIFIED); }
@Test public void watchRepositoryTimeout() { final HttpHeaders headers = HttpHeaders.of(HttpMethod.GET, CONTENTS_PREFIX) .add(HttpHeaderNames.IF_NONE_MATCH, "-1") .add(HttpHeaderNames.PREFER, "wait=5"); // 5 seconds final CompletableFuture<AggregatedHttpMessage> future = httpClient().execute(headers).aggregate(); await().between(4, TimeUnit.SECONDS, 6, TimeUnit.SECONDS).until(future::isDone); assertThat(future.join().headers().status()).isSameAs(HttpStatus.NOT_MODIFIED); }