Package com.jayway.awaitility.support

Examples of com.jayway.awaitility.support.CountDown



    @Test(timeout = 2000)
    public void expectedMatchMessageForAssertionConditionsWhenUsingLambdasWithoutAlias() {
        final AtomicReference<String> lastMatchMessage = new AtomicReference<>();
        CountDown countDown = new CountDown(10);
        with()
                .conditionEvaluationListener(condition -> {
                    try {
                        countDown.call();
                    } catch (Exception e) {
                        throw new RuntimeException(e);
                    }
                    lastMatchMessage.set(condition.getDescription());
                })
                .until(() -> assertEquals(5, (int) countDown.get()));

        String expectedMatchMessage = String.format("%s reached its end value", CountDown.class.getName());
        assertThat(lastMatchMessage.get(), allOf(startsWith("Condition defined as a lambda expression"), endsWith(expectedMatchMessage)));
    }
View Full Code Here


    }

    @Test(timeout = 2000)
    public void expectedMatchMessageForAssertionConditionsWhenUsingLambdasWithAlias() {
        final AtomicReference<String> lastMatchMessage = new AtomicReference<>();
        CountDown countDown = new CountDown(10);
        with()
                .conditionEvaluationListener(condition -> {
                    try {
                        countDown.call();
                    } catch (Exception e) {
                        throw new RuntimeException(e);
                    }
                    lastMatchMessage.set(condition.getDescription());
                }).await("my alias")
                .until(() -> assertEquals(5, (int) countDown.get()));

        String expectedMatchMessage = String.format("%s reached its end value", CountDown.class.getName());
        assertThat(lastMatchMessage.get(), allOf(startsWith("Condition with alias my alias defined as a lambda expression"), endsWith(expectedMatchMessage)));
    }
View Full Code Here

    }

    @Test(timeout = 2000)
    public void expectedMismatchMessageForAssertionConditionsWhenUsingLambdasWithoutAlias() {
        final AtomicReference<String> lastMatchMessage = new AtomicReference<>();
        CountDown countDown = new CountDown(10);
        try {
            with()
                    .conditionEvaluationListener(condition -> {
                        try {
                            countDown.call();
                        } catch (Exception e) {
                            throw new RuntimeException(e);
                        }
                        lastMatchMessage.set(condition.getDescription());
                    }).await().atMost(150, MILLISECONDS).until(() -> assertEquals(-1, (int) countDown.get()));
            fail("Test should fail");
        } catch (ConditionTimeoutException e) {
            assertThat(lastMatchMessage.get(), allOf(startsWith("Condition defined as a lambda expression in"), containsString("expected:<-1> but was:<")));
        }
    }
View Full Code Here

    }

    @Test(timeout = 2000)
    public void expectedMismatchMessageForAssertionConditionsWhenUsingLambdasWithAlias() {
        final AtomicReference<String> lastMatchMessage = new AtomicReference<>();
        CountDown countDown = new CountDown(10);
        try {
            with().conditionEvaluationListener(condition -> {
                try {
                    countDown.call();
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
                lastMatchMessage.set(condition.getDescription());
            }).await("my alias").atMost(150, MILLISECONDS).until(() -> assertEquals(-1, (int) countDown.get()));
            fail("Test should fail");
        } catch (ConditionTimeoutException e) {
            assertThat(lastMatchMessage.get(), startsWith("Condition with alias my alias defined as a lambda expression"));
        }
    }
View Full Code Here

    @SuppressWarnings("Convert2Lambda")
    @Test(timeout = 2000)
    public void expectedMatchMessageForAssertionConditionsWhenNotUsingLambdasWithoutAlias() {
        final AtomicReference<String> lastMatchMessage = new AtomicReference<>();
        CountDown countDown = new CountDown(10);
        with()
                .conditionEvaluationListener(condition -> {
                    try {
                        countDown.call();
                    } catch (Exception e) {
                        throw new RuntimeException(e);
                    }
                    lastMatchMessage.set(condition.getDescription());
                })
                .until(new Runnable() {
                    @Override
                    public void run() {
                        assertEquals(5, (int) countDown.get());
                    }
                });

        assertThat(lastMatchMessage.get(), allOf(startsWith("Runnable condition defined in"), containsString(testName.getMethodName()), endsWith("reached its end value")));
    }
View Full Code Here

    @SuppressWarnings("Convert2Lambda")
    @Test(timeout = 2000)
    public void expectedMatchMessageForAssertionConditionsWhenNotUsingLambdasWithAlias() {
        final AtomicReference<String> lastMatchMessage = new AtomicReference<>();
        CountDown countDown = new CountDown(10);
        with()
                .conditionEvaluationListener(condition -> {
                    try {
                        countDown.call();
                    } catch (Exception e) {
                        throw new RuntimeException(e);
                    }
                    lastMatchMessage.set(condition.getDescription());
                }).await("my alias")
                .until(new Runnable() {
                    @Override
                    public void run() {
                        assertEquals(5, (int) countDown.get());
                    }
                });

        assertThat(lastMatchMessage.get(), allOf(startsWith("Runnable condition with alias my alias defined in"), containsString(testName.getMethodName()), endsWith("reached its end value")));
    }
View Full Code Here

    @SuppressWarnings("Convert2Lambda")
    @Test(timeout = 2000)
    public void expectedMismatchMessageForAssertionConditionsWhenNotUsingLambdasWithoutAlias() {
        final AtomicReference<String> lastMatchMessage = new AtomicReference<>();
        CountDown countDown = new CountDown(10);
        try {
            with()
                    .conditionEvaluationListener(condition -> {
                        lastMatchMessage.set(condition.getDescription());
                        try {
                            countDown.call();
                        } catch (Exception e) {
                            throw new RuntimeException(e);
                        }
                    }).await().atMost(150, MILLISECONDS).until(new Runnable() {
                @Override
                public void run() {
                    assertEquals(-1, (int) countDown.get());
                }
            });
            fail("Expected to fail");
        } catch (ConditionTimeoutException e) {
            assertThat(lastMatchMessage.get(), allOf(startsWith("Runnable condition defined in"), containsString(testName.getMethodName()), containsString("expected:")));
View Full Code Here

    @SuppressWarnings("Convert2Lambda")
    @Test(timeout = 2000)
    public void expectedMismatchMessageForAssertionConditionsWhenNotUsingLambdasWithAlias() {
        final AtomicReference<String> lastMatchMessage = new AtomicReference<>();
        CountDown countDown = new CountDown(10);
        try {
            with()
                    .conditionEvaluationListener(condition -> {
                        lastMatchMessage.set(condition.getDescription());
                        try {
                            countDown.call();
                        } catch (Exception e) {
                            throw new RuntimeException(e);
                        }
                    }).await("my alias").atMost(150, MILLISECONDS)
                    .until(new Runnable() {
                        @Override
                        public void run() {
                            assertEquals(5, (int) countDown.get());
                        }
                    });
            fail("Expected to fail");
        } catch (ConditionTimeoutException e) {
            assertThat(lastMatchMessage.get(), allOf(startsWith("Runnable condition with alias my alias defined in"), containsString(testName.getMethodName()), containsString("expected:")));
View Full Code Here

    // Callable<Boolean> tests

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

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

    }

    @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

TOP

Related Classes of com.jayway.awaitility.support.CountDown

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.