@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)); } };
@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, 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 = 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 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) 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 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()); }
@BeforeClass public static void exceptionThrowingSetupStep() { new Asynch(fakeRepository).perform(); Awaitility .with().ignoreExceptions() .await().atMost(1000, TimeUnit.MILLISECONDS).until( conditionsThatIsThrowingAnExceptionForATime() ); }
@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) public void awaitOperationSupportsSpecifyingPollInterval() { new Asynch(fakeRepository).perform(); with().pollInterval(Duration.ONE_HUNDRED_MILLISECONDS).then().await().until(fakeRepositoryValueEqualsOne()); assertEquals(1, fakeRepository.getValue()); }
@Test(timeout = 2000) public void awaitOperationSupportsSpecifyingZeroAsPollDelay() { new Asynch(fakeRepository).perform(); with().pollDelay(Duration.ZERO).pollInterval(Duration.ONE_HUNDRED_MILLISECONDS).then().await().until(fakeRepositoryValueEqualsOne()); assertEquals(1, fakeRepository.getValue()); }
@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()); }
@Test(timeout = 2000) public void awaitOperationDoesntSupportSpecifyingForeverAsPollInterval() { exception.expect(IllegalArgumentException.class); exception.expectMessage("Cannot use a fixed poll interval of length 'forever'"); new Asynch(fakeRepository).perform(); with().pollDelay(Duration.ONE_HUNDRED_MILLISECONDS).pollInterval(Duration.FOREVER).then().await().until(fakeRepositoryValueEqualsOne()); assertEquals(1, fakeRepository.getValue()); }
@Test(timeout = 2000) public void awaitOperationDoesntSupportSpecifyingForeverAsPollDelay() { exception.expect(IllegalArgumentException.class); exception.expectMessage("Cannot delay polling forever"); new Asynch(fakeRepository).perform(); with().pollDelay(Duration.FOREVER).pollInterval(Duration.ONE_HUNDRED_MILLISECONDS).then().await().until(fakeRepositoryValueEqualsOne()); assertEquals(1, fakeRepository.getValue()); }
private void waitForDiferenciaToBecomeHealthy() { try { given().ignoreExceptions() .await().atMost(10, TimeUnit.SECONDS).until(diferenciaClient::healthy); } catch (ConditionTimeoutException e) { throw new IllegalStateException(diferenciaExecutor.checkForFailure(), e); } }
/** * Periodically checks for the status of stack creation until a defined timeout. * * @param stackName Name of the stack * @param cloudFormation AWS cloud formation * @param timeOutBuilder TimeOut object */ public void waitForStack(String stackName, AmazonCloudFormation cloudFormation, TimeOutBuilder timeOutBuilder) throws ConditionTimeoutException, TestGridInfrastructureException { logger.info("AWS CloudFormation stack creation events:"); Awaitility.with().pollInterval(timeOutBuilder.getPollInterval(), timeOutBuilder.getPollUnit()).await(). atMost(timeOutBuilder.getTimeOut(), timeOutBuilder.getTimeOutUnit()) .until(new StackCreationVerifier(stackName, cloudFormation)); }
public String waitForAvailableRegion( List<AWSResourceRequirement> resourceRequirements, TimeOutBuilder timeOutBuilder) throws ConditionTimeoutException, TestGridInfrastructureException, TestGridDAOException { AWSResourceLimitUOW awsResourceLimitUOW = new AWSResourceLimitUOW(); String region = awsResourceLimitUOW.getAvailableRegion(resourceRequirements); if (region != null) { availableRegion = region; } else { logger.info("Waiting for an available region on AWS..."); Awaitility.with().pollInterval(timeOutBuilder.getPollInterval(), timeOutBuilder.getPollUnit()).await(). atMost(timeOutBuilder.getTimeOut(), timeOutBuilder.getTimeOutUnit()) .until(new RegionAvailabilityWaiter(resourceRequirements)); } return availableRegion; }
@Test public void testLogsController() throws IOException { final String expectedDBState = resource("logs-controller-db.json").trim(); final String podLogs = resource("test-pod-x23x.txt"); final InputStream podLogsStream = new ByteArrayInputStream(podLogs.getBytes(StandardCharsets.UTF_8)); try (ActivityTrackingController controller = new StubbedController(jsondb, dbi, client, podLogsStream, ZonedDateTime.parse("2018-01-12T21:22:02.068338027Z").toInstant().toEpochMilli())) { controller.setStartupDelay("0 seconds"); controller.setRetention(Integer.MAX_VALUE); controller.open(); // Eventually all the log data should make it into the jsondb given().await() .atMost(20, SECONDS) .pollInterval(1, SECONDS) .untilAsserted(() -> { String db = jsondb.getAsString("/", new GetOptions().prettyPrint(true)); assertThat(db).isEqualTo(expectedDBState); }); } }