From e1cacf2eec5851705a0fa9f6c7fceadeb8218149 Mon Sep 17 00:00:00 2001 From: Chris Richardson Date: Fri, 16 Dec 2022 09:58:25 -0800 Subject: [PATCH] #128 Implemented factory method for EventuateZookeeperContainer --- .../common/testcontainers/EventuateZookeeperContainer.java | 7 +++++++ .../testcontainers/EventuateZookeeperContainerTest.java | 4 +--- 2 files changed, 8 insertions(+), 3 deletions(-) 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() {