From a70a8635f93b6bdfb99bcbcadec6c0118edc9d01 Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Tue, 14 Jun 2016 14:12:51 +0900 Subject: [PATCH] Polish Closes gh-6155 --- .../src/main/asciidoc/spring-boot-features.adoc | 10 +++++----- .../AnnotationsPropertySourceTests.java | 4 +--- .../test/mock/mockito/MockitoPostProcessor.java | 4 ++-- .../boot/web/client/RestTemplateBuilder.java | 8 ++++---- .../boot/web/client/RootUriTemplateHandler.java | 6 +++--- .../BasicAuthorizationInterceptorTests.java | 2 +- .../web/client/RestTemplateBuilderTests.java | 16 ++++------------ 7 files changed, 20 insertions(+), 30 deletions(-) diff --git a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc index 83510926000..e8bf1062b57 100644 --- a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -4253,7 +4253,7 @@ reached. [[boot-features-restclient]] == Calling REST services If you need to call remote REST services from your application, you can use Spring -Framework's `RestTemplate` class. Since `RestTemplate` instances often needs to be +Framework's `RestTemplate` class. Since `RestTemplate` instances often need to be customized before being used, Spring Boot does not provide any single auto-configured `RestTemplate` bean. It does, however, auto-configure a `RestTemplateBuilder` which can be used to create `RestTemplate` instances when needed. The auto-configured @@ -4273,7 +4273,7 @@ Here's a typical example: this.restTemplate = restTemplateBuilder.build(); } - public String someRestCall(String name) { + public Details someRestCall(String name) { return this.restTemplate.getForObject("/{name}/details", Details.class, name); } @@ -5035,7 +5035,7 @@ database you can use the `@AutoConfigureTestDatabase` annotation: [[boot-features-testing-spring-boot-applications-testing-autoconfigured-rest-client]] ==== Auto-configured REST clients Use `@RestClientTest` annotation can be used if you want to test REST clients. By default -it will auto configure Jackson and GSON support, configure a `RestTemplateBuilder` and +it will auto-configure Jackson and GSON support, configure a `RestTemplateBuilder` and add support for `MockRestServiceServer`. The specific beans that you want to test should be specified using `value` or `components` attribute of `@RestClientTest`: @@ -5047,7 +5047,7 @@ be specified using `value` or `components` attribute of `@RestClientTest`: public class ExampleRestClientTest { @Autowired - private MyService service; + private RemoteVehicleDetailsService service; @Autowired private MockRestServiceServer server; @@ -5057,7 +5057,7 @@ be specified using `value` or `components` attribute of `@RestClientTest`: throws Exception { this.server.expect(requestTo("/greet/details")) .andRespond(withSuccess("hello", MediaType.TEXT_PLAIN)); - String greeting = this.service.callRestService(); + String greeting = this.service.callRestService(); assertThat(greeting).isEqualTo("hello"); } diff --git a/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/properties/AnnotationsPropertySourceTests.java b/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/properties/AnnotationsPropertySourceTests.java index 62b4ba334f7..1b1cc96c849 100644 --- a/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/properties/AnnotationsPropertySourceTests.java +++ b/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/properties/AnnotationsPropertySourceTests.java @@ -348,9 +348,7 @@ public class AnnotationsPropertySourceTests { static @interface AttributeWithAliasAnnotation { @AliasFor(annotation = AliasedAttributeAnnotation.class, attribute = "value") - String value() - - default "foo"; + String value() default "foo"; String someOtherAttribute() default "shouldNotBeMapped"; diff --git a/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockitoPostProcessor.java b/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockitoPostProcessor.java index a46821d9b91..2109be3791e 100644 --- a/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockitoPostProcessor.java +++ b/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockitoPostProcessor.java @@ -416,7 +416,7 @@ public class MockitoPostProcessor extends InstantiationAwareBeanPostProcessorAda /** * {@link BeanPostProcessor} to handle {@link SpyBean} definitions. Registered as a - * separate processor so that it can ordered above AOP post processors. + * separate processor so that it can be ordered above AOP post processors. */ static class SpyPostProcessor extends InstantiationAwareBeanPostProcessorAdapter implements PriorityOrdered { @@ -466,7 +466,7 @@ public class MockitoPostProcessor extends InstantiationAwareBeanPostProcessorAda } /** - * An registered field item. + * A registered field item. */ private static class RegisteredField { diff --git a/spring-boot/src/main/java/org/springframework/boot/web/client/RestTemplateBuilder.java b/spring-boot/src/main/java/org/springframework/boot/web/client/RestTemplateBuilder.java index d93dd5daaf6..e2cf15540a9 100644 --- a/spring-boot/src/main/java/org/springframework/boot/web/client/RestTemplateBuilder.java +++ b/spring-boot/src/main/java/org/springframework/boot/web/client/RestTemplateBuilder.java @@ -285,7 +285,7 @@ public class RestTemplateBuilder { } /** - * Set the {@link HttpMessageConverter HttpMessageConverters} that should be applied + * Set the {@link RestTemplateCustomizer RestTemplateCustomizers} that should be applied * to the {@link RestTemplate}. Customizers are applied in the order that they were * added after builder configuration has been applied. Setting this value will replace * any previously configured customizers. @@ -301,7 +301,7 @@ public class RestTemplateBuilder { } /** - * Set the {@link HttpMessageConverter HttpMessageConverters} that should be applied + * Set the {@link RestTemplateCustomizer RestTemplateCustomizers} that should be applied * to the {@link RestTemplate}. Customizers are applied in the order that they were * added after builder configuration has been applied. Setting this value will replace * any previously configured customizers. @@ -321,7 +321,7 @@ public class RestTemplateBuilder { } /** - * Add {@link HttpMessageConverter HttpMessageConverters} that should be applied to + * Add {@link RestTemplateCustomizer RestTemplateCustomizers} that should be applied to * the {@link RestTemplate}. Customizers are applied in the order that they were added * after builder configuration has been applied. * @param restTemplateCustomizers the customizers to add @@ -336,7 +336,7 @@ public class RestTemplateBuilder { } /** - * Add {@link HttpMessageConverter HttpMessageConverters} that should be applied to + * Add {@link RestTemplateCustomizer RestTemplateCustomizers} that should be applied to * the {@link RestTemplate}. Customizers are applied in the order that they were added * after builder configuration has been applied. * @param customizers the customizers to add diff --git a/spring-boot/src/main/java/org/springframework/boot/web/client/RootUriTemplateHandler.java b/spring-boot/src/main/java/org/springframework/boot/web/client/RootUriTemplateHandler.java index 7d704e3863d..0defbeec782 100644 --- a/spring-boot/src/main/java/org/springframework/boot/web/client/RootUriTemplateHandler.java +++ b/spring-boot/src/main/java/org/springframework/boot/web/client/RootUriTemplateHandler.java @@ -26,7 +26,7 @@ import org.springframework.web.util.DefaultUriTemplateHandler; import org.springframework.web.util.UriTemplateHandler; /** - * {@link UriTemplateHandler} to set the root for URI that start with {@code '/'}. + * {@link UriTemplateHandler} to set the root for URI that starts with {@code '/'}. * * @author Phillip Webb * @since 1.4.0 @@ -44,7 +44,7 @@ public class RootUriTemplateHandler implements UriTemplateHandler { /** * Create a new {@link RootUriTemplateHandler} instance. - * @param rootUri the root URI to used to prefix relative URLs + * @param rootUri the root URI to be used to prefix relative URLs */ public RootUriTemplateHandler(String rootUri) { this(rootUri, new DefaultUriTemplateHandler()); @@ -52,7 +52,7 @@ public class RootUriTemplateHandler implements UriTemplateHandler { /** * Create a new {@link RootUriTemplateHandler} instance. - * @param rootUri the root URI to used to prefix relative URLs + * @param rootUri the root URI to be used to prefix relative URLs * @param handler the delegate handler */ public RootUriTemplateHandler(String rootUri, UriTemplateHandler handler) { diff --git a/spring-boot/src/test/java/org/springframework/boot/web/client/BasicAuthorizationInterceptorTests.java b/spring-boot/src/test/java/org/springframework/boot/web/client/BasicAuthorizationInterceptorTests.java index 75dc196c2db..c9536aebc02 100644 --- a/spring-boot/src/test/java/org/springframework/boot/web/client/BasicAuthorizationInterceptorTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/web/client/BasicAuthorizationInterceptorTests.java @@ -54,7 +54,7 @@ public class BasicAuthorizationInterceptorTests { @Test public void createWhenPasswordIsNullShouldUseEmptyPassword() throws Exception { BasicAuthorizationInterceptor interceptor = new BasicAuthorizationInterceptor( - "username", ""); + "username", null); assertThat(interceptor).extracting("password").containsExactly(""); } diff --git a/spring-boot/src/test/java/org/springframework/boot/web/client/RestTemplateBuilderTests.java b/spring-boot/src/test/java/org/springframework/boot/web/client/RestTemplateBuilderTests.java index 6e3166fad90..b7992d40b43 100644 --- a/spring-boot/src/test/java/org/springframework/boot/web/client/RestTemplateBuilderTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/web/client/RestTemplateBuilderTests.java @@ -264,22 +264,14 @@ public class RestTemplateBuilderTests { } @Test - public void customizersWhenNullArrayShouldThrowException() throws Exception { - this.thrown.expect(IllegalArgumentException.class); - this.thrown.expectMessage("Customizers must not be null"); - RestTemplateCustomizer[] customizers = null; - this.builder.customizers(customizers); - } - - @Test - public void customizersWhenConvertersAreNullShouldThrowException() throws Exception { + public void customizersWhenCustomizersAreNullShouldThrowException() throws Exception { this.thrown.expect(IllegalArgumentException.class); this.thrown.expectMessage("RestTemplateCustomizers must not be null"); this.builder.customizers((RestTemplateCustomizer[]) null); } @Test - public void customizersCollectionWhenConvertersAreNullShouldThrowException() + public void customizersCollectionWhenCustomizersAreNullShouldThrowException() throws Exception { this.thrown.expect(IllegalArgumentException.class); this.thrown.expectMessage("RestTemplateCustomizers must not be null"); @@ -318,7 +310,7 @@ public class RestTemplateBuilderTests { } @Test - public void additionalCustomizersWhenConvertersAreNullShouldThrowException() + public void additionalCustomizersWhenCustomizersAreNullShouldThrowException() throws Exception { this.thrown.expect(IllegalArgumentException.class); this.thrown.expectMessage("RestTemplateCustomizers must not be null"); @@ -326,7 +318,7 @@ public class RestTemplateBuilderTests { } @Test - public void additionalCustomizersCollectionWhenConvertersAreNullShouldThrowException() + public void additionalCustomizersCollectionWhenCustomizersAreNullShouldThrowException() throws Exception { this.thrown.expect(IllegalArgumentException.class); this.thrown.expectMessage("RestTemplateCustomizers must not be null");