private void waitForTicks(int minTicks) { try { Awaitility.with() .pollInterval(1, TimeUnit.MILLISECONDS) .atMost(Testing.TEST_TIMEOUT_MS, TimeUnit.MILLISECONDS) .untilAsserted(() -> assertThat(tickTupleCount.get(), Matchers.greaterThanOrEqualTo(minTicks))); } catch (ConditionTimeoutException e) { throw new AssertionError(e.getMessage()); } }
throw new ConditionTimeoutException( "The observed result '" + String.valueOf(supplier.get()) + "' does not satisfy the provided assertionConsumer. \n" + e.getMessage());
@Test(timeout = 2000) public void ignoredExceptionsAreAddedToExceptionHierarchy() { try { await().ignoreExceptions().atMost(200, TimeUnit.MILLISECONDS).until(new Callable<Boolean>() { @Override public Boolean call() throws Exception { throw new Exception("Nested"); } }); fail(); } catch (ConditionTimeoutException e) { assertNotNull(e.getCause()); assertEquals("Nested", e.getCause().getMessage()); } }
throw new ConditionTimeoutException(message, cause); } else if (evaluationDuration.compareTo(minWaitTime) < 0) { String message = String.format("Condition was evaluated in %s %s which is earlier than expected " + "minimum timeout %s %s", evaluationDuration.getValue(), evaluationDuration.getTimeUnit(), minWaitTime.getValue(), minWaitTime.getTimeUnit()); throw new ConditionTimeoutException(message);
await().untilTrue(functionExecuted); } catch (ConditionTimeoutException e) { e.printStackTrace(); lockingThreadState = GetRegionsFunctionTest.STATE.FINISHED;
throw new ConditionTimeoutException(message, cause); } else if (evaluationDuration.compareTo(minWaitTime) < 0) { String message = String.format("Condition was evaluated in %s %s which is earlier than expected " + "minimum timeout %s %s", evaluationDuration.getValue(), evaluationDuration.getTimeUnit(), minWaitTime.getValue(), minWaitTime.getTimeUnit()); throw new ConditionTimeoutException(message);
public static void assertLoop(Predicate<Object> condition, Object... conditionParams) { try { Awaitility.with() .pollInterval(1, TimeUnit.MILLISECONDS) .atMost(Testing.TEST_TIMEOUT_MS, TimeUnit.MILLISECONDS) .untilAsserted(() -> assertThat(Arrays.asList(conditionParams), everyItem(matchesPredicate(condition)))); } catch (ConditionTimeoutException e) { throw new AssertionError(e.getMessage()); } }
Throwable cause = e.getCause(); assertTrue(cause instanceof DeadlockException); assertEquals(2, ((DeadlockException) cause).getThreadInfos().length);
waitForTicks(3); } catch (ConditionTimeoutException e) { throw new AssertionError(e.getMessage());
private void waitForVideoCompleted(File video) { try { await().atMost(5, TimeUnit.SECONDS) .pollDelay(1, TimeUnit.SECONDS) .ignoreExceptions() .until(video::exists); } catch (ConditionTimeoutException ex) { throw new RecordingException(ex.getMessage()); } } }
private void waitForVideoCompleted(File video) { try { await().atMost(5, TimeUnit.SECONDS) .pollDelay(1, TimeUnit.SECONDS) .ignoreExceptions() .until(video::exists); } catch (ConditionTimeoutException ex) { throw new RecordingException(ex.getMessage()); } } }