From 6466c0afa5f7020db5c572e903c42cd0ce2103e4 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Mon, 2 May 2016 14:44:15 -0700 Subject: [PATCH] Polish --- .../session/HashMapSessionConfiguration.java | 11 ++++++----- .../session/NoOpSessionConfiguration.java | 1 + .../AbstractSessionAutoConfigurationTests.java | 5 +++-- .../SessionAutoConfigurationRedisTests.java | 3 +-- .../session/SessionAutoConfigurationTests.java | 16 ++++++++-------- .../web/FilterOrderingIntegrationTests.java | 7 ++++--- 6 files changed, 23 insertions(+), 20 deletions(-) diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/HashMapSessionConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/HashMapSessionConfiguration.java index 182992d083..332df6d272 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/HashMapSessionConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/HashMapSessionConfiguration.java @@ -36,13 +36,14 @@ import org.springframework.session.config.annotation.web.http.EnableSpringHttpSe class HashMapSessionConfiguration { @Bean - public SessionRepository sessionRepository(SessionProperties sessionProperties) { - MapSessionRepository sessionRepository = new MapSessionRepository(); - Integer timeout = sessionProperties.getTimeout(); + public SessionRepository sessionRepository( + SessionProperties properties) { + MapSessionRepository repository = new MapSessionRepository(); + Integer timeout = properties.getTimeout(); if (timeout != null) { - sessionRepository.setDefaultMaxInactiveInterval(timeout); + repository.setDefaultMaxInactiveInterval(timeout); } - return sessionRepository; + return repository; } } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/NoOpSessionConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/NoOpSessionConfiguration.java index c374c1bd2f..d2051acfaf 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/NoOpSessionConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/NoOpSessionConfiguration.java @@ -30,4 +30,5 @@ import org.springframework.session.SessionRepository; @ConditionalOnMissingBean(SessionRepository.class) @Conditional(SessionCondition.class) class NoOpSessionConfiguration { + } diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/AbstractSessionAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/AbstractSessionAutoConfigurationTests.java index 0c7f462d4c..dd8106e2fe 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/AbstractSessionAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/AbstractSessionAutoConfigurationTests.java @@ -45,8 +45,9 @@ public abstract class AbstractSessionAutoConfigurationTests { } } - protected > T validateSessionRepository(Class type) { - SessionRepository cacheManager = this.context.getBean(SessionRepository.class); + protected > T validateSessionRepository( + Class type) { + SessionRepository cacheManager = this.context.getBean(SessionRepository.class); assertThat(cacheManager).as("Wrong session repository type").isInstanceOf(type); return type.cast(cacheManager); } diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationRedisTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationRedisTests.java index 2647063842..6b6ede83f1 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationRedisTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationRedisTests.java @@ -55,8 +55,7 @@ public class SessionAutoConfigurationRedisTests @Test public void redisSessionStoreWithCustomizations() { load(Collections.>singletonList(RedisAutoConfiguration.class), - "spring.session.store-type=redis", - "spring.session.redis.namespace=foo", + "spring.session.store-type=redis", "spring.session.redis.namespace=foo", "spring.session.redis.flush-mode=immediate"); RedisOperationsSessionRepository repository = validateSessionRepository( RedisOperationsSessionRepository.class); diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationTests.java index 1620e71b59..9f10760c9a 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationTests.java @@ -72,8 +72,7 @@ public class SessionAutoConfigurationTests extends AbstractSessionAutoConfigurat @Test public void hashMapSessionStoreCustomTimeout() { - load("spring.session.store-type=hash-map", - "server.session.timeout=3000"); + load("spring.session.store-type=hash-map", "server.session.timeout=3000"); MapSessionRepository repository = validateSessionRepository( MapSessionRepository.class); assertThat(getSessionTimeout(repository)).isEqualTo(3000); @@ -81,8 +80,7 @@ public class SessionAutoConfigurationTests extends AbstractSessionAutoConfigurat @Test public void springSessionTimeoutIsNotAValidProperty() { - load("spring.session.store-type=hash-map", - "spring.session.timeout=3000"); + load("spring.session.store-type=hash-map", "spring.session.timeout=3000"); MapSessionRepository repository = validateSessionRepository( MapSessionRepository.class); assertThat(getSessionTimeout(repository)).isNull(); @@ -130,7 +128,8 @@ public class SessionAutoConfigurationTests extends AbstractSessionAutoConfigurat "spring.session.store-type=hazelcast", "spring.session.hazelcast.map-name=foo:bar:biz"); validateSessionRepository(MapSessionRepository.class); - HazelcastInstance hazelcastInstance = this.context.getBean(HazelcastInstance.class); + HazelcastInstance hazelcastInstance = this.context + .getBean(HazelcastInstance.class); verify(hazelcastInstance, times(1)).getMap("foo:bar:biz"); } @@ -154,13 +153,13 @@ public class SessionAutoConfigurationTests extends AbstractSessionAutoConfigurat .isEqualTo("foobar"); } - @Configuration static class SessionRepositoryConfiguration { @Bean public SessionRepository mySessionRepository() { - return new MapSessionRepository(Collections.emptyMap()); + return new MapSessionRepository( + Collections.emptyMap()); } } @@ -179,8 +178,9 @@ public class SessionAutoConfigurationTests extends AbstractSessionAutoConfigurat static class HazelcastSpecificMap { @Bean + @SuppressWarnings("unchecked") public HazelcastInstance hazelcastInstance() { - IMap map = mock(IMap.class); + IMap map = mock(IMap.class); HazelcastInstance mock = mock(HazelcastInstance.class); given(mock.getMap("foo:bar:biz")).willReturn(map); return mock; diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/FilterOrderingIntegrationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/FilterOrderingIntegrationTests.java index 7acc414a10..94cfb99c9e 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/FilterOrderingIntegrationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/FilterOrderingIntegrationTests.java @@ -84,11 +84,12 @@ public class FilterOrderingIntegrationTests { private void load() { this.context = new AnnotationConfigEmbeddedWebApplicationContext(); - EnvironmentTestUtils.addEnvironment(this.context, "spring.session.store-type=hash-map"); + EnvironmentTestUtils.addEnvironment(this.context, + "spring.session.store-type=hash-map"); this.context.register(MockEmbeddedServletContainerConfiguration.class, TestRedisConfiguration.class, WebMvcAutoConfiguration.class, - ServerPropertiesAutoConfiguration.class, - SecurityAutoConfiguration.class, SessionAutoConfiguration.class, + ServerPropertiesAutoConfiguration.class, SecurityAutoConfiguration.class, + SessionAutoConfiguration.class, HttpMessageConvertersAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class, HttpEncodingAutoConfiguration.class);