Merge pull request #10172 from eugenp/fix-redis-build-failure
fix redis context test
This commit is contained in:
commit
fcbb99633c
|
@ -5,7 +5,6 @@ import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.PropertySource;
|
import org.springframework.context.annotation.PropertySource;
|
||||||
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
|
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.core.RedisTemplate;
|
||||||
import org.springframework.data.redis.listener.ChannelTopic;
|
import org.springframework.data.redis.listener.ChannelTopic;
|
||||||
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
|
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
|
||||||
|
|
|
@ -1,16 +1,32 @@
|
||||||
package com.baeldung;
|
package com.baeldung;
|
||||||
|
|
||||||
|
import org.junit.AfterClass;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.annotation.DirtiesContext;
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
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)
|
import redis.embedded.RedisServerBuilder;
|
||||||
@ContextConfiguration(classes = RedisConfig.class)
|
|
||||||
|
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = SpringRedisApplication.class)
|
||||||
|
@DirtiesContext(classMode = ClassMode.BEFORE_CLASS)
|
||||||
public class SpringContextTest {
|
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
|
@Test
|
||||||
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue