From a630c4228c73915a5fff2fa8bb21537ba28609aa Mon Sep 17 00:00:00 2001 From: Rashidi Zin Date: Sun, 24 Nov 2024 19:02:27 +0800 Subject: [PATCH] Standardise mongo image version --- data-mongodb-tc-data-load/README.adoc | 10 +++++----- .../tc/dataload/user/UserRepositoryTests.java | 3 +-- data-mongodb-transactional/README.adoc | 2 +- .../data/mongodb/tm/user/CreateUserTests.java | 15 +++++++-------- test-execution-listeners/README.adoc | 2 +- .../boot/test/user/UserRepositoryTests.java | 2 +- 6 files changed, 16 insertions(+), 18 deletions(-) diff --git a/data-mongodb-tc-data-load/README.adoc b/data-mongodb-tc-data-load/README.adoc index 8418352b..7bdf0ffd 100644 --- a/data-mongodb-tc-data-load/README.adoc +++ b/data-mongodb-tc-data-load/README.adoc @@ -30,7 +30,7 @@ class UserRepositoryTests { @Container @ServiceConnection - private static final MongoDBContainer mongo = new MongoDBContainer(DockerImageName.parse("mongo").withTag("6")); + private static final MongoDBContainer mongo = new MongoDBContainer("mongo:latest"); @Autowired private UserRepository repository; @@ -133,7 +133,7 @@ class UserRepositoryTests { @Bean MongoDBContainer mongoDbContainer(DynamicPropertyRegistry registry) { - var mongo = new MongoDBContainer("mongo:6"); + var mongo = new MongoDBContainer("mongo:latest"); registry.add("spring.data.mongodb.uri", mongo::getReplicaSetUrl); @@ -170,7 +170,7 @@ class UserRepositoryTests { @Container @ServiceConnection - private static final MongoDBContainer mongo = new MongoDBContainer(DockerImageName.parse("mongo").withTag("6")) + private static final MongoDBContainer mongo = new MongoDBContainer("mongo:latest") .withCopyToContainer(forClasspathResource("mongo-init.js"), "/docker-entrypoint-initdb.d/mongo-init.js"); } ---- @@ -186,7 +186,7 @@ class UserRepositoryTests { @Container @ServiceConnection - private static final MongoDBContainer mongo = new MongoDBContainer(DockerImageName.parse("mongo").withTag("6")) + private static final MongoDBContainer mongo = new MongoDBContainer("mongo:latest") .withCopyToContainer(forClasspathResource("mongo-init.js"), "/docker-entrypoint-initdb.d/mongo-init.js") .waitingFor(forLogMessage("(?i).*waiting for connections.*", 1)); } @@ -202,7 +202,7 @@ class UserRepositoryTests { @Container @ServiceConnection - private static final MongoDBContainer mongo = new MongoDBContainer(DockerImageName.parse("mongo").withTag("6")) + private static final MongoDBContainer mongo = new MongoDBContainer("mongo:latest") .withCopyToContainer(forClasspathResource("mongo-init.js"), "/docker-entrypoint-initdb.d/mongo-init.js") .waitingFor(forLogMessage("(?i).*waiting for connections.*", 1)) .withStartupAttempts(2) diff --git a/data-mongodb-tc-data-load/src/test/java/zin/rashidi/data/mongodb/tc/dataload/user/UserRepositoryTests.java b/data-mongodb-tc-data-load/src/test/java/zin/rashidi/data/mongodb/tc/dataload/user/UserRepositoryTests.java index 673ff965..846b15ed 100644 --- a/data-mongodb-tc-data-load/src/test/java/zin/rashidi/data/mongodb/tc/dataload/user/UserRepositoryTests.java +++ b/data-mongodb-tc-data-load/src/test/java/zin/rashidi/data/mongodb/tc/dataload/user/UserRepositoryTests.java @@ -8,7 +8,6 @@ import org.testcontainers.containers.MongoDBContainer; import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; -import org.testcontainers.utility.DockerImageName; import static java.time.Duration.ofMinutes; import static org.assertj.core.api.Assertions.assertThat; @@ -24,7 +23,7 @@ class UserRepositoryTests { @Container @ServiceConnection - private static final MongoDBContainer mongo = new MongoDBContainer(DockerImageName.parse("mongo").withTag("6")) + private static final MongoDBContainer mongo = new MongoDBContainer("mongo:latest") .withCopyToContainer(forClasspathResource("mongo-init.js"), "/docker-entrypoint-initdb.d/mongo-init.js") .waitingFor(forLogMessage("(?i).*waiting for connections.*", 1)) .withStartupAttempts(2) diff --git a/data-mongodb-transactional/README.adoc b/data-mongodb-transactional/README.adoc index 09596cd5..2efad737 100644 --- a/data-mongodb-transactional/README.adoc +++ b/data-mongodb-transactional/README.adoc @@ -39,7 +39,7 @@ class CreateUserTests { @Container @ServiceConnection - private static final MongoDBContainer mongo = new MongoDBContainer(DockerImageName.parse("mongo").withTag("6")); + private static final MongoDBContainer mongo = new MongoDBContainer("mongo:latest"); @Autowired private TestRestTemplate restTemplate; diff --git a/data-mongodb-transactional/src/test/java/zin/rashidi/boot/data/mongodb/tm/user/CreateUserTests.java b/data-mongodb-transactional/src/test/java/zin/rashidi/boot/data/mongodb/tm/user/CreateUserTests.java index d57192d0..588f0d3e 100644 --- a/data-mongodb-transactional/src/test/java/zin/rashidi/boot/data/mongodb/tm/user/CreateUserTests.java +++ b/data-mongodb-transactional/src/test/java/zin/rashidi/boot/data/mongodb/tm/user/CreateUserTests.java @@ -1,11 +1,5 @@ package zin.rashidi.boot.data.mongodb.tm.user; -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; -import static org.springframework.http.HttpMethod.POST; -import static org.springframework.http.MediaType.APPLICATION_JSON; -import static zin.rashidi.boot.data.mongodb.tm.user.User.Status.ACTIVE; - import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -16,7 +10,12 @@ import org.testcontainers.containers.MongoDBContainer; import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; -import org.testcontainers.utility.DockerImageName; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; +import static org.springframework.http.HttpMethod.POST; +import static org.springframework.http.MediaType.APPLICATION_JSON; +import static zin.rashidi.boot.data.mongodb.tm.user.User.Status.ACTIVE; /** * @author Rashidi Zin @@ -27,7 +26,7 @@ class CreateUserTests { @Container @ServiceConnection - private static final MongoDBContainer mongo = new MongoDBContainer(DockerImageName.parse("mongo").withTag("6")); + private static final MongoDBContainer mongo = new MongoDBContainer("mongo:latest"); @Autowired private TestRestTemplate restTemplate; diff --git a/test-execution-listeners/README.adoc b/test-execution-listeners/README.adoc index 37964dd7..1f40cc63 100644 --- a/test-execution-listeners/README.adoc +++ b/test-execution-listeners/README.adoc @@ -107,7 +107,7 @@ class UserRepositoryTests { @Container @ServiceConnection - private static final MongoDBContainer mongo = new MongoDBContainer(DockerImageName.parse("mongo").withTag("6")); + private static final MongoDBContainer mongo = new MongoDBContainer("mongo:latest"); @Autowired private UserRepository repository; diff --git a/test-execution-listeners/src/test/java/zin/rashidi/boot/test/user/UserRepositoryTests.java b/test-execution-listeners/src/test/java/zin/rashidi/boot/test/user/UserRepositoryTests.java index 94f599f5..6b40e639 100644 --- a/test-execution-listeners/src/test/java/zin/rashidi/boot/test/user/UserRepositoryTests.java +++ b/test-execution-listeners/src/test/java/zin/rashidi/boot/test/user/UserRepositoryTests.java @@ -28,7 +28,7 @@ class UserRepositoryTests { @Container @ServiceConnection - private static final MongoDBContainer mongo = new MongoDBContainer(DockerImageName.parse("mongo").withTag("6")); + private static final MongoDBContainer mongo = new MongoDBContainer("mongo:latest"); @Autowired private UserRepository repository;