File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
backend/src/test/java/io/f1/backend/global/config Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 1+ package io .f1 .backend .global .config ;
2+
3+ import com .redis .testcontainers .RedisContainer ;
4+ import org .redisson .Redisson ;
5+ import org .redisson .api .RedissonClient ;
6+ import org .redisson .config .Config ;
7+ import org .springframework .context .annotation .Bean ;
8+ import org .springframework .context .annotation .Configuration ;
9+ import org .testcontainers .junit .jupiter .Container ;
10+ import org .testcontainers .junit .jupiter .Testcontainers ;
11+
12+ @ Configuration
13+ @ Testcontainers
14+ public class RedissonTestContainerConfig {
15+
16+ @ Container
17+ public static RedisContainer redisContainer =
18+ new RedisContainer (
19+ RedisContainer .DEFAULT_IMAGE_NAME .withTag (RedisContainer .DEFAULT_TAG ));
20+
21+ static {
22+ redisContainer .start ();
23+ }
24+
25+ @ Bean
26+ public RedissonClient redissonClient () {
27+ Config config = new Config ();
28+ String address = String .format ("redis://%s:%d" ,
29+ RedissonTestContainerConfig .redisContainer .getHost (),
30+ RedissonTestContainerConfig .redisContainer .getFirstMappedPort ());
31+
32+ config .useSingleServer ()
33+ .setAddress (address );
34+
35+ return Redisson .create (config );
36+ }
37+ }
You can’t perform that action at this time.
0 commit comments