Move and refactor Redis test server @Rule

Move the Redis JUnit @Rule so that it can be used with
SessionAutoConfigurationTests. Also refactored the internals a little.
This commit is contained in:
Phillip Webb
2015-07-13 11:52:42 -07:00
parent 9ebe15232e
commit fd6024ebf1
8 changed files with 166 additions and 163 deletions

View File

@@ -95,7 +95,6 @@ public class RedisAutoConfigurationTests {
@Test
public void testRedisConfigurationWithSentinel() throws Exception {
List<String> sentinels = Arrays.asList("127.0.0.1:26379", "127.0.0.1:26380");
if (isAtLeastOneSentinelAvailable(sentinels)) {
load("spring.redis.sentinel.master:mymaster", "spring.redis.sentinel.nodes:"
+ StringUtils.collectionToCommaDelimitedString(sentinels));

View File

@@ -17,6 +17,7 @@
package org.springframework.boot.autoconfigure.session;
import org.junit.After;
import org.junit.Rule;
import org.junit.Test;
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.redis.RedisAutoConfiguration;
@@ -25,6 +26,7 @@ import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfigurat
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.MockEmbeddedServletContainerFactory;
import org.springframework.boot.redis.RedisTestServer;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -39,6 +41,9 @@ import static org.junit.Assert.assertNotNull;
*/
public class SessionAutoConfigurationTests {
@Rule
public RedisTestServer redis = new RedisTestServer();
private AnnotationConfigEmbeddedWebApplicationContext context;
@After