From ca0c269ff83d2344e11ed6e205655fd00904b057 Mon Sep 17 00:00:00 2001 From: emanueltrandafir1993 Date: Sat, 5 Aug 2023 20:48:38 +0200 Subject: [PATCH 1/4] BAEL-6649: testcontainers in sb 3.1 --- .../spring-boot-3-testcontainers/README.md | 1 + .../spring-boot-3-testcontainers/pom.xml | 107 ++++++++++++++++++ .../baeldung/testcontainers/Application.java | 14 +++ .../middleearth/MiddleEarthCharacter.java | 13 +++ .../MiddleEarthCharactersController.java | 30 +++++ .../MiddleEarthCharactersRepository.java | 11 ++ .../DynamicPropertiesIntegrationTest.java | 60 ++++++++++ .../testcontainers/LocalDevApplication.java | 29 +++++ .../ServiceConnectionIntegrationTest.java | 55 +++++++++ 9 files changed, 320 insertions(+) create mode 100644 spring-boot-modules/spring-boot-3-testcontainers/README.md create mode 100644 spring-boot-modules/spring-boot-3-testcontainers/pom.xml create mode 100644 spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/Application.java create mode 100644 spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/middleearth/MiddleEarthCharacter.java create mode 100644 spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/middleearth/MiddleEarthCharactersController.java create mode 100644 spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/middleearth/MiddleEarthCharactersRepository.java create mode 100644 spring-boot-modules/spring-boot-3-testcontainers/src/test/java/com/baeldung/testcontainers/DynamicPropertiesIntegrationTest.java create mode 100644 spring-boot-modules/spring-boot-3-testcontainers/src/test/java/com/baeldung/testcontainers/LocalDevApplication.java create mode 100644 spring-boot-modules/spring-boot-3-testcontainers/src/test/java/com/baeldung/testcontainers/ServiceConnectionIntegrationTest.java diff --git a/spring-boot-modules/spring-boot-3-testcontainers/README.md b/spring-boot-modules/spring-boot-3-testcontainers/README.md new file mode 100644 index 0000000000..5616cce48b --- /dev/null +++ b/spring-boot-modules/spring-boot-3-testcontainers/README.md @@ -0,0 +1 @@ +## Relevant Articles diff --git a/spring-boot-modules/spring-boot-3-testcontainers/pom.xml b/spring-boot-modules/spring-boot-3-testcontainers/pom.xml new file mode 100644 index 0000000000..24b88bc7bc --- /dev/null +++ b/spring-boot-modules/spring-boot-3-testcontainers/pom.xml @@ -0,0 +1,107 @@ + + + 4.0.0 + spring-boot-3-testcontainers + 0.0.1-SNAPSHOT + spring-boot-3-testcontainers + Testcontainer Improvements in Spring Boot 3 + + + com.baeldung + parent-boot-3 + 0.0.1-SNAPSHOT + ../../parent-boot-3 + + + + + + org.springframework.boot + spring-boot-starter + ${spring-boot.version} + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-devtools + ${spring-boot.version} + runtime + true + + + org.springframework.boot + spring-boot-starter-test + ${spring-boot.version} + + + org.springframework.boot + spring-boot-starter-data-mongodb + ${spring-boot.version} + + + + org.springframework.boot + spring-boot-testcontainers + ${spring-boot.version} + + + + org.testcontainers + mongodb + ${testcontainers.version} + test + + + org.testcontainers + testcontainers + ${testcontainers.version} + test + + + org.testcontainers + junit-jupiter + ${testcontainers.version} + test + + + + io.rest-assured + rest-assured + 5.3.1 + test + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + 3.0.0-M7 + 1.18.3 + 3.1.0 + + + \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/Application.java b/spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/Application.java new file mode 100644 index 0000000000..9a00bfebf2 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/Application.java @@ -0,0 +1,14 @@ +package com.baeldung.testcontainers; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.data.mongodb.repository.config.EnableMongoRepositories; + +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } + +} diff --git a/spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/middleearth/MiddleEarthCharacter.java b/spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/middleearth/MiddleEarthCharacter.java new file mode 100644 index 0000000000..38f125d3cf --- /dev/null +++ b/spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/middleearth/MiddleEarthCharacter.java @@ -0,0 +1,13 @@ +package com.baeldung.testcontainers.middleearth; + +import java.util.UUID; + +import org.springframework.data.annotation.Id; +import org.springframework.data.mongodb.core.mapping.Document; + +@Document("characters") +public record MiddleEarthCharacter(@Id String id, String name, String race) { + public MiddleEarthCharacter(String name, String race) { + this(UUID.randomUUID().toString(), name, race); + } +} diff --git a/spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/middleearth/MiddleEarthCharactersController.java b/spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/middleearth/MiddleEarthCharactersController.java new file mode 100644 index 0000000000..ef99732cc8 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/middleearth/MiddleEarthCharactersController.java @@ -0,0 +1,30 @@ +package com.baeldung.testcontainers.middleearth; + +import java.util.List; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("characters") +public class MiddleEarthCharactersController { + private final MiddleEarthCharactersRepository repository; + + public MiddleEarthCharactersController(MiddleEarthCharactersRepository repository) { + this.repository = repository; + } + + @GetMapping + public List findByRace(@RequestParam String race) { + return repository.findAllByRace(race); + } + + @PostMapping + public MiddleEarthCharacter save(@RequestBody MiddleEarthCharacter character) { + return repository.save(character); + } +} diff --git a/spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/middleearth/MiddleEarthCharactersRepository.java b/spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/middleearth/MiddleEarthCharactersRepository.java new file mode 100644 index 0000000000..6101d7d1e1 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/middleearth/MiddleEarthCharactersRepository.java @@ -0,0 +1,11 @@ +package com.baeldung.testcontainers.middleearth; + +import java.util.List; + +import org.springframework.data.mongodb.repository.MongoRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface MiddleEarthCharactersRepository extends MongoRepository { + List findAllByRace(String race); +} diff --git a/spring-boot-modules/spring-boot-3-testcontainers/src/test/java/com/baeldung/testcontainers/DynamicPropertiesIntegrationTest.java b/spring-boot-modules/spring-boot-3-testcontainers/src/test/java/com/baeldung/testcontainers/DynamicPropertiesIntegrationTest.java new file mode 100644 index 0000000000..f66603b420 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-testcontainers/src/test/java/com/baeldung/testcontainers/DynamicPropertiesIntegrationTest.java @@ -0,0 +1,60 @@ +package com.baeldung.testcontainers; + +import static io.restassured.RestAssured.when; +import static org.hamcrest.Matchers.hasItems; +import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.DEFINED_PORT; +import static org.springframework.test.annotation.DirtiesContext.ClassMode.AFTER_CLASS; + +import java.util.List; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.testcontainers.service.connection.ServiceConnection; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.DynamicPropertyRegistry; +import org.springframework.test.context.DynamicPropertySource; +import org.testcontainers.containers.MongoDBContainer; +import org.testcontainers.junit.jupiter.Container; +import org.testcontainers.junit.jupiter.Testcontainers; +import org.testcontainers.utility.DockerImageName; + +import com.baeldung.testcontainers.middleearth.MiddleEarthCharacter; +import com.baeldung.testcontainers.middleearth.MiddleEarthCharactersRepository; + +@Testcontainers +@SpringBootTest(webEnvironment = DEFINED_PORT) +@DirtiesContext(classMode = AFTER_CLASS) +class DynamicPropertiesIntegrationTest { + @Container + static MongoDBContainer mongoDBContainer = new MongoDBContainer(DockerImageName.parse("mongo:4.0.10")); + + @DynamicPropertySource + static void setProperties(DynamicPropertyRegistry registry) { + registry.add("spring.data.mongodb.uri", mongoDBContainer::getReplicaSetUrl); + } + + @Autowired + private MiddleEarthCharactersRepository repository; + + @BeforeEach + void beforeEach() { + repository.deleteAll(); + } + + @Test + void whenRequestingHobbits_thenReturnFrodoAndSam() { + repository.saveAll(List.of( + new MiddleEarthCharacter("Frodo", "hobbit"), + new MiddleEarthCharacter("Samwise", "hobbit"), + new MiddleEarthCharacter("Aragon", "human"), + new MiddleEarthCharacter("Gandalf", "wizzard") + )); + + when().get("/characters?race=hobbit") + .then().statusCode(200) + .and().body("name", hasItems("Frodo", "Samwise")); + } + +} diff --git a/spring-boot-modules/spring-boot-3-testcontainers/src/test/java/com/baeldung/testcontainers/LocalDevApplication.java b/spring-boot-modules/spring-boot-3-testcontainers/src/test/java/com/baeldung/testcontainers/LocalDevApplication.java new file mode 100644 index 0000000000..91eef3bf1d --- /dev/null +++ b/spring-boot-modules/spring-boot-3-testcontainers/src/test/java/com/baeldung/testcontainers/LocalDevApplication.java @@ -0,0 +1,29 @@ +package com.baeldung.testcontainers; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.devtools.restart.RestartScope; +import org.springframework.boot.test.context.TestConfiguration; +import org.springframework.boot.testcontainers.service.connection.ServiceConnection; +import org.springframework.context.annotation.Bean; +import org.testcontainers.containers.MongoDBContainer; +import org.testcontainers.utility.DockerImageName; + +public class LocalDevApplication { + + public static void main(String[] args) { + SpringApplication.from(Application::main) + .with(LocalDevTestcontainersConfig.class) + .run(args); + } + + @TestConfiguration(proxyBeanMethods = false) + static class LocalDevTestcontainersConfig { + @Bean + @RestartScope + @ServiceConnection + public MongoDBContainer mongoDBContainer() { + return new MongoDBContainer(DockerImageName.parse("mongo:4.0.10")); + } + } + +} diff --git a/spring-boot-modules/spring-boot-3-testcontainers/src/test/java/com/baeldung/testcontainers/ServiceConnectionIntegrationTest.java b/spring-boot-modules/spring-boot-3-testcontainers/src/test/java/com/baeldung/testcontainers/ServiceConnectionIntegrationTest.java new file mode 100644 index 0000000000..29e5b51704 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-testcontainers/src/test/java/com/baeldung/testcontainers/ServiceConnectionIntegrationTest.java @@ -0,0 +1,55 @@ +package com.baeldung.testcontainers; + +import static io.restassured.RestAssured.when; +import static org.hamcrest.Matchers.hasItems; +import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.DEFINED_PORT; +import static org.springframework.test.annotation.DirtiesContext.ClassMode.AFTER_CLASS; + +import java.util.List; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.testcontainers.service.connection.ServiceConnection; +import org.springframework.test.annotation.DirtiesContext; +import org.testcontainers.containers.MongoDBContainer; +import org.testcontainers.junit.jupiter.Container; +import org.testcontainers.junit.jupiter.Testcontainers; +import org.testcontainers.utility.DockerImageName; + +import com.baeldung.testcontainers.middleearth.MiddleEarthCharacter; +import com.baeldung.testcontainers.middleearth.MiddleEarthCharactersRepository; + +@Testcontainers +@SpringBootTest(webEnvironment = DEFINED_PORT) +@DirtiesContext(classMode = AFTER_CLASS) +class ServiceConnectionIntegrationTest { + + @Container + @ServiceConnection + static MongoDBContainer mongoDBContainer = new MongoDBContainer(DockerImageName.parse("mongo:4.0.10")); + + @Autowired + private MiddleEarthCharactersRepository repository; + + @BeforeEach + void beforeEach() { + repository.deleteAll(); + } + + @Test + void whenRequestingHobbits_thenReturnFrodoAndSam() { + repository.saveAll(List.of( + new MiddleEarthCharacter("Frodo", "hobbit"), + new MiddleEarthCharacter("Samwise", "hobbit"), + new MiddleEarthCharacter("Aragon", "human"), + new MiddleEarthCharacter("Gandalf", "wizzard") + )); + + when().get("/characters?race=hobbit") + .then().statusCode(200) + .and().body("name", hasItems("Frodo", "Samwise")); + } + +} From d3b6ca69741d5ecba67f55fe86b0de14dce6ffdf Mon Sep 17 00:00:00 2001 From: "emanuel.trandafir" Date: Sun, 13 Aug 2023 13:10:21 +0200 Subject: [PATCH 2/4] BAEL-6649: renamed package --- spring-boot-modules/spring-boot-3-testcontainers/pom.xml | 1 + .../{middleearth => support}/MiddleEarthCharacter.java | 2 +- .../MiddleEarthCharactersController.java | 2 +- .../MiddleEarthCharactersRepository.java | 2 +- .../testcontainers/DynamicPropertiesIntegrationTest.java | 5 ++--- .../testcontainers/ServiceConnectionIntegrationTest.java | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) rename spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/{middleearth => support}/MiddleEarthCharacter.java (88%) rename spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/{middleearth => support}/MiddleEarthCharactersController.java (95%) rename spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/{middleearth => support}/MiddleEarthCharactersRepository.java (86%) diff --git a/spring-boot-modules/spring-boot-3-testcontainers/pom.xml b/spring-boot-modules/spring-boot-3-testcontainers/pom.xml index 24b88bc7bc..6763d1b3d4 100644 --- a/spring-boot-modules/spring-boot-3-testcontainers/pom.xml +++ b/spring-boot-modules/spring-boot-3-testcontainers/pom.xml @@ -25,6 +25,7 @@ org.springframework.boot spring-boot-starter-web + ${spring-boot.version} org.springframework.boot diff --git a/spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/middleearth/MiddleEarthCharacter.java b/spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/support/MiddleEarthCharacter.java similarity index 88% rename from spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/middleearth/MiddleEarthCharacter.java rename to spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/support/MiddleEarthCharacter.java index 38f125d3cf..4780a2f66a 100644 --- a/spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/middleearth/MiddleEarthCharacter.java +++ b/spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/support/MiddleEarthCharacter.java @@ -1,4 +1,4 @@ -package com.baeldung.testcontainers.middleearth; +package com.baeldung.testcontainers.support; import java.util.UUID; diff --git a/spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/middleearth/MiddleEarthCharactersController.java b/spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/support/MiddleEarthCharactersController.java similarity index 95% rename from spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/middleearth/MiddleEarthCharactersController.java rename to spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/support/MiddleEarthCharactersController.java index ef99732cc8..3b7bfddbef 100644 --- a/spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/middleearth/MiddleEarthCharactersController.java +++ b/spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/support/MiddleEarthCharactersController.java @@ -1,4 +1,4 @@ -package com.baeldung.testcontainers.middleearth; +package com.baeldung.testcontainers.support; import java.util.List; diff --git a/spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/middleearth/MiddleEarthCharactersRepository.java b/spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/support/MiddleEarthCharactersRepository.java similarity index 86% rename from spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/middleearth/MiddleEarthCharactersRepository.java rename to spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/support/MiddleEarthCharactersRepository.java index 6101d7d1e1..a668650670 100644 --- a/spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/middleearth/MiddleEarthCharactersRepository.java +++ b/spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/support/MiddleEarthCharactersRepository.java @@ -1,4 +1,4 @@ -package com.baeldung.testcontainers.middleearth; +package com.baeldung.testcontainers.support; import java.util.List; diff --git a/spring-boot-modules/spring-boot-3-testcontainers/src/test/java/com/baeldung/testcontainers/DynamicPropertiesIntegrationTest.java b/spring-boot-modules/spring-boot-3-testcontainers/src/test/java/com/baeldung/testcontainers/DynamicPropertiesIntegrationTest.java index f66603b420..f008471b2a 100644 --- a/spring-boot-modules/spring-boot-3-testcontainers/src/test/java/com/baeldung/testcontainers/DynamicPropertiesIntegrationTest.java +++ b/spring-boot-modules/spring-boot-3-testcontainers/src/test/java/com/baeldung/testcontainers/DynamicPropertiesIntegrationTest.java @@ -11,7 +11,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.testcontainers.service.connection.ServiceConnection; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.DynamicPropertyRegistry; import org.springframework.test.context.DynamicPropertySource; @@ -20,8 +19,8 @@ import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; import org.testcontainers.utility.DockerImageName; -import com.baeldung.testcontainers.middleearth.MiddleEarthCharacter; -import com.baeldung.testcontainers.middleearth.MiddleEarthCharactersRepository; +import com.baeldung.testcontainers.support.MiddleEarthCharacter; +import com.baeldung.testcontainers.support.MiddleEarthCharactersRepository; @Testcontainers @SpringBootTest(webEnvironment = DEFINED_PORT) diff --git a/spring-boot-modules/spring-boot-3-testcontainers/src/test/java/com/baeldung/testcontainers/ServiceConnectionIntegrationTest.java b/spring-boot-modules/spring-boot-3-testcontainers/src/test/java/com/baeldung/testcontainers/ServiceConnectionIntegrationTest.java index 29e5b51704..d7cdbbd580 100644 --- a/spring-boot-modules/spring-boot-3-testcontainers/src/test/java/com/baeldung/testcontainers/ServiceConnectionIntegrationTest.java +++ b/spring-boot-modules/spring-boot-3-testcontainers/src/test/java/com/baeldung/testcontainers/ServiceConnectionIntegrationTest.java @@ -18,8 +18,8 @@ import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; import org.testcontainers.utility.DockerImageName; -import com.baeldung.testcontainers.middleearth.MiddleEarthCharacter; -import com.baeldung.testcontainers.middleearth.MiddleEarthCharactersRepository; +import com.baeldung.testcontainers.support.MiddleEarthCharacter; +import com.baeldung.testcontainers.support.MiddleEarthCharactersRepository; @Testcontainers @SpringBootTest(webEnvironment = DEFINED_PORT) From 8532ae8aa9831f5adae8779d992b2a822b055d99 Mon Sep 17 00:00:00 2001 From: "emanuel.trandafir" Date: Mon, 21 Aug 2023 08:25:30 +0200 Subject: [PATCH 3/4] BAEL-6649: code review #2 --- .../spring-boot-3-testcontainers/pom.xml | 10 ++-------- .../DynamicPropertiesIntegrationTest.java | 4 ++-- .../baeldung/testcontainers/LocalDevApplication.java | 6 +++--- .../ServiceConnectionIntegrationTest.java | 4 ++-- 4 files changed, 9 insertions(+), 15 deletions(-) diff --git a/spring-boot-modules/spring-boot-3-testcontainers/pom.xml b/spring-boot-modules/spring-boot-3-testcontainers/pom.xml index 6763d1b3d4..173fb8795c 100644 --- a/spring-boot-modules/spring-boot-3-testcontainers/pom.xml +++ b/spring-boot-modules/spring-boot-3-testcontainers/pom.xml @@ -20,35 +20,29 @@ org.springframework.boot spring-boot-starter - ${spring-boot.version} org.springframework.boot spring-boot-starter-web - ${spring-boot.version} org.springframework.boot spring-boot-devtools - ${spring-boot.version} runtime true org.springframework.boot spring-boot-starter-test - ${spring-boot.version} org.springframework.boot spring-boot-starter-data-mongodb - ${spring-boot.version} org.springframework.boot spring-boot-testcontainers - ${spring-boot.version} @@ -73,7 +67,7 @@ io.rest-assured rest-assured - 5.3.1 + ${rest-assured.version} test @@ -102,7 +96,7 @@ 3.0.0-M7 1.18.3 - 3.1.0 + 5.3.1 \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-3-testcontainers/src/test/java/com/baeldung/testcontainers/DynamicPropertiesIntegrationTest.java b/spring-boot-modules/spring-boot-3-testcontainers/src/test/java/com/baeldung/testcontainers/DynamicPropertiesIntegrationTest.java index f008471b2a..8689b10110 100644 --- a/spring-boot-modules/spring-boot-3-testcontainers/src/test/java/com/baeldung/testcontainers/DynamicPropertiesIntegrationTest.java +++ b/spring-boot-modules/spring-boot-3-testcontainers/src/test/java/com/baeldung/testcontainers/DynamicPropertiesIntegrationTest.java @@ -52,8 +52,8 @@ class DynamicPropertiesIntegrationTest { )); when().get("/characters?race=hobbit") - .then().statusCode(200) - .and().body("name", hasItems("Frodo", "Samwise")); + .then().statusCode(200) + .and().body("name", hasItems("Frodo", "Samwise")); } } diff --git a/spring-boot-modules/spring-boot-3-testcontainers/src/test/java/com/baeldung/testcontainers/LocalDevApplication.java b/spring-boot-modules/spring-boot-3-testcontainers/src/test/java/com/baeldung/testcontainers/LocalDevApplication.java index 91eef3bf1d..a94c0f772a 100644 --- a/spring-boot-modules/spring-boot-3-testcontainers/src/test/java/com/baeldung/testcontainers/LocalDevApplication.java +++ b/spring-boot-modules/spring-boot-3-testcontainers/src/test/java/com/baeldung/testcontainers/LocalDevApplication.java @@ -8,12 +8,12 @@ import org.springframework.context.annotation.Bean; import org.testcontainers.containers.MongoDBContainer; import org.testcontainers.utility.DockerImageName; -public class LocalDevApplication { +class LocalDevApplication { public static void main(String[] args) { SpringApplication.from(Application::main) - .with(LocalDevTestcontainersConfig.class) - .run(args); + .with(LocalDevTestcontainersConfig.class) + .run(args); } @TestConfiguration(proxyBeanMethods = false) diff --git a/spring-boot-modules/spring-boot-3-testcontainers/src/test/java/com/baeldung/testcontainers/ServiceConnectionIntegrationTest.java b/spring-boot-modules/spring-boot-3-testcontainers/src/test/java/com/baeldung/testcontainers/ServiceConnectionIntegrationTest.java index d7cdbbd580..500d6d2e61 100644 --- a/spring-boot-modules/spring-boot-3-testcontainers/src/test/java/com/baeldung/testcontainers/ServiceConnectionIntegrationTest.java +++ b/spring-boot-modules/spring-boot-3-testcontainers/src/test/java/com/baeldung/testcontainers/ServiceConnectionIntegrationTest.java @@ -48,8 +48,8 @@ class ServiceConnectionIntegrationTest { )); when().get("/characters?race=hobbit") - .then().statusCode(200) - .and().body("name", hasItems("Frodo", "Samwise")); + .then().statusCode(200) + .and().body("name", hasItems("Frodo", "Samwise")); } } From 429ebba267fb43c7a13af7cc1288f11763d1c076 Mon Sep 17 00:00:00 2001 From: "emanuel.trandafir" Date: Fri, 25 Aug 2023 13:59:22 +0200 Subject: [PATCH 4/4] BAEL-6649: added module entry in parent pom --- spring-boot-modules/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-boot-modules/pom.xml b/spring-boot-modules/pom.xml index fa05c1061a..251dba0316 100644 --- a/spring-boot-modules/pom.xml +++ b/spring-boot-modules/pom.xml @@ -91,6 +91,7 @@ spring-boot-3-native spring-boot-3-observation spring-boot-3-test-pitfalls + spring-boot-3-testcontainers spring-boot-resilience4j spring-boot-properties spring-boot-properties-2