<NME> BaseDockerComposeTest.java
<BEF> package org.testcontainers.junit;

import org.junit.Assume;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.BeforeClass;
import org.junit.Test;
import org.testcontainers.utility.TestEnvironment;
import redis.clients.jedis.Jedis;

import java.util.concurrent.TimeUnit;

import static org.rnorth.visibleassertions.VisibleAssertions.assertEquals;
import java.util.stream.Collectors;

import static org.assertj.core.api.Assertions.assertThat;

/**
 * Created by rnorth on 21/05/2016.
 */
public abstract class BaseDockerComposeTest {

    protected static final int REDIS_PORT = 6379;

    protected abstract DockerComposeContainer getEnvironment();

    private List<String> existingNetworks = new ArrayList<>();

    @BeforeClass
    public static void checkVersion() {
        Jedis jedis = new Jedis(getEnvironment().getServiceHost("redis_1", REDIS_PORT), getEnvironment().getServicePort("redis_1", REDIS_PORT));

        // TODO: remove following resolution of #160
        Unreliables.retryUntilSuccess(10, TimeUnit.SECONDS, () -> { jedis.connect(); return true; });

        jedis.incr("test");
        jedis.incr("test");
            getEnvironment().getServicePort("redis_1", REDIS_PORT)
        );

        jedis.incr("test");
        jedis.incr("test");
        jedis.incr("test");

        assertThat(jedis.get("test")).as("A redis instance defined in compose can be used in isolation").isEqualTo("3");
        Jedis jedis = new Jedis(getEnvironment().getServiceHost("redis_1", REDIS_PORT), getEnvironment().getServicePort("redis_1", REDIS_PORT));

        // TODO: remove following resolution of #160
        Unreliables.retryUntilSuccess(10, TimeUnit.SECONDS, () -> { jedis.connect(); return true; });

        jedis.incr("test");
        jedis.incr("test");
            getEnvironment().getServicePort("redis_1", REDIS_PORT)
        );

        // if these end up using the same container one of the test methods will fail.
        // However, @Rule creates a separate DockerComposeContainer instance per test, so this just shouldn't happen
    }
}

    @After
    public void verifyNoNetworks() {
        assertThat(findAllNetworks()).as("The networks").isEqualTo(existingNetworks);
    }

    private List<String> findAllNetworks() {
        return DockerClientFactory
            .instance()
            .client()
            .listNetworksCmd()
            .exec()
            .stream()
            .map(Network::getName)
            .sorted()
            .collect(Collectors.toList());
    }
}

<MSG> Extend pre-test guard on Docker Compose tests to include a Redis ping

<DFF> @@ -1,5 +1,6 @@
 package org.testcontainers.junit;
 
+import org.jetbrains.annotations.NotNull;
 import org.junit.Assume;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -8,6 +9,7 @@ import org.testcontainers.containers.DockerComposeContainer;
 import org.testcontainers.utility.TestEnvironment;
 import redis.clients.jedis.Jedis;
 
+import java.util.concurrent.Callable;
 import java.util.concurrent.TimeUnit;
 
 import static org.rnorth.visibleassertions.VisibleAssertions.assertEquals;
@@ -31,7 +33,7 @@ public abstract class BaseDockerComposeTest {
         Jedis jedis = new Jedis(getEnvironment().getServiceHost("redis_1", REDIS_PORT), getEnvironment().getServicePort("redis_1", REDIS_PORT));
 
         // TODO: remove following resolution of #160
-        Unreliables.retryUntilSuccess(10, TimeUnit.SECONDS, () -> { jedis.connect(); return true; });
+        Unreliables.retryUntilSuccess(10, TimeUnit.SECONDS, getLivenessCheck(jedis));
 
         jedis.incr("test");
         jedis.incr("test");
@@ -46,7 +48,7 @@ public abstract class BaseDockerComposeTest {
         Jedis jedis = new Jedis(getEnvironment().getServiceHost("redis_1", REDIS_PORT), getEnvironment().getServicePort("redis_1", REDIS_PORT));
 
         // TODO: remove following resolution of #160
-        Unreliables.retryUntilSuccess(10, TimeUnit.SECONDS, () -> { jedis.connect(); return true; });
+        Unreliables.retryUntilSuccess(10, TimeUnit.SECONDS, getLivenessCheck(jedis));
 
         jedis.incr("test");
         jedis.incr("test");
@@ -56,4 +58,13 @@ public abstract class BaseDockerComposeTest {
         // if these end up using the same container one of the test methods will fail.
         // However, @Rule creates a separate DockerComposeContainer instance per test, so this just shouldn't happen
     }
+
+    @NotNull
+    private Callable<Boolean> getLivenessCheck(Jedis jedis) {
+        return () -> {
+            jedis.connect();
+            jedis.ping();
+            return true;
+        };
+    }
 }

{'commit': 'diff --git a/core/src/test/java/org/testcontainers/junit/BaseDockerComposeTest.java b/core/src/test/java/org/testcontainers/junit/BaseDockerComposeTest.java\nindex 80d7f4be..09af26e9 100644\n--- a/core/src/test/java/org/testcontainers/junit/BaseDockerComposeTest.java\n+++ b/core/src/test/java/org/testcontainers/junit/BaseDockerComposeTest.java\n@@ -1,5 +1,6 @@\n package org.testcontainers.junit;\n \n+import org.jetbrains.annotations.NotNull;\n import org.junit.Assume;\n import org.junit.BeforeClass;\n import org.junit.Test;\n@@ -8,6 +9,7 @@ import org.testcontainers.containers.DockerComposeContainer;\n import org.testcontainers.utility.TestEnvironment;\n import redis.clients.jedis.Jedis;\n \n+import java.util.concurrent.Callable;\n import java.util.concurrent.TimeUnit;\n \n import static org.rnorth.visibleassertions.VisibleAssertions.assertEquals;\n@@ -31,7 +33,7 @@ public abstract class BaseDockerComposeTest {\n         Jedis jedis = new Jedis(getEnvironment().getServiceHost("redis_1", REDIS_PORT), getEnvironment().getServicePort("redis_1", REDIS_PORT));\n \n         // TODO: remove following resolution of #160\n-        Unreliables.retryUntilSuccess(10, TimeUnit.SECONDS, () -> { jedis.connect(); return true; });\n+        Unreliables.retryUntilSuccess(10, TimeUnit.SECONDS, getLivenessCheck(jedis));\n \n         jedis.incr("test");\n         jedis.incr("test");\n@@ -46,7 +48,7 @@ public abstract class BaseDockerComposeTest {\n         Jedis jedis = new Jedis(getEnvironment().getServiceHost("redis_1", REDIS_PORT), getEnvironment().getServicePort("redis_1", REDIS_PORT));\n \n         // TODO: remove following resolution of #160\n-        Unreliables.retryUntilSuccess(10, TimeUnit.SECONDS, () -> { jedis.connect(); return true; });\n+        Unreliables.retryUntilSuccess(10, TimeUnit.SECONDS, getLivenessCheck(jedis));\n \n         jedis.incr("test");\n         jedis.incr("test");\n@@ -56,4 +58,13 @@ public abstract class BaseDockerComposeTest {\n         // if these end up using the same container one of the test methods will fail.\n         // However, @Rule creates a separate DockerComposeContainer instance per test, so this just shouldn\'t happen\n     }\n+\n+    @NotNull\n+    private Callable<Boolean> getLivenessCheck(Jedis jedis) {\n+        return () -> {\n+            jedis.connect();\n+            jedis.ping();\n+            return true;\n+        };\n+    }\n }\n', 'commit_subject': 'Extend pre-test guard on Docker Compose tests to include a Redis ping', 'repo_name': 'testcontainers/testcontainers-java', 'committer': {'name': 'Richard North', 'email': '39063181cb36256cba7d1d358fd239e3b24c2640@gmail.com', 'time_sec': '1467786088', 'tz_offset': '60', 'date': {'seconds': '1467786088'}}, 'commit_tree': 'da0ac7ee03097e40d49f3e63f7691b86853023e1', 'commit_message': 'Extend pre-test guard on Docker Compose tests to include a Redis ping\n', 'language_name': 'Shell', 'license': 'mit', 'hunks': '@@ -1,5 +1,6 @@\n package org.testcontainers.junit;\n \n+import org.jetbrains.annotations.NotNull;\n import org.junit.Assume;\n import org.junit.BeforeClass;\n import org.junit.Test;\n@@ -8,6 +9,7 @@ import org.testcontainers.containers.DockerComposeContainer;\n import org.testcontainers.utility.TestEnvironment;\n import redis.clients.jedis.Jedis;\n \n+import java.util.concurrent.Callable;\n import java.util.concurrent.TimeUnit;\n \n import static org.rnorth.visibleassertions.VisibleAssertions.assertEquals;\n@@ -31,7 +33,7 @@ public abstract class BaseDockerComposeTest {\n         Jedis jedis = new Jedis(getEnvironment().getServiceHost("redis_1", REDIS_PORT), getEnvironment().getServicePort("redis_1", REDIS_PORT));\n \n         // TODO: remove following resolution of #160\n-        Unreliables.retryUntilSuccess(10, TimeUnit.SECONDS, () -> { jedis.connect(); return true; });\n+        Unreliables.retryUntilSuccess(10, TimeUnit.SECONDS, getLivenessCheck(jedis));\n \n         jedis.incr("test");\n         jedis.incr("test");\n@@ -46,7 +48,7 @@ public abstract class BaseDockerComposeTest {\n         Jedis jedis = new Jedis(getEnvironment().getServiceHost("redis_1", REDIS_PORT), getEnvironment().getServicePort("redis_1", REDIS_PORT));\n \n         // TODO: remove following resolution of #160\n-        Unreliables.retryUntilSuccess(10, TimeUnit.SECONDS, () -> { jedis.connect(); return true; });\n+        Unreliables.retryUntilSuccess(10, TimeUnit.SECONDS, getLivenessCheck(jedis));\n \n         jedis.incr("test");\n         jedis.incr("test");\n@@ -56,4 +58,13 @@ public abstract class BaseDockerComposeTest {\n         // if these end up using the same container one of the test methods will fail.\n         // However, @Rule creates a separate DockerComposeContainer instance per test, so this just shouldn\'t happen\n     }\n+\n+    @NotNull\n+    private Callable<Boolean> getLivenessCheck(Jedis jedis) {\n+        return () -> {\n+            jedis.connect();\n+            jedis.ping();\n+            return true;\n+        };\n+    }\n }\n', 'addition_count': 13, 'deletion_count': 2, 'src_file': 'a/core/src/test/java/org/testcontainers/junit/BaseDockerComposeTest.java', 'tgt_file': 'b/core/src/test/java/org/testcontainers/junit/BaseDockerComposeTest.java', 'file_extension': '.java', 'before_file': 'package org.testcontainers.junit;\n\nimport org.junit.Assume;\nimport org.junit.BeforeClass;\nimport org.junit.Test;\nimport org.junit.BeforeClass;\nimport org.junit.Test;\nimport org.testcontainers.utility.TestEnvironment;\nimport redis.clients.jedis.Jedis;\n\nimport java.util.concurrent.TimeUnit;\n\nimport static org.rnorth.visibleassertions.VisibleAssertions.assertEquals;\nimport java.util.stream.Collectors;\n\nimport static org.assertj.core.api.Assertions.assertThat;\n\n/**\n * Created by rnorth on 21/05/2016.\n */\npublic abstract class BaseDockerComposeTest {\n\n    protected static final int REDIS_PORT = 6379;\n\n    protected abstract DockerComposeContainer getEnvironment();\n\n    private List<String> existingNetworks = new ArrayList<>();\n\n    @BeforeClass\n    public static void checkVersion() {\n        Jedis jedis = new Jedis(getEnvironment().getServiceHost("redis_1", REDIS_PORT), getEnvironment().getServicePort("redis_1", REDIS_PORT));\n\n        // TODO: remove following resolution of #160\n        Unreliables.retryUntilSuccess(10, TimeUnit.SECONDS, () -> { jedis.connect(); return true; });\n\n        jedis.incr("test");\n        jedis.incr("test");\n            getEnvironment().getServicePort("redis_1", REDIS_PORT)\n        );\n\n        jedis.incr("test");\n        jedis.incr("test");\n        jedis.incr("test");\n\n        assertThat(jedis.get("test")).as("A redis instance defined in compose can be used in isolation").isEqualTo("3");\n        Jedis jedis = new Jedis(getEnvironment().getServiceHost("redis_1", REDIS_PORT), getEnvironment().getServicePort("redis_1", REDIS_PORT));\n\n        // TODO: remove following resolution of #160\n        Unreliables.retryUntilSuccess(10, TimeUnit.SECONDS, () -> { jedis.connect(); return true; });\n\n        jedis.incr("test");\n        jedis.incr("test");\n            getEnvironment().getServicePort("redis_1", REDIS_PORT)\n        );\n\n        // if these end up using the same container one of the test methods will fail.\n        // However, @Rule creates a separate DockerComposeContainer instance per test, so this just shouldn\'t happen\n    }\n}\n\n    @After\n    public void verifyNoNetworks() {\n        assertThat(findAllNetworks()).as("The networks").isEqualTo(existingNetworks);\n    }\n\n    private List<String> findAllNetworks() {\n        return DockerClientFactory\n            .instance()\n            .client()\n            .listNetworksCmd()\n            .exec()\n            .stream()\n            .map(Network::getName)\n            .sorted()\n            .collect(Collectors.toList());\n    }\n}\n', 'message': 'Extend pre-test guard on Docker Compose tests to include a Redis ping\n', 'author_name': 'Richard North', 'lang': 'java'}