|
1 | 1 | package com.baeldung.spring.data.redis;
|
2 | 2 |
|
3 |
| -import static org.junit.Assert.assertTrue; |
4 |
| - |
5 |
| -import java.io.IOException; |
6 |
| -import java.util.UUID; |
7 |
| - |
| 3 | +import com.baeldung.spring.data.redis.queue.RedisMessagePublisher; |
| 4 | +import com.baeldung.spring.data.redis.queue.RedisMessageSubscriber; |
8 | 5 | import org.junit.AfterClass;
|
9 | 6 | import org.junit.BeforeClass;
|
10 | 7 | import org.junit.Test;
|
11 | 8 | import org.junit.runner.RunWith;
|
12 | 9 | import org.springframework.beans.factory.annotation.Autowired;
|
| 10 | +import org.springframework.boot.test.context.SpringBootTest; |
13 | 11 | import org.springframework.test.annotation.DirtiesContext;
|
14 | 12 | import org.springframework.test.annotation.DirtiesContext.ClassMode;
|
15 |
| -import org.springframework.test.context.ContextConfiguration; |
16 |
| -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; |
| 13 | +import org.springframework.test.context.junit4.SpringRunner; |
| 14 | +import redis.embedded.RedisServerBuilder; |
17 | 15 |
|
18 |
| -import com.baeldung.spring.data.redis.config.RedisConfig; |
19 |
| -import com.baeldung.spring.data.redis.queue.RedisMessagePublisher; |
20 |
| -import com.baeldung.spring.data.redis.queue.RedisMessageSubscriber; |
| 16 | +import java.util.UUID; |
21 | 17 |
|
22 |
| -import redis.embedded.RedisServerBuilder; |
| 18 | +import static org.junit.Assert.assertTrue; |
23 | 19 |
|
24 |
| -@RunWith(SpringJUnit4ClassRunner.class) |
25 |
| -@ContextConfiguration(classes = RedisConfig.class) |
| 20 | +@RunWith(SpringRunner.class) |
| 21 | +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = SpringRedisApplication.class) |
26 | 22 | @DirtiesContext(classMode = ClassMode.BEFORE_CLASS)
|
27 | 23 | public class RedisMessageListenerIntegrationTest {
|
28 | 24 |
|
29 | 25 | private static redis.embedded.RedisServer redisServer;
|
30 |
| - |
| 26 | + |
31 | 27 | @Autowired
|
32 | 28 | private RedisMessagePublisher redisMessagePublisher;
|
33 |
| - |
| 29 | + |
34 | 30 | @BeforeClass
|
35 |
| - public static void startRedisServer() throws IOException { |
| 31 | + public static void startRedisServer() { |
36 | 32 | redisServer = new RedisServerBuilder().port(6379).setting("maxmemory 256M").build();
|
37 | 33 | redisServer.start();
|
38 | 34 | }
|
39 |
| - |
| 35 | + |
40 | 36 | @AfterClass
|
41 |
| - public static void stopRedisServer() throws IOException { |
| 37 | + public static void stopRedisServer() { |
42 | 38 | redisServer.stop();
|
43 | 39 | }
|
44 | 40 |
|
|
0 commit comments