From 281bf57e54a4b8ddd204dd6c81078dd7d44f4c46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janusz=20Wi=C5=9Bniowski?= Date: Fri, 21 Sep 2018 12:34:40 +0200 Subject: [PATCH 1/2] Upgraded Awaitility to 3.1.2. Fixes #250 --- docker-compose-rule-core/core.gradle | 2 +- .../docker/compose/connection/waiting/ClusterWait.java | 4 ++-- .../docker/compose/execution/DefaultDockerCompose.java | 2 +- .../docker/compose/connection/ContainerIntegrationTests.java | 4 ++-- docker-compose-rule-junit4/junit4.gradle | 2 +- .../DockerComposeRuleNativeHealthcheckIntegrationTest.java | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docker-compose-rule-core/core.gradle b/docker-compose-rule-core/core.gradle index a9248ad37..bcedd2f0d 100644 --- a/docker-compose-rule-core/core.gradle +++ b/docker-compose-rule-core/core.gradle @@ -1,5 +1,5 @@ dependencies { - compile 'com.jayway.awaitility:awaitility:1.6.5' + compile 'org.awaitility:awaitility:3.1.2' compile "com.github.zafarkhaja:java-semver:$javaSemverVersion" compile "com.google.guava:guava:$guavaVersion" compile "commons-io:commons-io:2.4" diff --git a/docker-compose-rule-core/src/main/java/com/palantir/docker/compose/connection/waiting/ClusterWait.java b/docker-compose-rule-core/src/main/java/com/palantir/docker/compose/connection/waiting/ClusterWait.java index 25af11894..01f6f20a7 100644 --- a/docker-compose-rule-core/src/main/java/com/palantir/docker/compose/connection/waiting/ClusterWait.java +++ b/docker-compose-rule-core/src/main/java/com/palantir/docker/compose/connection/waiting/ClusterWait.java @@ -15,13 +15,13 @@ */ package com.palantir.docker.compose.connection.waiting; -import com.jayway.awaitility.Awaitility; -import com.jayway.awaitility.core.ConditionTimeoutException; import com.palantir.docker.compose.connection.Cluster; import java.util.Optional; import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; +import org.awaitility.Awaitility; +import org.awaitility.core.ConditionTimeoutException; import org.joda.time.ReadableDuration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/docker-compose-rule-core/src/main/java/com/palantir/docker/compose/execution/DefaultDockerCompose.java b/docker-compose-rule-core/src/main/java/com/palantir/docker/compose/execution/DefaultDockerCompose.java index 5fa062d50..b0c67f275 100644 --- a/docker-compose-rule-core/src/main/java/com/palantir/docker/compose/execution/DefaultDockerCompose.java +++ b/docker-compose-rule-core/src/main/java/com/palantir/docker/compose/execution/DefaultDockerCompose.java @@ -22,7 +22,6 @@ import com.github.zafarkhaja.semver.Version; import com.google.common.base.Strings; import com.google.common.collect.ImmutableList; -import com.jayway.awaitility.Awaitility; import com.palantir.docker.compose.configuration.DockerComposeFiles; import com.palantir.docker.compose.configuration.ProjectName; import com.palantir.docker.compose.connection.Container; @@ -37,6 +36,7 @@ import java.util.Optional; import java.util.concurrent.TimeUnit; import org.apache.commons.io.IOUtils; +import org.awaitility.Awaitility; import org.joda.time.Duration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/docker-compose-rule-core/src/test/java/com/palantir/docker/compose/connection/ContainerIntegrationTests.java b/docker-compose-rule-core/src/test/java/com/palantir/docker/compose/connection/ContainerIntegrationTests.java index e2ecfa8aa..d7d5fe75e 100644 --- a/docker-compose-rule-core/src/test/java/com/palantir/docker/compose/connection/ContainerIntegrationTests.java +++ b/docker-compose-rule-core/src/test/java/com/palantir/docker/compose/connection/ContainerIntegrationTests.java @@ -4,15 +4,14 @@ package com.palantir.docker.compose.connection; -import static com.jayway.awaitility.Awaitility.await; import static com.palantir.docker.compose.execution.DockerComposeExecArgument.arguments; import static com.palantir.docker.compose.execution.DockerComposeExecOption.noOptions; +import static org.awaitility.Awaitility.await; import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertEquals; import static org.junit.Assume.assumeThat; import com.github.zafarkhaja.semver.Version; -import com.jayway.awaitility.core.ConditionFactory; import com.palantir.docker.compose.configuration.DockerComposeFiles; import com.palantir.docker.compose.configuration.ProjectName; import com.palantir.docker.compose.execution.DefaultDockerCompose; @@ -21,6 +20,7 @@ import com.palantir.docker.compose.execution.DockerExecutable; import java.io.IOException; import java.util.concurrent.TimeUnit; +import org.awaitility.core.ConditionFactory; import org.junit.Test; import org.mockito.internal.matchers.GreaterOrEqual; diff --git a/docker-compose-rule-junit4/junit4.gradle b/docker-compose-rule-junit4/junit4.gradle index d82cc62d5..14b562ab6 100644 --- a/docker-compose-rule-junit4/junit4.gradle +++ b/docker-compose-rule-junit4/junit4.gradle @@ -6,7 +6,7 @@ dependencies { compile project(':docker-compose-rule-core') testCompile 'com.github.zafarkhaja:java-semver:0.9.0' - testCompile 'com.jayway.awaitility:awaitility:1.6.5' + testCompile 'org.awaitility:awaitility:3.1.2' testCompile 'commons-io:commons-io:2.4' testCompile "com.google.guava:guava:$guavaVersion" testCompile "joda-time:joda-time:$jodaVersion" diff --git a/docker-compose-rule-junit4/src/test/java/com/palantir/docker/compose/DockerComposeRuleNativeHealthcheckIntegrationTest.java b/docker-compose-rule-junit4/src/test/java/com/palantir/docker/compose/DockerComposeRuleNativeHealthcheckIntegrationTest.java index 6ad62740f..29fb133ff 100644 --- a/docker-compose-rule-junit4/src/test/java/com/palantir/docker/compose/DockerComposeRuleNativeHealthcheckIntegrationTest.java +++ b/docker-compose-rule-junit4/src/test/java/com/palantir/docker/compose/DockerComposeRuleNativeHealthcheckIntegrationTest.java @@ -5,9 +5,9 @@ package com.palantir.docker.compose; import static com.google.common.util.concurrent.Uninterruptibles.getUninterruptibly; -import static com.jayway.awaitility.Awaitility.await; import static com.palantir.docker.compose.execution.DockerComposeExecArgument.arguments; import static com.palantir.docker.compose.execution.DockerComposeExecOption.noOptions; +import static org.awaitility.Awaitility.await; import static org.junit.Assert.fail; import static org.junit.Assume.assumeThat; From fea591b2e65d77a72eb0c67a9948e09070834356 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janusz=20Wi=C5=9Bniowski?= Date: Fri, 21 Sep 2018 17:51:34 +0200 Subject: [PATCH 2/2] Added tests for #250 --- .../connection/waiting/ClusterWaitShould.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/docker-compose-rule-core/src/test/java/com/palantir/docker/compose/connection/waiting/ClusterWaitShould.java b/docker-compose-rule-core/src/test/java/com/palantir/docker/compose/connection/waiting/ClusterWaitShould.java index 05c275cf8..1c8240be6 100644 --- a/docker-compose-rule-core/src/test/java/com/palantir/docker/compose/connection/waiting/ClusterWaitShould.java +++ b/docker-compose-rule-core/src/test/java/com/palantir/docker/compose/connection/waiting/ClusterWaitShould.java @@ -72,4 +72,32 @@ public class ClusterWaitShould { wait.waitUntilReady(cluster); } + + @SuppressWarnings("unchecked") + @Test public void + should_propagate_throwable() throws InterruptedException { + class AThrowable extends Throwable {} + + when(clusterHealthCheck.isClusterHealthy(cluster)) + .thenThrow(AThrowable.class); + + exception.expect(AThrowable.class); + + ClusterWait wait = new ClusterWait(clusterHealthCheck, DURATION); + wait.waitUntilReady(cluster); + } + + @SuppressWarnings("unchecked") + @Test public void + should_propagate_error() throws InterruptedException { + class AnError extends Error {} + + when(clusterHealthCheck.isClusterHealthy(cluster)) + .thenThrow(AnError.class); + + exception.expect(AnError.class); + + ClusterWait wait = new ClusterWait(clusterHealthCheck, DURATION); + wait.waitUntilReady(cluster); + } }