/** * Specifies the duration window which has to be satisfied during operation execution. In case operation is executed * before <code>atLeast</code> or after <code>atMost</code> timeout exception is thrown. * * @param atLeast lower part of execution window * @param atMost upper part of execution window * @return the condition factory */ public ConditionFactory between(Duration atLeast, Duration atMost) { return atLeast(atLeast).and().atMost(atMost); }
/** Returns a configured {@link ConditionFactory} that polls at a short interval. */ public static ConditionFactory await() { return Awaitility.with() .pollDelay(1, TimeUnit.MILLISECONDS).and() .pollInterval(1, TimeUnit.MILLISECONDS); } }
@Override public void testLogic() { new ExceptionThrowingAsynch(new IllegalStateException("Illegal state!")).perform(); dontCatchUncaughtExceptions().and().await().atMost(Duration.ONE_SECOND).until(value(), equalTo(1)); } };
@Override public void testLogic() { new ExceptionThrowingAsynch(new IllegalStateException("Illegal state!")).perform(); dontCatchUncaughtExceptions().and().await().atMost(ONE_SECOND).until(value(), equalTo(1)); } };
@Override public void testLogic() { new ExceptionThrowingAsynch(new IllegalStateException("Illegal state!")).perform(); await().and().dontCatchUncaughtExceptions().given().timeout(ONE_SECOND).until(value(), equalTo(1)); } };
@Test(timeout = 2000, expected = IllegalStateException.class) public void uncaughtExceptionsArePropagatedToAwaitingThreadAndBreaksForeverBlockWhenCatchingAllUncaughtExceptions() { new ExceptionThrowingAsynch(new IllegalStateException("Illegal state!")).perform(); catchUncaughtExceptions().and().await().forever().until(value(), equalTo(1)); }
given().pollDelay(0, MILLISECONDS).and().ignoreExceptions().await().until(new Callable<Boolean>() { @Override public Boolean call() {
@Test(timeout = 3000, expected = ConditionTimeoutException.class) public void throwsTimeoutExceptionWhenDoneEarlierThanAtLeastConstraint() { new Asynch(fakeRepository).perform(); await().atLeast(1, SECONDS).and().atMost(2, SECONDS).until(value(), equalTo(1)); }
@Test(timeout = 2000) public void ignoreExceptionWorksWithThrowable() { new Asynch(fakeRepository).perform(); await().atMost(1000, MILLISECONDS).and().ignoreException(AssertionError.class).until(conditionsThatIsThrowingAnExceptionForATime(AssertionError.class)); }
@Test(timeout = 2000) public void exceptionsDuringEvaluationAreIgnoredUponRequest() { new Asynch(fakeRepository).perform(); await().atMost(1000, MILLISECONDS).and().ignoreExceptions().until(conditionsThatIsThrowingAnExceptionForATime(IllegalArgumentException.class)); }
@Test(timeout = 2000) public void exceptionsOnlySpecifiedExceptionsAreIgnored() { new Asynch(fakeRepository).perform(); await().atMost(1000, MILLISECONDS).and().ignoreException(IllegalArgumentException.class).until(conditionsThatIsThrowingAnExceptionForATime(IllegalArgumentException.class)); }
@Test(timeout = 2000) public void exceptionsOnlySpecifiedExceptionsAreIgnoredWhenUsingShortcut() { new Asynch(fakeRepository).perform(); await().atMost(1000, MILLISECONDS).and().ignoreExceptionsInstanceOf(RuntimeException.class).until(conditionsThatIsThrowingAnExceptionForATime(IllegalArgumentException.class)); }
@Test(timeout = 2000) public void throwablesDuringEvaluationAreIgnoredUponRequest() { new Asynch(fakeRepository).perform(); await().atMost(1000, MILLISECONDS).and().ignoreExceptions().until(conditionsThatIsThrowingAnExceptionForATime(AssertionError.class)); }
/** * Specifies the duration window which has to be satisfied during operation execution. In case operation is executed * before <code>atLeast</code> or after <code>atMost</code> timeout exception is thrown. * * @param atLeast lower part of execution window * @param atMost upper part of execution window * @return the condition factory */ public ConditionFactory between(Duration atLeast, Duration atMost) { return atLeast(atLeast).and().atMost(atMost); }