Search in sources :

Example 6 with ConditionFactory

use of org.awaitility.core.ConditionFactory in project testcontainers-java by testcontainers.

the class ResourceReaperTest method assertCleanup.

private void assertCleanup(Map<String, String> labels) {
    DockerClient client = DockerClientFactory.instance().client();
    ConditionFactory awaitFactory = Awaitility.await().atMost(Duration.ofMinutes(1)).pollInterval(Duration.ofSeconds(1));
    List<String> labelValues = labels.entrySet().stream().map(it -> it.getKey() + "=" + it.getValue()).collect(Collectors.toList());
    awaitFactory.untilAsserted(() -> {
        assertThat(client.listContainersCmd().withFilter("label", labelValues).withShowAll(true).exec()).isEmpty();
    });
    awaitFactory.untilAsserted(() -> {
        assertThat(client.listNetworksCmd().withFilter("label", labelValues).exec()).isEmpty();
    });
    awaitFactory.untilAsserted(() -> {
        assertThat(client.listVolumesCmd().withFilter("label", labelValues).exec().getVolumes()).isEmpty();
    });
}
Also used : ConditionFactory(org.awaitility.core.ConditionFactory) SneakyThrows(lombok.SneakyThrows) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test) ProcessExecutor(org.zeroturnaround.exec.ProcessExecutor) Collectors(java.util.stream.Collectors) File(java.io.File) DockerClient(com.github.dockerjava.api.DockerClient) ProcessResult(org.zeroturnaround.exec.ProcessResult) Consumer(java.util.function.Consumer) List(java.util.List) Stream(java.util.stream.Stream) Duration(java.time.Duration) Map(java.util.Map) DockerClientFactory(org.testcontainers.DockerClientFactory) GenericContainer(org.testcontainers.containers.GenericContainer) Awaitility(org.awaitility.Awaitility) Assert.assertEquals(org.junit.Assert.assertEquals) DockerClient(com.github.dockerjava.api.DockerClient) ConditionFactory(org.awaitility.core.ConditionFactory)

Example 7 with ConditionFactory

use of org.awaitility.core.ConditionFactory in project besu by hyperledger.

the class EthProtocolManagerTest method doNotDisconnectOnValidMessage.

@Test
public void doNotDisconnectOnValidMessage() {
    try (final EthProtocolManager ethManager = EthProtocolManagerTestUtil.create(blockchain, () -> false, protocolContext.getWorldStateArchive(), transactionPool, EthProtocolConfiguration.defaultConfig())) {
        final MessageData messageData = GetBlockBodiesMessage.create(Collections.singletonList(gen.hash()));
        final MockPeerConnection peer = setupPeer(ethManager, (cap, msg, conn) -> {
        });
        ethManager.processMessage(EthProtocol.ETH63, new DefaultMessage(peer, messageData));
        final ConditionFactory waitDisconnect = Awaitility.await().catchUncaughtExceptions().atMost(200, TimeUnit.MILLISECONDS);
        assertThatThrownBy(() -> waitDisconnect.until(peer::isDisconnected)).isInstanceOf(ConditionTimeoutException.class);
    }
}
Also used : DefaultMessage(org.hyperledger.besu.ethereum.p2p.rlpx.wire.DefaultMessage) MessageData(org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData) ConditionFactory(org.awaitility.core.ConditionFactory) Test(org.junit.Test)

Example 8 with ConditionFactory

use of org.awaitility.core.ConditionFactory in project java-operator-sdk by java-operator-sdk.

the class TimerEventSourceTest method untilAsserted.

private void untilAsserted(long initialDelay, long interval, ThrowingRunnable assertion) {
    long delay = INITIAL_DELAY;
    long period = PERIOD;
    ConditionFactory cf = Awaitility.await();
    if (initialDelay > 0) {
        delay = initialDelay;
        cf = cf.pollDelay(initialDelay, TimeUnit.MILLISECONDS);
    }
    if (interval > 0) {
        period = interval;
        cf = cf.pollInterval(interval, TimeUnit.MILLISECONDS);
    }
    cf = cf.atMost(delay + (period * 3), TimeUnit.MILLISECONDS);
    cf.untilAsserted(assertion);
}
Also used : ConditionFactory(org.awaitility.core.ConditionFactory)

Example 9 with ConditionFactory

use of org.awaitility.core.ConditionFactory in project selenium-webdriver-java by bonigarcia.

the class DownloadChromeJUnit4Test method testDownloadChrome.

@Test
public void testDownloadChrome() {
    driver.get("https://bonigarcia.dev/selenium-webdriver-java/download.html");
    driver.findElement(By.xpath("(//a)[2]")).click();
    driver.findElement(By.xpath("(//a)[3]")).click();
    ConditionFactory await = Awaitility.await().atMost(Duration.ofSeconds(5));
    File wdmLogo = new File(targetFolder, "webdrivermanager.png");
    await.until(() -> wdmLogo.exists());
    File wdmDoc = new File(targetFolder, "webdrivermanager.pdf");
    await.until(() -> wdmDoc.exists());
}
Also used : ConditionFactory(org.awaitility.core.ConditionFactory) File(java.io.File) Test(org.junit.Test)

Example 10 with ConditionFactory

use of org.awaitility.core.ConditionFactory in project selenium-webdriver-java by bonigarcia.

the class DownloadFirefoxJUnit4Test method testDownloadFirefox.

@Test
public void testDownloadFirefox() {
    driver.get("https://bonigarcia.dev/selenium-webdriver-java/download.html");
    driver.findElement(By.xpath("(//a)[2]")).click();
    driver.findElement(By.xpath("(//a)[3]")).click();
    ConditionFactory await = Awaitility.await().atMost(Duration.ofSeconds(5));
    File wdmLogo = new File(targetFolder, "webdrivermanager.png");
    await.until(() -> wdmLogo.exists());
    File wdmDoc = new File(targetFolder, "webdrivermanager.pdf");
    await.until(() -> wdmDoc.exists());
}
Also used : ConditionFactory(org.awaitility.core.ConditionFactory) File(java.io.File) Test(org.junit.Test)

Aggregations

ConditionFactory (org.awaitility.core.ConditionFactory)11 File (java.io.File)9 Test (org.junit.Test)4 Test (org.junit.jupiter.api.Test)4 Test (org.testng.annotations.Test)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 DockerClient (com.github.dockerjava.api.DockerClient)1 Duration (java.time.Duration)1 List (java.util.List)1 Map (java.util.Map)1 Consumer (java.util.function.Consumer)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 SneakyThrows (lombok.SneakyThrows)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Awaitility (org.awaitility.Awaitility)1 DefaultMessage (org.hyperledger.besu.ethereum.p2p.rlpx.wire.DefaultMessage)1 MessageData (org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 DockerClientFactory (org.testcontainers.DockerClientFactory)1