File tree Expand file tree Collapse file tree 2 files changed +26
-4
lines changed
src/test/java/example/springdata/multistore Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Original file line number Diff line number Diff line change 3333 <artifactId >spring-boot-starter-data-mongodb</artifactId >
3434 </dependency >
3535
36+ <!-- Testcontainers -->
37+
38+ <dependency >
39+ <groupId >org.springframework.boot</groupId >
40+ <artifactId >spring-boot-testcontainers</artifactId >
41+ <scope >test</scope >
42+ </dependency >
43+
3644 <dependency >
37- <groupId >de.flapdoodle.embed</groupId >
38- <artifactId >de.flapdoodle.embed.mongo</artifactId >
39- <version >4.16.2</version >
40- <scope >runtime</scope >
45+ <groupId >org.testcontainers</groupId >
46+ <artifactId >mongodb</artifactId >
47+ <scope >test</scope >
4148 </dependency >
4249
4350 </dependencies >
Original file line number Diff line number Diff line change 2424import org .junit .jupiter .api .Test ;
2525import org .springframework .beans .factory .annotation .Autowired ;
2626import org .springframework .boot .test .context .SpringBootTest ;
27+ import org .springframework .boot .test .context .TestConfiguration ;
28+ import org .springframework .boot .testcontainers .service .connection .ServiceConnection ;
29+ import org .springframework .context .annotation .Bean ;
30+ import org .testcontainers .containers .MongoDBContainer ;
31+ import org .testcontainers .utility .DockerImageName ;
2732
2833/**
2934 * Integration test to show the usage of repositories backed by different stores.
@@ -37,6 +42,16 @@ public class ApplicationIntegrationTests {
3742 @ Autowired PersonRepository personRepository ;
3843 @ Autowired TreasureRepository treasureRepository ;
3944
45+ @ TestConfiguration
46+ static class Infrastructure {
47+
48+ @ Bean
49+ @ ServiceConnection
50+ MongoDBContainer mongoDBContainer () {
51+ return new MongoDBContainer (DockerImageName .parse ("mongodb/mongodb-community-server" ));
52+ }
53+ }
54+
4055 @ Test
4156 public void useMultipleRepositories () {
4257
You can’t perform that action at this time.
0 commit comments