File tree 2 files changed +26
-4
lines changed
src/test/java/example/springdata/multistore
2 files changed +26
-4
lines changed Original file line number Diff line number Diff line change 33
33
<artifactId >spring-boot-starter-data-mongodb</artifactId >
34
34
</dependency >
35
35
36
+ <!-- Testcontainers -->
37
+
38
+ <dependency >
39
+ <groupId >org.springframework.boot</groupId >
40
+ <artifactId >spring-boot-testcontainers</artifactId >
41
+ <scope >test</scope >
42
+ </dependency >
43
+
36
44
<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 >
41
48
</dependency >
42
49
43
50
</dependencies >
Original file line number Diff line number Diff line change 24
24
import org .junit .jupiter .api .Test ;
25
25
import org .springframework .beans .factory .annotation .Autowired ;
26
26
import 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 ;
27
32
28
33
/**
29
34
* Integration test to show the usage of repositories backed by different stores.
@@ -37,6 +42,16 @@ public class ApplicationIntegrationTests {
37
42
@ Autowired PersonRepository personRepository ;
38
43
@ Autowired TreasureRepository treasureRepository ;
39
44
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
+
40
55
@ Test
41
56
public void useMultipleRepositories () {
42
57
You can’t perform that action at this time.
0 commit comments