diff --git a/eventuate-common-testcontainers/src/main/java/io/eventuate/common/testcontainers/EventuateZookeeperContainer.java b/eventuate-common-testcontainers/src/main/java/io/eventuate/common/testcontainers/EventuateZookeeperContainer.java index 83d3e4df..f6cb2aa7 100644 --- a/eventuate-common-testcontainers/src/main/java/io/eventuate/common/testcontainers/EventuateZookeeperContainer.java +++ b/eventuate-common-testcontainers/src/main/java/io/eventuate/common/testcontainers/EventuateZookeeperContainer.java @@ -1,8 +1,10 @@ package io.eventuate.common.testcontainers; +import org.jetbrains.annotations.NotNull; import org.testcontainers.containers.wait.strategy.Wait; import org.testcontainers.images.builder.ImageFromDockerfile; +import java.nio.file.FileSystems; import java.nio.file.Path; import java.util.function.BiConsumer; import java.util.function.Supplier; @@ -19,6 +21,11 @@ public EventuateZookeeperContainer(Path path) { withConfiguration(); } + @NotNull + static EventuateZookeeperContainer makeFromDockerfile() { + return new EventuateZookeeperContainer(FileSystems.getDefault().getPath("../zookeeper/Dockerfile")); + } + private void withConfiguration() { withExposedPorts(2181); waitingFor(Wait.forHealthcheck()); diff --git a/eventuate-common-testcontainers/src/test/java/io/eventuate/common/testcontainers/EventuateZookeeperContainerTest.java b/eventuate-common-testcontainers/src/test/java/io/eventuate/common/testcontainers/EventuateZookeeperContainerTest.java index f7bb087b..9ae94451 100644 --- a/eventuate-common-testcontainers/src/test/java/io/eventuate/common/testcontainers/EventuateZookeeperContainerTest.java +++ b/eventuate-common-testcontainers/src/test/java/io/eventuate/common/testcontainers/EventuateZookeeperContainerTest.java @@ -3,12 +3,10 @@ import org.junit.ClassRule; import org.junit.Test; -import java.nio.file.FileSystems; - public class EventuateZookeeperContainerTest { @ClassRule - public static EventuateZookeeperContainer container = new EventuateZookeeperContainer(FileSystems.getDefault().getPath("../zookeeper/Dockerfile")); + public static EventuateZookeeperContainer container = EventuateZookeeperContainer.makeFromDockerfile(); @Test public void shouldStart() {