From cf6212b9553e1e6cdb73e7a47a20ca3640113424 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Tue, 10 May 2016 10:22:37 -0700 Subject: [PATCH] Polish --- spring-boot-actuator-docs/pom.xml | 2 +- .../boot/actuate/endpoint/InfoEndpoint.java | 3 +- .../InfoEndpointCompatibilityTests.java | 2 + ...Jackson2ObjectMapperBuilderCustomizer.java | 1 + .../oauth2/client/SsoSecurityConfigurer.java | 8 ++- .../oauth2/OAuth2AutoConfigurationTests.java | 4 +- .../SessionAutoConfigurationTests.java | 1 - ...spatcherServletAutoConfigurationTests.java | 4 +- spring-boot-dependencies/pom.xml | 1 - .../spring-boot-starter-redis/pom.xml | 5 +- ...erDepricationWarningAutoConfiguration.java | 47 +++++++++++++++++ .../main/resources/META-INF/spring.factories | 3 ++ .../boot/test/TestRestTemplate.java | 51 +++++++++---------- .../boot/test/TestRestTemplateTests.java | 9 +++- ...tEmbeddedServletContainerFactoryTests.java | 1 - 15 files changed, 99 insertions(+), 43 deletions(-) create mode 100644 spring-boot-starters/spring-boot-starter-redis/src/main/java/org/springframework/boot/starter/redis/RedisStarterDepricationWarningAutoConfiguration.java create mode 100644 spring-boot-starters/spring-boot-starter-redis/src/main/resources/META-INF/spring.factories diff --git a/spring-boot-actuator-docs/pom.xml b/spring-boot-actuator-docs/pom.xml index 12927fbc86..6ef2498e11 100644 --- a/spring-boot-actuator-docs/pom.xml +++ b/spring-boot-actuator-docs/pom.xml @@ -21,7 +21,7 @@ org.springframework.boot - spring-boot-starter-actuator + spring-boot-actuator provided diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/InfoEndpoint.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/InfoEndpoint.java index 60a9f696cf..b9915c6fb4 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/InfoEndpoint.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/InfoEndpoint.java @@ -54,8 +54,7 @@ public class InfoEndpoint extends AbstractEndpoint> { * Constructor provided for backward compatibility. * @param info a map (which is added to the info) * @param infoContributors the info contributors to use - * - * @deprecated in favour of the constructor without the map + * @deprecated as of 1.4 in favor of the constructor without the map */ @Deprecated public InfoEndpoint(Map info, InfoContributor... infoContributors) { diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/InfoEndpointCompatibilityTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/InfoEndpointCompatibilityTests.java index 1a5fc3578a..090c5679bf 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/InfoEndpointCompatibilityTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/InfoEndpointCompatibilityTests.java @@ -31,6 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Dave Syer */ +@Deprecated public class InfoEndpointCompatibilityTests { @Test @@ -55,4 +56,5 @@ public class InfoEndpointCompatibilityTests { }; } + } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jackson/Jackson2ObjectMapperBuilderCustomizer.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jackson/Jackson2ObjectMapperBuilderCustomizer.java index 59b6a451f4..7e18099346 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jackson/Jackson2ObjectMapperBuilderCustomizer.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jackson/Jackson2ObjectMapperBuilderCustomizer.java @@ -35,4 +35,5 @@ public interface Jackson2ObjectMapperBuilderCustomizer { * @param jacksonObjectMapperBuilder the jacksonObjectMapperBuilder to customize */ void customize(Jackson2ObjectMapperBuilder jacksonObjectMapperBuilder); + } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/SsoSecurityConfigurer.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/SsoSecurityConfigurer.java index f876d15609..f3786abed6 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/SsoSecurityConfigurer.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/SsoSecurityConfigurer.java @@ -37,6 +37,11 @@ import org.springframework.security.web.util.matcher.RequestHeaderRequestMatcher import org.springframework.web.accept.ContentNegotiationStrategy; import org.springframework.web.accept.HeaderContentNegotiationStrategy; +/** + * Configurer for OAuth2 Single Sign On (SSO). + * + * @author Dave Syer + */ class SsoSecurityConfigurer { private ApplicationContext applicationContext; @@ -46,7 +51,8 @@ class SsoSecurityConfigurer { } public void configure(HttpSecurity http) throws Exception { - OAuth2SsoProperties sso = this.applicationContext.getBean(OAuth2SsoProperties.class); + OAuth2SsoProperties sso = this.applicationContext + .getBean(OAuth2SsoProperties.class); // Delay the processing of the filter until we know the // SessionAuthenticationStrategy is available: http.apply(new OAuth2ClientAuthenticationConfigurer(oauth2SsoFilter(sso))); diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/OAuth2AutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/OAuth2AutoConfigurationTests.java index 3a208e0a0e..3acc278b92 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/OAuth2AutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/OAuth2AutoConfigurationTests.java @@ -36,8 +36,8 @@ import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfigurat import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration; import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext; import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; -import org.springframework.boot.test.EnvironmentTestUtils; -import org.springframework.boot.test.TestRestTemplate; +import org.springframework.boot.test.util.EnvironmentTestUtils; +import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; 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 2b30d4b22c..48d7ffcb1d 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 @@ -159,7 +159,6 @@ public class SessionAutoConfigurationTests extends AbstractSessionAutoConfigurat .isEqualTo("foobar"); } - @Configuration static class SessionRepositoryConfiguration { diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/DispatcherServletAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/DispatcherServletAutoConfigurationTests.java index 545d996288..73f52c62c0 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/DispatcherServletAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/DispatcherServletAutoConfigurationTests.java @@ -162,8 +162,8 @@ public class DispatcherServletAutoConfigurationTests { .containsExactly(true); assertThat(bean).extracting("dispatchOptionsRequest").containsExactly(true); assertThat(bean).extracting("dispatchTraceRequest").containsExactly(true); - assertThat( - new DirectFieldAccessor(this.context.getBean("dispatcherServletRegistration")) + assertThat(new DirectFieldAccessor( + this.context.getBean("dispatcherServletRegistration")) .getPropertyValue("loadOnStartup")).isEqualTo(5); } diff --git a/spring-boot-dependencies/pom.xml b/spring-boot-dependencies/pom.xml index f211ed00c1..25fe41ac32 100644 --- a/spring-boot-dependencies/pom.xml +++ b/spring-boot-dependencies/pom.xml @@ -335,7 +335,6 @@ 1.4.0.BUILD-SNAPSHOT - org.springframework.boot spring-boot-starter-redis 1.4.0.BUILD-SNAPSHOT diff --git a/spring-boot-starters/spring-boot-starter-redis/pom.xml b/spring-boot-starters/spring-boot-starter-redis/pom.xml index 56bf9e8893..6e699543fb 100644 --- a/spring-boot-starters/spring-boot-starter-redis/pom.xml +++ b/spring-boot-starters/spring-boot-starter-redis/pom.xml @@ -8,9 +8,8 @@ spring-boot-starter-redis spring-boot-starter-redis (DEPRECATED) - DEPRECATED (use spring-boot-starter-data-redis instead). - Starter for using Redis key-value data store with Spring Data Redis and - the Jedis client + Starter for using Redis key-value data store with Spring Data Redis and + the Jedis client. Deprecated as of 1.4 in favor of spring-boot-starter-data-redis http://projects.spring.io/spring-boot/ Pivotal Software, Inc. diff --git a/spring-boot-starters/spring-boot-starter-redis/src/main/java/org/springframework/boot/starter/redis/RedisStarterDepricationWarningAutoConfiguration.java b/spring-boot-starters/spring-boot-starter-redis/src/main/java/org/springframework/boot/starter/redis/RedisStarterDepricationWarningAutoConfiguration.java new file mode 100644 index 0000000000..1fbd6cf31b --- /dev/null +++ b/spring-boot-starters/spring-boot-starter-redis/src/main/java/org/springframework/boot/starter/redis/RedisStarterDepricationWarningAutoConfiguration.java @@ -0,0 +1,47 @@ +/* + * Copyright 2012-2016 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.starter.redis; + +import javax.annotation.PostConstruct; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.context.annotation.Configuration; + +/** + * {@link EnableAutoConfiguration Auto-configuration} to print a deprecation warning about + * the starter. + * + * @author Phillip Webb + * @since 1.4.0 + */ +@Configuration +@Deprecated +public class RedisStarterDepricationWarningAutoConfiguration { + + private static final Log logger = LogFactory + .getLog(RedisStarterDepricationWarningAutoConfiguration.class); + + @PostConstruct + public void logWarning() { + logger.warn("spring-boot-starter-redis is deprecated as of Spring Boot 1.4, " + + "please migrate to spring-boot-starter-data-redis"); + } + +} diff --git a/spring-boot-starters/spring-boot-starter-redis/src/main/resources/META-INF/spring.factories b/spring-boot-starters/spring-boot-starter-redis/src/main/resources/META-INF/spring.factories new file mode 100644 index 0000000000..0a72942759 --- /dev/null +++ b/spring-boot-starters/spring-boot-starter-redis/src/main/resources/META-INF/spring.factories @@ -0,0 +1,3 @@ +# Auto Configure +org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ +org.springframework.boot.starter.redis.RedisStarterDepricationWarningAutoConfiguration diff --git a/spring-boot-test/src/main/java/org/springframework/boot/test/TestRestTemplate.java b/spring-boot-test/src/main/java/org/springframework/boot/test/TestRestTemplate.java index 5604c2f3d1..97462e4480 100644 --- a/spring-boot-test/src/main/java/org/springframework/boot/test/TestRestTemplate.java +++ b/spring-boot-test/src/main/java/org/springframework/boot/test/TestRestTemplate.java @@ -19,51 +19,46 @@ package org.springframework.boot.test; import org.springframework.web.client.RestTemplate; /** - * Convenient subclass of {@link RestTemplate} that is suitable for integration - * tests. They are fault tolerant, and optionally can carry Basic authentication - * headers. If Apache Http Client 4.3.2 or better is available (recommended) it - * will be used as the client, and by default configured to ignore cookies and - * redirects. + * Convenient subclass of {@link RestTemplate} that is suitable for integration tests. + * They are fault tolerant, and optionally can carry Basic authentication headers. If + * Apache Http Client 4.3.2 or better is available (recommended) it will be used as the + * client, and by default configured to ignore cookies and redirects. * * @author Dave Syer * @author Phillip Webb * @deprecated as of 1.4 in favor of - * {@link org.springframework.boot.test.web.client.TestRestTemplate} + * {@link org.springframework.boot.test.web.client.TestRestTemplate} */ @Deprecated -public class TestRestTemplate extends org.springframework.boot.test.web.client.TestRestTemplate { +public class TestRestTemplate + extends org.springframework.boot.test.web.client.TestRestTemplate { /** * Create a new {@link TestRestTemplate} instance. - * - * @param httpClientOptions - * client options to use if the Apache HTTP Client is used + * @param httpClientOptions client options to use if the Apache HTTP Client is used */ public TestRestTemplate(HttpClientOption... httpClientOptions) { - super(options(httpClientOptions)); + super(convertOptions(httpClientOptions)); } /** - * Create a new {@link TestRestTemplate} instance with the specified - * credentials. - * - * @param username - * the username to use (or {@code null}) - * @param password - * the password (or {@code null}) - * @param httpClientOptions - * client options to use if the Apache HTTP Client is used + * Create a new {@link TestRestTemplate} instance with the specified credentials. + * @param username the username to use (or {@code null}) + * @param password the password (or {@code null}) + * @param httpClientOptions client options to use if the Apache HTTP Client is used */ - public TestRestTemplate(String username, String password, HttpClientOption... httpClientOptions) { - super(username, password, options(httpClientOptions)); + public TestRestTemplate(String username, String password, + HttpClientOption... httpClientOptions) { + super(username, password, convertOptions(httpClientOptions)); } - private static org.springframework.boot.test.web.client.TestRestTemplate.HttpClientOption[] options( - HttpClientOption[] httpClientOptions) { - org.springframework.boot.test.web.client.TestRestTemplate.HttpClientOption[] result = new org.springframework.boot.test.web.client.TestRestTemplate.HttpClientOption[httpClientOptions.length]; - for (int i = 0; i < httpClientOptions.length; i++) { - HttpClientOption httpClientOption = httpClientOptions[i]; - result[i] = org.springframework.boot.test.web.client.TestRestTemplate.HttpClientOption.valueOf(httpClientOption.name()); + private static org.springframework.boot.test.web.client.TestRestTemplate.HttpClientOption[] convertOptions( + HttpClientOption[] options) { + org.springframework.boot.test.web.client.TestRestTemplate.HttpClientOption[] result = new org.springframework.boot.test.web.client.TestRestTemplate.HttpClientOption[options.length]; + for (int i = 0; i < options.length; i++) { + HttpClientOption option = options[i]; + result[i] = org.springframework.boot.test.web.client.TestRestTemplate.HttpClientOption + .valueOf(option.name()); } return result; } diff --git a/spring-boot-test/src/test/java/org/springframework/boot/test/TestRestTemplateTests.java b/spring-boot-test/src/test/java/org/springframework/boot/test/TestRestTemplateTests.java index ee6cd64c70..e43c3bbcf8 100644 --- a/spring-boot-test/src/test/java/org/springframework/boot/test/TestRestTemplateTests.java +++ b/spring-boot-test/src/test/java/org/springframework/boot/test/TestRestTemplateTests.java @@ -20,11 +20,18 @@ import org.junit.Test; import static org.assertj.core.api.Assertions.assertThat; +/** + * Tests for the deprecated {@link TestRestTemplate}. + * + * @author Dave Syer + */ +@Deprecated public class TestRestTemplateTests { @Test public void canCreateTemplateFromOwnOptions() { - TestRestTemplate template = new TestRestTemplate(TestRestTemplate.HttpClientOption.ENABLE_REDIRECTS); + TestRestTemplate template = new TestRestTemplate( + TestRestTemplate.HttpClientOption.ENABLE_REDIRECTS); assertThat(template).isNotNull(); } diff --git a/spring-boot/src/test/java/org/springframework/boot/context/embedded/AbstractEmbeddedServletContainerFactoryTests.java b/spring-boot/src/test/java/org/springframework/boot/context/embedded/AbstractEmbeddedServletContainerFactoryTests.java index befd2b2ee3..e1a479180d 100644 --- a/spring-boot/src/test/java/org/springframework/boot/context/embedded/AbstractEmbeddedServletContainerFactoryTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/context/embedded/AbstractEmbeddedServletContainerFactoryTests.java @@ -1065,7 +1065,6 @@ public abstract class AbstractEmbeddedServletContainerFactoryTests { } } - private class TestGzipInputStreamFactory implements InputStreamFactory { private final AtomicBoolean requested = new AtomicBoolean(false);