mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Polish
Closes gh-6155
This commit is contained in:
parent
ed96d142b8
commit
a70a8635f9
@ -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");
|
||||
}
|
||||
|
||||
|
@ -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";
|
||||
|
||||
|
@ -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 {
|
||||
|
||||
|
@ -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
|
||||
|
@ -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) {
|
||||
|
@ -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("");
|
||||
}
|
||||
|
||||
|
@ -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");
|
||||
|
Loading…
Reference in New Issue
Block a user