diff --git a/persistence-modules/spring-data-redis/src/main/java/com/baeldung/spring/data/redis/config/RedisConfig.java b/persistence-modules/spring-data-redis/src/main/java/com/baeldung/spring/data/redis/config/RedisConfig.java index 497e1506bd..7fd13d2777 100644 --- a/persistence-modules/spring-data-redis/src/main/java/com/baeldung/spring/data/redis/config/RedisConfig.java +++ b/persistence-modules/spring-data-redis/src/main/java/com/baeldung/spring/data/redis/config/RedisConfig.java @@ -5,7 +5,6 @@ import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; -import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.listener.ChannelTopic; import org.springframework.data.redis.listener.RedisMessageListenerContainer; diff --git a/persistence-modules/spring-data-redis/src/test/java/com/baeldung/SpringContextTest.java b/persistence-modules/spring-data-redis/src/test/java/com/baeldung/SpringContextTest.java index 4df0cbd0ad..5167e63721 100644 --- a/persistence-modules/spring-data-redis/src/test/java/com/baeldung/SpringContextTest.java +++ b/persistence-modules/spring-data-redis/src/test/java/com/baeldung/SpringContextTest.java @@ -1,16 +1,32 @@ package com.baeldung; +import org.junit.AfterClass; +import org.junit.BeforeClass; import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.annotation.DirtiesContext.ClassMode; -import com.baeldung.spring.data.redis.config.RedisConfig; +import com.baeldung.spring.data.redis.SpringRedisApplication; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = RedisConfig.class) +import redis.embedded.RedisServerBuilder; + +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = SpringRedisApplication.class) +@DirtiesContext(classMode = ClassMode.BEFORE_CLASS) public class SpringContextTest { + + private static redis.embedded.RedisServer redisServer; + + @BeforeClass + public static void startRedisServer() { + redisServer = new RedisServerBuilder().port(6379).setting("maxmemory 256M").build(); + redisServer.start(); + } + @AfterClass + public static void stopRedisServer() { + redisServer.stop(); + } @Test public void whenSpringContextIsBootstrapped_thenNoExceptions() { }