From 5de46c3186b8eaad82636c59bfa071270ea686c9 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Thu, 8 Feb 2018 16:34:49 -0800 Subject: [PATCH] Polish --- ...KafkaHealthIndicatorAutoConfiguration.java | 3 +- .../metrics/MeterRegistryConfigurer.java | 4 +- .../metrics/export/atlas/AtlasProperties.java | 2 +- .../atlas/AtlasPropertiesConfigAdapter.java | 2 +- .../GangliaPropertiesConfigAdapter.java | 2 +- .../PrometheusPropertiesConfigAdapter.java | 2 +- .../properties/PropertiesConfigAdapter.java | 2 +- .../properties/StepRegistryProperties.java | 2 +- .../StepRegistryPropertiesConfigAdapter.java | 2 +- .../simple/SimplePropertiesConfigAdapter.java | 2 +- .../statsd/StatsdPropertiesConfigAdapter.java | 2 +- ...HealthIndicatorAutoConfigurationTests.java | 1 + .../actuate/kafka/KafkaHealthIndicator.java | 1 + .../web/servlet/WebMvcMetricsFilter.java | 9 ++--- .../JerseyWebEndpointIntegrationTests.java | 39 ++++++++++-------- .../WebFluxEndpointIntegrationTests.java | 40 ++++++++++++------- .../MvcWebEndpointIntegrationTests.java | 39 ++++++++++-------- .../ReactiveSecurityAutoConfiguration.java | 2 +- ...veUserDetailsServiceAutoConfiguration.java | 2 +- ...eactiveSecurityAutoConfigurationTests.java | 2 +- .../main/asciidoc/spring-boot-features.adoc | 2 + .../boot/docs/ExitCodeApplication.java | 2 +- .../boot/docs/autoconfigure/UserService.java | 2 +- .../SpringApplicationBuilderExample.java | 2 +- .../CloudFoundryIgnorePathsExample.java | 2 +- .../EnvironmentPostProcessorExample.java | 2 +- .../HibernateSearchElasticsearchExample.java | 2 +- .../jest/JestClientCustomizationExample.java | 2 +- .../docs/jdbc/BasicDataSourceExample.java | 2 +- .../jdbc/CompleteTwoDataSourcesExample.java | 2 +- .../jdbc/ConfigurableDataSourceExample.java | 2 +- .../docs/jdbc/SimpleDataSourceExample.java | 2 +- .../jdbc/SimpleTwoDataSourcesExample.java | 2 +- .../AdvancedConfigurationExample.java | 2 +- .../restassured/UserDocumentationTests.java | 2 +- .../spock/SpockTestRestTemplateExample.java | 2 +- .../UnauthenticatedAccessExample.java | 2 +- .../SpringApplicationBuilderExampleTests.java | 2 +- .../EnvironmentPostProcessorExampleTests.java | 2 +- ...mcatLegacyCookieProcessorExampleTests.java | 2 +- .../jdbc/BasicDataSourceExampleTests.java | 2 +- .../CompleteTwoDataSourcesExampleTests.java | 2 +- .../ConfigurableDataSourceExampleTests.java | 2 +- .../boot/docs/jdbc/SampleApp.java | 2 +- .../jdbc/SimpleDataSourceExampleTests.java | 2 +- .../SpockTestRestTemplateExampleTests.java | 2 +- .../ConfigurationBeanFactoryMetadata.java | 2 +- ...opertiesBindingPostProcessorRegistrar.java | 2 +- .../properties/bind/JavaBeanBinder.java | 16 ++++---- .../boot/system/ApplicationHome.java | 3 +- .../context/properties/bind/BinderTests.java | 1 + ...entPortSampleActuatorApplicationTests.java | 2 +- .../spring-boot-sample-kafka/pom.xml | 5 +-- .../src/main/java/sample/kafka/Consumer.java | 3 +- .../src/main/java/sample/kafka/Producer.java | 3 +- .../sample/kafka/SampleKafkaApplication.java | 2 +- .../main/java/sample/kafka/SampleMessage.java | 6 +-- .../kafka/SampleKafkaApplicationTests.java | 3 +- .../SampleSecureWebFluxApplicationTests.java | 2 +- .../test/web/UserVehicleControllerTests.java | 2 +- 60 files changed, 141 insertions(+), 123 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/kafka/KafkaHealthIndicatorAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/kafka/KafkaHealthIndicatorAutoConfiguration.java index 803034cbd1..8bf093507f 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/kafka/KafkaHealthIndicatorAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/kafka/KafkaHealthIndicatorAutoConfiguration.java @@ -40,6 +40,7 @@ import org.springframework.kafka.core.KafkaAdmin; * {@link EnableAutoConfiguration Auto-configuration} for {@link KafkaHealthIndicator}. * * @author Juan Rada + * @since 2.0.0 */ @Configuration @ConditionalOnClass(KafkaAdmin.class) @@ -55,7 +56,7 @@ public class KafkaHealthIndicatorAutoConfiguration private final KafkaHealthIndicatorProperties properties; - KafkaHealthIndicatorAutoConfiguration(Map admins, + public KafkaHealthIndicatorAutoConfiguration(Map admins, KafkaHealthIndicatorProperties properties) { this.admins = admins; this.properties = properties; diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MeterRegistryConfigurer.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MeterRegistryConfigurer.java index 7b8affefe7..42041ddcea 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MeterRegistryConfigurer.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MeterRegistryConfigurer.java @@ -62,8 +62,8 @@ class MeterRegistryConfigurer { if (registry instanceof CompositeMeterRegistry) { return; } - // Customizers must be applied before binders, as they may add custom tags or - // alter timer or summary configuration. + // Customizers must be applied before binders, as they may add custom + // tags or alter timer or summary configuration. customize(registry); addFilters(registry); addBinders(registry); diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/atlas/AtlasProperties.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/atlas/AtlasProperties.java index 8edede82a7..73a693a644 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/atlas/AtlasProperties.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/atlas/AtlasProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/atlas/AtlasPropertiesConfigAdapter.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/atlas/AtlasPropertiesConfigAdapter.java index ea6146d568..418479fd6a 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/atlas/AtlasPropertiesConfigAdapter.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/atlas/AtlasPropertiesConfigAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/ganglia/GangliaPropertiesConfigAdapter.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/ganglia/GangliaPropertiesConfigAdapter.java index 8bd7ecc1d8..44d1e30287 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/ganglia/GangliaPropertiesConfigAdapter.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/ganglia/GangliaPropertiesConfigAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/prometheus/PrometheusPropertiesConfigAdapter.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/prometheus/PrometheusPropertiesConfigAdapter.java index 4f7615bde2..a1c6c247ef 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/prometheus/PrometheusPropertiesConfigAdapter.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/prometheus/PrometheusPropertiesConfigAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/properties/PropertiesConfigAdapter.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/properties/PropertiesConfigAdapter.java index e5c239d893..90eead2575 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/properties/PropertiesConfigAdapter.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/properties/PropertiesConfigAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/properties/StepRegistryProperties.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/properties/StepRegistryProperties.java index bc04abf3df..f150fac4c6 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/properties/StepRegistryProperties.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/properties/StepRegistryProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/properties/StepRegistryPropertiesConfigAdapter.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/properties/StepRegistryPropertiesConfigAdapter.java index eb9de5f020..74bc563f07 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/properties/StepRegistryPropertiesConfigAdapter.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/properties/StepRegistryPropertiesConfigAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/simple/SimplePropertiesConfigAdapter.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/simple/SimplePropertiesConfigAdapter.java index c46efe95d9..759fe3f8af 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/simple/SimplePropertiesConfigAdapter.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/simple/SimplePropertiesConfigAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdPropertiesConfigAdapter.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdPropertiesConfigAdapter.java index 3c48bbea21..cc90e3ac4b 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdPropertiesConfigAdapter.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdPropertiesConfigAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/kafka/KafkaHealthIndicatorAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/kafka/KafkaHealthIndicatorAutoConfigurationTests.java index b03583c7e0..20a5a5cb7a 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/kafka/KafkaHealthIndicatorAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/kafka/KafkaHealthIndicatorAutoConfigurationTests.java @@ -53,4 +53,5 @@ public class KafkaHealthIndicatorAutoConfigurationTests { .doesNotHaveBean(KafkaHealthIndicator.class) .hasSingleBean(ApplicationHealthIndicator.class)); } + } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/kafka/KafkaHealthIndicator.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/kafka/KafkaHealthIndicator.java index 5ce3d935e7..228a6de934 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/kafka/KafkaHealthIndicator.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/kafka/KafkaHealthIndicator.java @@ -38,6 +38,7 @@ import org.springframework.util.Assert; * {@link HealthIndicator} for Kafka cluster. * * @author Juan Rada + * @since 2.0.0 */ public class KafkaHealthIndicator extends AbstractHealthIndicator { diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcMetricsFilter.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcMetricsFilter.java index 20034bd995..4beb9dad91 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcMetricsFilter.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcMetricsFilter.java @@ -128,11 +128,10 @@ public class WebMvcMetricsFilter extends OncePerRequestFilter { private Object getHandler(HttpServletRequest request) throws Exception { HttpServletRequest wrapper = new UnmodifiableAttributesRequestWrapper(request); - for (HandlerMapping handlerMapping : getMappingIntrospector() - .getHandlerMappings()) { - HandlerExecutionChain chain = handlerMapping.getHandler(wrapper); + for (HandlerMapping mapping : getMappingIntrospector().getHandlerMappings()) { + HandlerExecutionChain chain = mapping.getHandler(wrapper); if (chain != null) { - if (handlerMapping instanceof MatchableHandlerMapping) { + if (mapping instanceof MatchableHandlerMapping) { return chain.getHandler(); } return null; @@ -294,8 +293,8 @@ public class WebMvcMetricsFilter extends OncePerRequestFilter { @Override public void setAttribute(String name, Object value) { - } + } } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/jersey/JerseyWebEndpointIntegrationTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/jersey/JerseyWebEndpointIntegrationTests.java index 7ac65a3292..586a85f88c 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/jersey/JerseyWebEndpointIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/jersey/JerseyWebEndpointIntegrationTests.java @@ -132,27 +132,32 @@ public class JerseyWebEndpointIntegrationTests extends protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { - filterChain.doFilter(new HttpServletRequestWrapper(request) { - - @Override - public Principal getUserPrincipal() { - - return new Principal() { - - @Override - public String getName() { - return "Alice"; - } - - }; - - } - - }, response); + filterChain.doFilter(new MockPrincipalWrapper(request), response); } }; + } + } + + private static class MockPrincipalWrapper extends HttpServletRequestWrapper { + + public MockPrincipalWrapper(HttpServletRequest request) { + super(request); + } + + @Override + public Principal getUserPrincipal() { + return new MockPrincipal(); + } + + } + + private static class MockPrincipal implements Principal { + + @Override + public String getName() { + return "Alice"; } } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/reactive/WebFluxEndpointIntegrationTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/reactive/WebFluxEndpointIntegrationTests.java index f124e8f34f..d0afb7a017 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/reactive/WebFluxEndpointIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/reactive/WebFluxEndpointIntegrationTests.java @@ -152,21 +152,8 @@ public class WebFluxEndpointIntegrationTests @Override public Mono filter(ServerWebExchange exchange, WebFilterChain chain) { - return chain.filter(new ServerWebExchangeDecorator(exchange) { - - @Override - public Mono getPrincipal() { - return Mono.just(new Principal() { - - @Override - public String getName() { - return "Alice"; - } - - }); - } - - }); + return chain.filter( + new MockPrincipalServerWebExchangeDecorator(exchange)); } }; @@ -174,4 +161,27 @@ public class WebFluxEndpointIntegrationTests } + private static class MockPrincipalServerWebExchangeDecorator + extends ServerWebExchangeDecorator { + + protected MockPrincipalServerWebExchangeDecorator(ServerWebExchange delegate) { + super(delegate); + } + + @Override + public Mono getPrincipal() { + return Mono.just(new MockPrincipal()); + } + + } + + private static class MockPrincipal implements Principal { + + @Override + public String getName() { + return "Alice"; + } + + } + } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/servlet/MvcWebEndpointIntegrationTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/servlet/MvcWebEndpointIntegrationTests.java index 79837bb7a4..64fcc7a047 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/servlet/MvcWebEndpointIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/servlet/MvcWebEndpointIntegrationTests.java @@ -146,27 +146,32 @@ public class MvcWebEndpointIntegrationTests extends protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { - filterChain.doFilter(new HttpServletRequestWrapper(request) { - - @Override - public Principal getUserPrincipal() { - - return new Principal() { - - @Override - public String getName() { - return "Alice"; - } - - }; - - } - - }, response); + filterChain.doFilter(new MockPrincipalWrapper(request), response); } }; + } + } + + private static class MockPrincipalWrapper extends HttpServletRequestWrapper { + + public MockPrincipalWrapper(HttpServletRequest request) { + super(request); + } + + @Override + public Principal getUserPrincipal() { + return new MockPrincipal(); + } + + } + + private static class MockPrincipal implements Principal { + + @Override + public String getName() { + return "Alice"; } } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/reactive/ReactiveSecurityAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/reactive/ReactiveSecurityAutoConfiguration.java index 75646b5385..083e3ebc71 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/reactive/ReactiveSecurityAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/reactive/ReactiveSecurityAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/reactive/ReactiveUserDetailsServiceAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/reactive/ReactiveUserDetailsServiceAutoConfiguration.java index 7f36829df6..6c74c6b5d8 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/reactive/ReactiveUserDetailsServiceAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/reactive/ReactiveUserDetailsServiceAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/reactive/ReactiveSecurityAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/reactive/ReactiveSecurityAutoConfigurationTests.java index c944e5eee8..1e4b9f0229 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/reactive/ReactiveSecurityAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/reactive/ReactiveSecurityAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc index 7cb43298c1..55553ed100 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -6152,6 +6152,8 @@ NOTE: While Spring's test framework caches application contexts between tests an a context for tests sharing the same configuration, the use of `@MockBean` or `@SpyBean` influences the cache key, which will most likely increase the number of contexts. + + [[boot-features-testing-spring-boot-applications-testing-autoconfigured-tests]] ==== Auto-configured Tests Spring Boot's auto-configuration system works well for applications but can sometimes be diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/ExitCodeApplication.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/ExitCodeApplication.java index b77707ab78..2d73b4c9a7 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/ExitCodeApplication.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/ExitCodeApplication.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/autoconfigure/UserService.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/autoconfigure/UserService.java index 7262ec951e..e80370d603 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/autoconfigure/UserService.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/autoconfigure/UserService.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/builder/SpringApplicationBuilderExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/builder/SpringApplicationBuilderExample.java index fcca6abd9c..13e56801e4 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/builder/SpringApplicationBuilderExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/builder/SpringApplicationBuilderExample.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/cloudfoundry/CloudFoundryIgnorePathsExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/cloudfoundry/CloudFoundryIgnorePathsExample.java index d01bdfe5f9..bd77061dd3 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/cloudfoundry/CloudFoundryIgnorePathsExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/cloudfoundry/CloudFoundryIgnorePathsExample.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/context/EnvironmentPostProcessorExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/context/EnvironmentPostProcessorExample.java index 48207c75ac..210b9b32a8 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/context/EnvironmentPostProcessorExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/context/EnvironmentPostProcessorExample.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/elasticsearch/HibernateSearchElasticsearchExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/elasticsearch/HibernateSearchElasticsearchExample.java index 904b5ad0c5..5ec76f3fa7 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/elasticsearch/HibernateSearchElasticsearchExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/elasticsearch/HibernateSearchElasticsearchExample.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/elasticsearch/jest/JestClientCustomizationExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/elasticsearch/jest/JestClientCustomizationExample.java index 0d1bcac807..fee62a1663 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/elasticsearch/jest/JestClientCustomizationExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/elasticsearch/jest/JestClientCustomizationExample.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/jdbc/BasicDataSourceExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/jdbc/BasicDataSourceExample.java index 2051151cfe..ad9f57b4b6 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/jdbc/BasicDataSourceExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/jdbc/BasicDataSourceExample.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/jdbc/CompleteTwoDataSourcesExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/jdbc/CompleteTwoDataSourcesExample.java index 79c43de1e0..624bced135 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/jdbc/CompleteTwoDataSourcesExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/jdbc/CompleteTwoDataSourcesExample.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/jdbc/ConfigurableDataSourceExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/jdbc/ConfigurableDataSourceExample.java index fc27210eaf..3ed8ecba56 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/jdbc/ConfigurableDataSourceExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/jdbc/ConfigurableDataSourceExample.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/jdbc/SimpleDataSourceExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/jdbc/SimpleDataSourceExample.java index a9b2815e4a..8375f9416a 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/jdbc/SimpleDataSourceExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/jdbc/SimpleDataSourceExample.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/jdbc/SimpleTwoDataSourcesExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/jdbc/SimpleTwoDataSourcesExample.java index 57d5df89e6..286f187270 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/jdbc/SimpleTwoDataSourcesExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/jdbc/SimpleTwoDataSourcesExample.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/autoconfigure/restdocs/restassured/AdvancedConfigurationExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/autoconfigure/restdocs/restassured/AdvancedConfigurationExample.java index 417ef7c167..d140c8af39 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/autoconfigure/restdocs/restassured/AdvancedConfigurationExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/autoconfigure/restdocs/restassured/AdvancedConfigurationExample.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/autoconfigure/restdocs/restassured/UserDocumentationTests.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/autoconfigure/restdocs/restassured/UserDocumentationTests.java index 8d9736fae0..af457d9361 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/autoconfigure/restdocs/restassured/UserDocumentationTests.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/autoconfigure/restdocs/restassured/UserDocumentationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/spock/SpockTestRestTemplateExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/spock/SpockTestRestTemplateExample.java index 7a82c33325..cc0e36145a 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/spock/SpockTestRestTemplateExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/spock/SpockTestRestTemplateExample.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/web/security/UnauthenticatedAccessExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/web/security/UnauthenticatedAccessExample.java index 337a61031b..2e1f939a8b 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/web/security/UnauthenticatedAccessExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/web/security/UnauthenticatedAccessExample.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/builder/SpringApplicationBuilderExampleTests.java b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/builder/SpringApplicationBuilderExampleTests.java index 70513f1d27..752c712f34 100644 --- a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/builder/SpringApplicationBuilderExampleTests.java +++ b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/builder/SpringApplicationBuilderExampleTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/context/EnvironmentPostProcessorExampleTests.java b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/context/EnvironmentPostProcessorExampleTests.java index 0344a2b9ea..32fbf6fc5d 100644 --- a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/context/EnvironmentPostProcessorExampleTests.java +++ b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/context/EnvironmentPostProcessorExampleTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/context/embedded/TomcatLegacyCookieProcessorExampleTests.java b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/context/embedded/TomcatLegacyCookieProcessorExampleTests.java index 16ae290171..b0ec4777a5 100644 --- a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/context/embedded/TomcatLegacyCookieProcessorExampleTests.java +++ b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/context/embedded/TomcatLegacyCookieProcessorExampleTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jdbc/BasicDataSourceExampleTests.java b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jdbc/BasicDataSourceExampleTests.java index 19473660cb..41e46a6bd7 100644 --- a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jdbc/BasicDataSourceExampleTests.java +++ b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jdbc/BasicDataSourceExampleTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jdbc/CompleteTwoDataSourcesExampleTests.java b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jdbc/CompleteTwoDataSourcesExampleTests.java index b44a75207a..e973511d79 100644 --- a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jdbc/CompleteTwoDataSourcesExampleTests.java +++ b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jdbc/CompleteTwoDataSourcesExampleTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jdbc/ConfigurableDataSourceExampleTests.java b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jdbc/ConfigurableDataSourceExampleTests.java index 73ae368f5c..0e65807549 100644 --- a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jdbc/ConfigurableDataSourceExampleTests.java +++ b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jdbc/ConfigurableDataSourceExampleTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jdbc/SampleApp.java b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jdbc/SampleApp.java index fb228f18f0..a78044ec1b 100644 --- a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jdbc/SampleApp.java +++ b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jdbc/SampleApp.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jdbc/SimpleDataSourceExampleTests.java b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jdbc/SimpleDataSourceExampleTests.java index 16bfb73126..a2b5a534c0 100644 --- a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jdbc/SimpleDataSourceExampleTests.java +++ b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jdbc/SimpleDataSourceExampleTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/test/spock/SpockTestRestTemplateExampleTests.java b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/test/spock/SpockTestRestTemplateExampleTests.java index 0a7c381a6a..5edc44e6e2 100644 --- a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/test/spock/SpockTestRestTemplateExampleTests.java +++ b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/test/spock/SpockTestRestTemplateExampleTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationBeanFactoryMetadata.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationBeanFactoryMetadata.java index 8ab2229aa2..a11832d251 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationBeanFactoryMetadata.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationBeanFactoryMetadata.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesBindingPostProcessorRegistrar.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesBindingPostProcessorRegistrar.java index c21b418635..0446ce91fc 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesBindingPostProcessorRegistrar.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesBindingPostProcessorRegistrar.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/JavaBeanBinder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/JavaBeanBinder.java index c61ba3f0a2..fc6a54eaa1 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/JavaBeanBinder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/JavaBeanBinder.java @@ -127,27 +127,25 @@ class JavaBeanBinder implements BeanBinder { int parameterCount = method.getParameterCount(); if (name.startsWith("get") && parameterCount == 0) { name = Introspector.decapitalize(name.substring(3)); - this.properties - .computeIfAbsent(name, - (n) -> new BeanProperty(n, this.resolvableType)) + this.properties.computeIfAbsent(name, this::getBeanProperty) .addGetter(method); } else if (name.startsWith("is") && parameterCount == 0) { name = Introspector.decapitalize(name.substring(2)); - this.properties - .computeIfAbsent(name, - (n) -> new BeanProperty(n, this.resolvableType)) + this.properties.computeIfAbsent(name, this::getBeanProperty) .addGetter(method); } else if (name.startsWith("set") && parameterCount == 1) { name = Introspector.decapitalize(name.substring(3)); - this.properties - .computeIfAbsent(name, - (n) -> new BeanProperty(n, this.resolvableType)) + this.properties.computeIfAbsent(name, this::getBeanProperty) .addSetter(method); } } + private BeanProperty getBeanProperty(String name) { + return new BeanProperty(name, this.resolvableType); + } + private void addField(Field field) { BeanProperty property = this.properties.get(field.getName()); if (property != null) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationHome.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationHome.java index 05e3e5ddea..216c78e772 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationHome.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationHome.java @@ -107,8 +107,7 @@ public class ApplicationHome { try { StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace(); for (int i = stackTrace.length - 1; i >= 0; i--) { - StackTraceElement element = stackTrace[i]; - if (element.getClassName().startsWith("org.junit.")) { + if (stackTrace[i].getClassName().startsWith("org.junit.")) { return true; } } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/BinderTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/BinderTests.java index 711b7c029f..00f99e2393 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/BinderTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/BinderTests.java @@ -370,6 +370,7 @@ public class BinderTests { public void setBar(T bar) { this.bar = bar; } + } } diff --git a/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ManagementPortSampleActuatorApplicationTests.java b/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ManagementPortSampleActuatorApplicationTests.java index 6796b3154d..566e79c4b0 100644 --- a/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ManagementPortSampleActuatorApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ManagementPortSampleActuatorApplicationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-samples/spring-boot-sample-kafka/pom.xml b/spring-boot-samples/spring-boot-sample-kafka/pom.xml index e0d3ca2717..d902964c70 100644 --- a/spring-boot-samples/spring-boot-sample-kafka/pom.xml +++ b/spring-boot-samples/spring-boot-sample-kafka/pom.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 @@ -11,11 +11,9 @@ spring-boot-sample-kafka Spring Boot Kafka Sample Spring Boot Kafka Sample - ${basedir}/../.. - @@ -38,7 +36,6 @@ test - diff --git a/spring-boot-samples/spring-boot-sample-kafka/src/main/java/sample/kafka/Consumer.java b/spring-boot-samples/spring-boot-sample-kafka/src/main/java/sample/kafka/Consumer.java index a18227b40a..324351dd7f 100644 --- a/spring-boot-samples/spring-boot-sample-kafka/src/main/java/sample/kafka/Consumer.java +++ b/spring-boot-samples/spring-boot-sample-kafka/src/main/java/sample/kafka/Consumer.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package sample.kafka; import org.springframework.kafka.annotation.KafkaListener; @@ -26,4 +27,4 @@ class Consumer { System.out.println("Received sample message [" + message + "]"); } -} \ No newline at end of file +} diff --git a/spring-boot-samples/spring-boot-sample-kafka/src/main/java/sample/kafka/Producer.java b/spring-boot-samples/spring-boot-sample-kafka/src/main/java/sample/kafka/Producer.java index 3297bb4780..dba72cbde4 100644 --- a/spring-boot-samples/spring-boot-sample-kafka/src/main/java/sample/kafka/Producer.java +++ b/spring-boot-samples/spring-boot-sample-kafka/src/main/java/sample/kafka/Producer.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package sample.kafka; import org.springframework.kafka.core.KafkaTemplate; @@ -32,4 +33,4 @@ public class Producer { System.out.println("Sent sample message [" + message + "]"); } -} \ No newline at end of file +} diff --git a/spring-boot-samples/spring-boot-sample-kafka/src/main/java/sample/kafka/SampleKafkaApplication.java b/spring-boot-samples/spring-boot-sample-kafka/src/main/java/sample/kafka/SampleKafkaApplication.java index 00e677b1f6..3897ddfe9b 100644 --- a/spring-boot-samples/spring-boot-sample-kafka/src/main/java/sample/kafka/SampleKafkaApplication.java +++ b/spring-boot-samples/spring-boot-sample-kafka/src/main/java/sample/kafka/SampleKafkaApplication.java @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package sample.kafka; import org.springframework.boot.ApplicationRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.context.annotation.Bean; @SpringBootApplication diff --git a/spring-boot-samples/spring-boot-sample-kafka/src/main/java/sample/kafka/SampleMessage.java b/spring-boot-samples/spring-boot-sample-kafka/src/main/java/sample/kafka/SampleMessage.java index d11cd9a4f9..0b86b02e84 100644 --- a/spring-boot-samples/spring-boot-sample-kafka/src/main/java/sample/kafka/SampleMessage.java +++ b/spring-boot-samples/spring-boot-sample-kafka/src/main/java/sample/kafka/SampleMessage.java @@ -41,11 +41,7 @@ public class SampleMessage { @Override public String toString() { - final StringBuilder sb = new StringBuilder("SampleMessage{"); - sb.append("id=").append(this.id); - sb.append(", message='").append(this.message).append('\''); - sb.append('}'); - return sb.toString(); + return "SampleMessage{id=" + this.id + ", message='" + this.message + "'}"; } } diff --git a/spring-boot-samples/spring-boot-sample-kafka/src/test/java/sample/kafka/SampleKafkaApplicationTests.java b/spring-boot-samples/spring-boot-sample-kafka/src/test/java/sample/kafka/SampleKafkaApplicationTests.java index c6364d6d7d..5348008b23 100644 --- a/spring-boot-samples/spring-boot-sample-kafka/src/test/java/sample/kafka/SampleKafkaApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-kafka/src/test/java/sample/kafka/SampleKafkaApplicationTests.java @@ -22,7 +22,6 @@ import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.TestConfiguration; import org.springframework.boot.test.rule.OutputCapture; @@ -64,11 +63,13 @@ public class SampleKafkaApplicationTests { @Bean public Consumer consumer() { return new Consumer() { + @Override public void processMessage(SampleMessage message) { super.processMessage(message); latch.countDown(); } + }; } diff --git a/spring-boot-samples/spring-boot-sample-secure-webflux/src/test/java/sample/secure/webflux/SampleSecureWebFluxApplicationTests.java b/spring-boot-samples/spring-boot-sample-secure-webflux/src/test/java/sample/secure/webflux/SampleSecureWebFluxApplicationTests.java index e04b872740..bc8b2311d6 100644 --- a/spring-boot-samples/spring-boot-sample-secure-webflux/src/test/java/sample/secure/webflux/SampleSecureWebFluxApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-secure-webflux/src/test/java/sample/secure/webflux/SampleSecureWebFluxApplicationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-samples/spring-boot-sample-test/src/test/java/sample/test/web/UserVehicleControllerTests.java b/spring-boot-samples/spring-boot-sample-test/src/test/java/sample/test/web/UserVehicleControllerTests.java index 1c8697828e..752a1e856f 100644 --- a/spring-boot-samples/spring-boot-sample-test/src/test/java/sample/test/web/UserVehicleControllerTests.java +++ b/spring-boot-samples/spring-boot-sample-test/src/test/java/sample/test/web/UserVehicleControllerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2018 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.