@Test(timeout = 2000) public void awaitDisplaysCallableNameWhenConditionTimeoutExceptionOccurs() { exception.expect(ConditionTimeoutException.class); exception.expectMessage(String.format("Condition %s was not fulfilled within 120 milliseconds.", FakeRepositoryEqualsOne.class.getName())); await().atMost(120, MILLISECONDS).until(fakeRepositoryValueEqualsOne()); }
@Test(timeout = 2000) public void awaitDisplaysMethodDeclaringTheCallableWhenCallableIsAnonymousClassAndConditionTimeoutExceptionOccurs() { exception.expect(ConditionTimeoutException.class); exception .expectMessage(String .format("Condition returned by method \"fakeRepositoryValueEqualsOneAsAnonymous\" in class %s was not fulfilled within 120 milliseconds.", AwaitilityTest.class.getName())); await().atMost(120, MILLISECONDS).until(fakeRepositoryValueEqualsOneAsAnonymous()); }
@Test(timeout = 2000, expected = IllegalStateException.class) public void uncaughtExceptionsArePropagatedToAwaitingThreadAndBreaksForeverBlockWhenSetToCatchAllUncaughtExceptions() { catchUncaughtExceptionsByDefault(); new ExceptionThrowingAsynch(new IllegalStateException("Illegal state!")).perform(); await().forever().until(value(), equalTo(1)); }
@Test(timeout = 2000) public void awaitDisplaysMethodDeclaringTheSupplierWhenSupplierIsAnonymousClassAndConditionTimeoutExceptionOccurs() { exception.expect(ConditionTimeoutException.class); exception .expectMessage(String .format("%s.valueAsAnonymous Callable expected %s but was <0> within 120 milliseconds.", AwaitilityTest.class.getName(), equalTo(2).toString())); with().pollInterval(10, MILLISECONDS).await().atMost(120, MILLISECONDS).until(valueAsAnonymous(), equalTo(2)); }
@Test(timeout = 2000) public void foreverConditionWithHamcrestCollectionMatchersWithDirectBlock() { new Asynch(fakeRepository).perform(); await().forever().until(valueAsList(), hasItem(1)); assertEquals(1, fakeRepository.getValue()); }
@Test public void awaitilityThrowsIllegalStateExceptionWhenTimeoutIsLessThanPollDelay() { exception.expect(IllegalStateException.class); exception.expectMessage(is("Timeout (10 seconds) must be greater than the poll delay (10 minutes).")); with().pollDelay(10, MINUTES).await().atMost(10, SECONDS).until(fakeRepositoryValueEqualsOne()); }
@Test(timeout = 2000, expected = IllegalStateException.class) public void uncaughtExceptionsArePropagatedToAwaitingThreadAndBreaksForeverBlockWhenCatchingAllUncaughtExceptions() { new ExceptionThrowingAsynch(new IllegalStateException("Illegal state!")).perform(); catchUncaughtExceptions().and().await().forever().until(value(), equalTo(1)); }
@Test(timeout = 2000) public void awaitOperationSupportsSpecifyingPollIntervalUsingTimeunit() { new Asynch(fakeRepository).perform(); with().pollInterval(20, TimeUnit.MILLISECONDS).await().until(fakeRepositoryValueEqualsOne()); given().pollInterval(20, TimeUnit.MILLISECONDS).await().until(fakeRepositoryValueEqualsOne()); assertEquals(1, fakeRepository.getValue()); }
@Test(timeout = 3000) public void doesNotThrowTimeoutExceptionWhenDoneLaterThanAtLeastConstraint() { new Asynch(fakeRepository).perform(); await().atLeast(100, NANOSECONDS).until(value(), equalTo(1)); }
@Test(timeout = 2000) public void awaitOperationBlocksAutomatically() { new Asynch(fakeRepository).perform(); await().until(fakeRepositoryValueEqualsOne()); assertEquals(1, fakeRepository.getValue()); }
@Test(timeout = 2000) public void awaitWithAliasDisplaysAliasWhenConditionTimeoutExceptionOccurs() { String alias = "test"; exception.expect(ConditionTimeoutException.class); exception.expectMessage( "Condition with alias 'test' didn't complete within 120 milliseconds because org.awaitility.classes.FakeRepositoryValue expected a value greater than <0> but <0> was equal to <0>."); await(alias).atMost(120, MILLISECONDS).until(value(), greaterThan(0)); }
@Test public void awaitilityThrowsIllegalStateExceptionWhenTimeoutIsEqualToPollDelay() { exception.expect(IllegalStateException.class); exception.expectMessage(is("Timeout (200 milliseconds) must be greater than the poll delay (200 milliseconds).")); with().with().pollDelay(20, MILLISECONDS).pollDelay(200, MILLISECONDS).await().atMost(200, MILLISECONDS).until(fakeRepositoryValueEqualsOne()); }
@Test(timeout = 2000L, expected = ConditionTimeoutException.class) public void awaitOperationSupportsDefaultTimeout() { Awaitility.setDefaultTimeout(120, TimeUnit.MILLISECONDS); await().until(value(), greaterThan(0)); assertEquals(1, fakeRepository.getValue()); }
@Test(timeout = 2000) public void foreverConditionSpecificationUsingUntilWithDirectBlock() { new Asynch(fakeRepository).perform(); await().forever().until(fakeRepositoryValueEqualsOne()); assertEquals(1, fakeRepository.getValue()); }
@Test(timeout = 2000) public void awaitDisplaysSupplierAndMatcherMismatchMessageWhenConditionTimeoutExceptionOccurs() { exception.expect(ConditionTimeoutException.class); exception.expectMessage(FakeRepositoryValue.class.getName() + " expected a value greater than <0> but <0> was equal to <0> within 120 milliseconds."); with().pollInterval(10, MILLISECONDS).then().await().atMost(120, MILLISECONDS).until(value(), greaterThan(0)); }
@Test(timeout = 2000) public void awaitOperationSupportsSpecifyingPollDelay() { new Asynch(fakeRepository).perform(); with().pollDelay(Duration.ONE_HUNDRED_MILLISECONDS).await().until(fakeRepositoryValueEqualsOne()); assertEquals(1, fakeRepository.getValue()); }
@Test(timeout = 2000, expected = ConditionTimeoutException.class) public void conditionBreaksAfterDurationTimeout() { new Asynch(fakeRepository).perform(); await().atMost(200, TimeUnit.MILLISECONDS).until(value(), equalTo(1)); assertEquals(1, fakeRepository.getValue()); }
@Test(timeout = 2000) public void awaitOperationSupportsSpecifyingPollInterval() { new Asynch(fakeRepository).perform(); with().pollInterval(Duration.ONE_HUNDRED_MILLISECONDS).then().await().until(fakeRepositoryValueEqualsOne()); assertEquals(1, fakeRepository.getValue()); }
@Test(timeout = 2000, expected = ComparisonFailure.class) public void uncaughtThrowablesArePropagatedToAwaitingThreadAndBreaksForeverBlockWhenSetToCatchAllUncaughtExceptions() { new ExceptionThrowingAsynch(new ComparisonFailure("Message", "Something", "Something else")).perform(); await().forever().until(value(), equalTo(1)); }
@Test(timeout = 2000) public void awaitOperationSupportsSpecifyingZeroAsPollInterval() { new Asynch(fakeRepository).perform(); with().pollDelay(Duration.TWO_HUNDRED_MILLISECONDS).pollInterval(Duration.ZERO).then().await().until(fakeRepositoryValueEqualsOne()); assertEquals(1, fakeRepository.getValue()); }