@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, expected = IllegalStateException.class) public void uncaughtExceptionsArePropagatedToAwaitingThreadAndBreaksForeverBlockWhenCatchingAllUncaughtExceptions() { new ExceptionThrowingAsynch(new IllegalStateException("Illegal state!")).perform(); catchUncaughtExceptions().and().await().forever().until(value(), equalTo(1)); }
@Test(timeout = 3000) public void doesNotThrowTimeoutExceptionWhenDoneLaterThanAtLeastConstraint() { new Asynch(fakeRepository).perform(); await().atLeast(100, NANOSECONDS).until(value(), equalTo(1)); }
@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(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 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, 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, 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 foreverConditionWithHamcrestMatchersWithDirectBlock() { new Asynch(fakeRepository).perform(); await().forever().until(value(), equalTo(1)); assertEquals(1, fakeRepository.getValue()); }
@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 specifyingDefaultPollIntervalImpactsAllSubsequentUndefinedPollIntervalStatements() { Awaitility.setDefaultPollInterval(20, TimeUnit.MILLISECONDS); new Asynch(fakeRepository).perform(); await().until(value(), equalTo(1)); assertEquals(1, fakeRepository.getValue()); }