Examples of CountDown


Examples of com.jayway.awaitility.support.CountDown

    }

    @SuppressWarnings("Convert2Lambda")
    @Test(timeout = 2000)
    public void expectedMatchMessageForCallableConditionsWithAliasWhenNotUsingLambda() {
        final CountDown countDown = new CountDown(10);
        final AtomicReference<String> lastMatchMessage = new AtomicReference<>();
        with()
                .conditionEvaluationListener(condition -> lastMatchMessage.set(condition.getDescription()))
                .await("my alias")
                .until(new Callable<Boolean>() {
                    @Override
                    public Boolean call() throws Exception {
                        return countDown.call() == 5;
                    }
                });

        assertThat(lastMatchMessage.get(), allOf(startsWith("Callable condition with alias my alias defined in"), containsString(testName.getMethodName()), endsWith("returned true")));
    }
View Full Code Here

Examples of com.jayway.awaitility.support.CountDown

        assertThat(lastMatchMessage.get(), allOf(startsWith("Callable condition with alias my alias defined in"), containsString(testName.getMethodName()), endsWith("returned true")));
    }

    @Test(timeout = 2000)
    public void expectedMatchMessageForCallableConditionsWithoutAliasWhenUsingLambda() {
        final CountDown countDown = new CountDown(10);
        final AtomicReference<String> lastMatchMessage = new AtomicReference<>();
        with()
                .conditionEvaluationListener(condition -> lastMatchMessage.set(condition.getDescription()))
                .until(() -> countDown.call() == 5);

        assertThat(lastMatchMessage.get(), allOf(startsWith("Condition defined as a lambda expression in"), containsString(getClass().getName()), endsWith("returned true")));
    }
View Full Code Here

Examples of com.jayway.awaitility.support.CountDown

        assertThat(lastMatchMessage.get(), allOf(startsWith("Condition defined as a lambda expression in"), containsString(getClass().getName()), endsWith("returned true")));
    }

    @Test(timeout = 2000)
    public void expectedMatchMessageForCallableConditionsWithAliasWhenUsingLambda() {
        final CountDown countDown = new CountDown(10);
        final AtomicReference<String> lastMatchMessage = new AtomicReference<>();
        with()
                .conditionEvaluationListener(condition -> lastMatchMessage.set(condition.getDescription()))
                .await("my alias")
                .until(() -> countDown.call() == 5);

        assertThat(lastMatchMessage.get(), allOf(startsWith("Condition with alias my alias defined as a lambda expression in "), containsString(getClass().getName()), endsWith("returned true")));
    }
View Full Code Here

Examples of com.jayway.awaitility.support.CountDown

    // Callable<Boolean> mismatch tests

    @SuppressWarnings("Convert2Lambda")
    @Test(timeout = 2000)
    public void expectedMismatchMessageForCallableConditionsWithoutAliasWhenNotUsingLambda() {
        final CountDown countDown = new CountDown(10);
        final AtomicReference<String> lastMatchMessage = new AtomicReference<>();
        try {
            with()
                    .conditionEvaluationListener(condition -> lastMatchMessage.set(condition.getDescription()))
                    .await().atMost(150, MILLISECONDS)
                    .until(new Callable<Boolean>() {
                        @Override
                        public Boolean call() throws Exception {
                            return countDown.call() == -1;
                        }
                    });
            fail("Should fail");
        } catch (Exception e) {
            assertThat(lastMatchMessage.get(), allOf(startsWith("Callable condition defined in"), containsString(testName.getMethodName()), endsWith("returned false")));
View Full Code Here

Examples of com.jayway.awaitility.support.CountDown

    }

    @SuppressWarnings("Convert2Lambda")
    @Test(timeout = 2000)
    public void expectedMismatchMessageForCallableConditionsWithAliasWhenNotUsingLambda() {
        final CountDown countDown = new CountDown(10);
        final AtomicReference<String> lastMatchMessage = new AtomicReference<>();
        try {
            with()
                    .conditionEvaluationListener(condition -> lastMatchMessage.set(condition.getDescription()))
                    .await("my alias").atMost(150, MILLISECONDS)
                    .until(new Callable<Boolean>() {
                        @Override
                        public Boolean call() throws Exception {
                            return countDown.call() == 5;
                        }
                    });
            fail("Should fail");
        } catch (Exception e) {
            assertThat(lastMatchMessage.get(), allOf(startsWith("Callable condition with alias my alias defined in"), containsString(testName.getMethodName()), endsWith("returned false")));
View Full Code Here

Examples of com.jayway.awaitility.support.CountDown

        }
    }

    @Test(timeout = 2000)
    public void expectedMismatchMessageForCallableConditionsWithoutAliasWhenUsingLambda() {
        final CountDown countDown = new CountDown(10);
        final AtomicReference<String> lastMatchMessage = new AtomicReference<>();
        try {
            with()
                    .conditionEvaluationListener(condition -> lastMatchMessage.set(condition.getDescription()))
                    .await().atMost(150, MILLISECONDS)
                    .until(() -> countDown.call() == 5);
            fail("Should fail");
        } catch (Exception e) {
            assertThat(lastMatchMessage.get(), allOf(startsWith("Condition defined as a lambda expression in"), containsString(getClass().getName()), endsWith("returned false")));
        }
    }
View Full Code Here

Examples of com.jayway.awaitility.support.CountDown

        }
    }

    @Test(timeout = 2000)
    public void expectedMismatchMessageForCallableConditionsWithAliasWhenUsingLambda() {
        final CountDown countDown = new CountDown(10);
        final AtomicReference<String> lastMatchMessage = new AtomicReference<>();
        try {
            with()
                    .conditionEvaluationListener(condition -> lastMatchMessage.set(condition.getDescription()))
                    .await("my alias").atMost(150, MILLISECONDS)
                    .until(() -> countDown.call() == 5);
            fail("Should fail");
        } catch (Exception e) {
            assertThat(lastMatchMessage.get(), allOf(startsWith("Condition with alias my alias defined as a lambda expression in "), containsString(getClass().getName()), endsWith("returned false")));
        }
    }
View Full Code Here

Examples of com.jayway.awaitility.support.CountDown

    }

    // Callable<Boolean> value test
    @Test(timeout = 2000)
    public void conditionOfCallableBooleanHasBooleanValuesInConditionEvalutionListener() {
        final CountDown countDown = new CountDown(10);
        final List<Boolean> results = new ArrayList<>();
        with()
                .conditionEvaluationListener(condition -> results.add((Boolean) condition.getValue()))
                .until(() -> countDown.call() == 5);

        assertThat(results.get(results.size() - 1), is(true));
        assertThat(results.subList(0, results.size() - 1), allOf(hasItem(false), not(hasItem(true))));
    }
View Full Code Here

Examples of com.jayway.awaitility.support.CountDown

    public void conditionResultsCanBeLoggedToSystemOut() {
        with()
                .conditionEvaluationListener(condition -> System.out.printf("%s (elapsed time %dms, remaining time %dms)\n", condition.getDescription(), condition.getElapsedTimeInMS(), condition.getRemainingTimeInMS()))
                .pollInterval(Duration.ONE_HUNDRED_MILLISECONDS)
                .atMost(Duration.TWO_SECONDS)
                .until(new CountDown(5), anyOf(is(0), lessThan(0)));
    }
View Full Code Here

Examples of com.jayway.awaitility.support.CountDown

    public void loggingIntermediaryHandlerLogsToSystemOut() {
        with()
                .conditionEvaluationListener(new ConditionEvaluationLogger(SECONDS))
                .pollInterval(Duration.ONE_HUNDRED_MILLISECONDS)
                .atMost(Duration.TWO_SECONDS)
                .until(new CountDown(5), is(equalTo(0)));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.