Package com.jayway.awaitility

Examples of com.jayway.awaitility.Duration


     * <p>await.</p>
     */
    public void await() {
        try {
            try {
                final Duration maxWaitTime = conditionSettings.getMaxWaitTime();
                final long timeout = maxWaitTime.getValue();
                final boolean finishedBeforeTimeout;
                if (maxWaitTime == Duration.FOREVER) {
                    latch.await();
                    finishedBeforeTimeout = true;
                } else if (maxWaitTime == Duration.SAME_AS_POLL_INTERVAL) {
                    throw new IllegalStateException("Cannot use 'SAME_AS_POLL_INTERVAL' as maximum wait time.");
                } else {
                    finishedBeforeTimeout = latch.await(timeout, maxWaitTime.getTimeUnit());
                }
                if (throwable != null) {
                    throw throwable;
                } else if (!finishedBeforeTimeout) {
                    final String maxWaitTimeLowerCase = maxWaitTime.getTimeUnitAsString();
                    final String message;
                    if (conditionSettings.hasAlias()) {
                        message = String.format("Condition with alias '%s' didn't complete within %s %s because %s.",
                                conditionSettings.getAlias(), timeout, maxWaitTimeLowerCase, Introspector.decapitalize(getTimeoutMessage()));
                    } else {
View Full Code Here


     * @param timeout the timeout
     * @param unit    the unit
     * @return the condition factory
     */
    public ConditionFactory timeout(long timeout, TimeUnit unit) {
        return new ConditionFactory(alias, new Duration(timeout, unit), pollInterval, pollDelay,
                catchUncaughtExceptions, conditionEvaluationListener);
    }
View Full Code Here

     * @param delay the delay
     * @param unit  the unit
     * @return the condition factory
     */
    public ConditionFactory pollDelay(long delay, TimeUnit unit) {
        return new ConditionFactory(alias, this.timeout, pollInterval, new Duration(delay, unit),
                catchUncaughtExceptions, conditionEvaluationListener);
    }
View Full Code Here

     * @param timeout the timeout
     * @param unit    the unit
     * @return the condition factory
     */
    public ConditionFactory atMost(long timeout, TimeUnit unit) {
        return new ConditionFactory(alias, new Duration(timeout, unit), pollInterval, pollDelay,
                catchUncaughtExceptions, conditionEvaluationListener);
    }
View Full Code Here

     * @param pollInterval the poll interval
     * @param unit         the unit
     * @return the condition factory
     */
    public ConditionFactory pollInterval(long pollInterval, TimeUnit unit) {
        return new ConditionFactory(alias, timeout, new Duration(pollInterval, unit), pollDelay,
                catchUncaughtExceptions, conditionEvaluationListener);
    }
View Full Code Here

        await().until(receivedMessageCallable(queue), receivedMessageMatcher(queue, testMessage, false));

        // Then

        // Assert that message is invisible for at least 1.5 seconds
        await().atMost(new Duration(1500 - (System.currentTimeMillis() - beforeReceivingTheMessage),
                TimeUnit.MILLISECONDS)).until(receivedMessageCallable(queue), noMessageFound()); // .5s tolerance

        // Finally delete the message
        await().until(receivedMessageCallable(queue), receivedMessageMatcher(queue, testMessage, true));
    }
View Full Code Here

        // Assert that the message is not available in the queue for at least 1.5 seconds
        Thread.sleep(1500 - (System.currentTimeMillis() - beforeSendingTheMessage));
        MatcherAssert.assertThat(receivedMessageCallable(queue).call(), noMessageFound());

        // Try to obtain the message
        await().atMost(new Duration(1000, TimeUnit.MILLISECONDS)).until(receivedMessageCallable(queue),
                receivedMessageMatcher(queue, testMessage, true));
    }
View Full Code Here

TOP

Related Classes of com.jayway.awaitility.Duration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.