File tree Expand file tree Collapse file tree 2 files changed +58
-0
lines changed
core/testcontainers-redis/src/test/java/com/redis/testcontainers Expand file tree Collapse file tree 2 files changed +58
-0
lines changed Original file line number Diff line number Diff line change 1+ package com .redis .testcontainers ;
2+
3+ import org .junit .jupiter .api .Assertions ;
4+ import org .junit .jupiter .api .Test ;
5+ import org .testcontainers .junit .jupiter .Container ;
6+ import org .testcontainers .junit .jupiter .Testcontainers ;
7+
8+ import io .lettuce .core .RedisClient ;
9+ import io .lettuce .core .api .StatefulRedisConnection ;
10+ import io .lettuce .core .api .sync .RedisCommands ;
11+
12+ @ Testcontainers
13+ public class RedisExampleTest {
14+
15+ @ Container
16+ private static RedisContainer redisContainer = new RedisContainer (
17+ RedisContainer .DEFAULT_IMAGE_NAME .withTag (RedisContainer .DEFAULT_TAG ));
18+
19+ @ Test
20+ void testSomethingUsingLettuce () {
21+ // Retrieve the Redis URI from the container
22+ String redisURI = redisContainer .getRedisURI ();
23+ RedisClient client = RedisClient .create (redisURI );
24+ try (StatefulRedisConnection <String , String > connection = client .connect ()) {
25+ RedisCommands <String , String > commands = connection .sync ();
26+ Assertions .assertEquals ("PONG" , commands .ping ());
27+ }
28+ }
29+ }
Original file line number Diff line number Diff line change 1+ package com .redis .testcontainers ;
2+
3+ import org .junit .jupiter .api .Assertions ;
4+ import org .junit .jupiter .api .Test ;
5+ import org .testcontainers .junit .jupiter .Container ;
6+ import org .testcontainers .junit .jupiter .Testcontainers ;
7+
8+ import com .redis .lettucemod .RedisModulesClient ;
9+ import com .redis .lettucemod .api .StatefulRedisModulesConnection ;
10+ import com .redis .lettucemod .api .sync .RedisModulesCommands ;
11+
12+ @ Testcontainers
13+ public class RedisStackExampleTest {
14+
15+ @ Container
16+ private static RedisStackContainer redisContainer = new RedisStackContainer (
17+ RedisStackContainer .DEFAULT_IMAGE_NAME .withTag (RedisStackContainer .DEFAULT_TAG ));
18+
19+ @ Test
20+ void testSomethingUsingLettuce () {
21+ // Retrieve the Redis URI from the container
22+ String redisURI = redisContainer .getRedisURI ();
23+ RedisModulesClient client = RedisModulesClient .create (redisURI );
24+ try (StatefulRedisModulesConnection <String , String > connection = client .connect ()) {
25+ RedisModulesCommands <String , String > commands = connection .sync ();
26+ Assertions .assertEquals ("PONG" , commands .ping ());
27+ }
28+ }
29+ }
You can’t perform that action at this time.
0 commit comments