File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change 1+ package com .back ;
2+
3+ import org .junit .jupiter .api .Test ;
4+ import org .springframework .beans .factory .annotation .Autowired ;
5+ import org .springframework .boot .test .context .SpringBootTest ;
6+ import org .springframework .data .redis .core .StringRedisTemplate ;
7+ import org .springframework .test .context .ActiveProfiles ;
8+
9+ import static org .assertj .core .api .Assertions .assertThat ;
10+
11+ @ SpringBootTest
12+ @ ActiveProfiles ("test" )
13+ class RedisConnectionTest {
14+
15+ @ Autowired
16+ private StringRedisTemplate redisTemplate ;
17+
18+ @ Test
19+ void redisShouldStoreAndGetValue () {
20+ // given
21+ String key = "test:key" ;
22+ String value = "hello" ;
23+
24+ // when
25+ redisTemplate .opsForValue ().set (key , value );
26+ String result = redisTemplate .opsForValue ().get (key );
27+
28+ // then
29+ assertThat (result ).isEqualTo (value );
30+ }
31+ }
You can’t perform that action at this time.
0 commit comments