Skip to content

Commit e6e0db0

Browse files
committed
Polish documentation following relocation of TestRestTemplate
See gh-46356 See gh-47322
1 parent f10b80c commit e6e0db0

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/features/kotlin.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ runApplication<MyApplication>(*args) {
8686
Kotlin {url-kotlin-docs}/extensions.html[extensions] provide the ability to extend existing classes with additional functionality.
8787
The Spring Boot Kotlin API makes use of these extensions to add new Kotlin specific conveniences to existing APIs.
8888

89-
javadoc:org.springframework.boot.test.web.client.TestRestTemplate[] extensions, similar to those provided by Spring Framework for javadoc:org.springframework.web.client.RestOperations[] in Spring Framework, are provided.
89+
javadoc:org.springframework.boot.resttestclient.TestRestTemplate[] extensions, similar to those provided by Spring Framework for javadoc:org.springframework.web.client.RestOperations[] in Spring Framework, are provided.
9090
Among other things, the extensions make it possible to take advantage of Kotlin reified type parameters.
9191

9292

documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/testing/spring-boot-applications.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ include-code::MyRandomPortWebTestClientTests[]
189189

190190
TIP: javadoc:org.springframework.test.web.reactive.server.WebTestClient[] can also used with a xref:testing/spring-boot-applications.adoc#testing.spring-boot-applications.with-mock-environment[mock environment], removing the need for a running server, by annotating your test class with javadoc:org.springframework.boot.webflux.test.autoconfigure.AutoConfigureWebTestClient[format=annotation] from `spring-boot-webflux-test`.
191191

192-
The `spring-boot-retclient-test` modules also provides a javadoc:org.springframework.boot.restclient.test.TestRestTemplate[] facility:
192+
The `spring-boot-resttestclient` modules also provides a javadoc:org.springframework.boot.resttestclient.TestRestTemplate[] facility:
193193

194194
include-code::MyRandomPortTestRestTemplateTests[]
195195

documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/testing/test-utilities.adoc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ include-code::MyOutputCaptureTests[]
4242
[[testing.utilities.test-rest-template]]
4343
== TestRestTemplate
4444

45-
javadoc:org.springframework.boot.test.web.client.TestRestTemplate[] is a convenience alternative to Spring's javadoc:org.springframework.web.client.RestTemplate[] that is useful in integration tests.
46-
It's provided by the `spring-boot-restclient-test` module.
45+
javadoc:org.springframework.boot.resttestclient.TestRestTemplate[] is a convenience alternative to Spring's javadoc:org.springframework.web.client.RestTemplate[] that is useful in integration tests.
46+
It's provided by the `spring-boot-resttestclient` module.
4747

4848
You can get a vanilla template or one that sends Basic HTTP authentication (with a username and password).
4949
In either case, the template is fault tolerant.
@@ -55,14 +55,14 @@ If you need fluent API for assertions, consider using javadoc:org.springframewor
5555
If you are using Spring WebFlux, consider the javadoc:org.springframework.test.web.reactive.server.WebTestClient[] that provides a similar API and works with xref:testing/spring-boot-applications.adoc#testing.spring-boot-applications.with-mock-environment[mock environments], xref:testing/spring-boot-applications.adoc#testing.spring-boot-applications.spring-webflux-tests[WebFlux integration tests], and xref:testing/spring-boot-applications.adoc#testing.spring-boot-applications.with-running-server[end-to-end tests].
5656

5757
It is recommended, but not mandatory, to use the Apache HTTP Client (version 5.1 or better).
58-
If you have that on your classpath, the javadoc:org.springframework.boot.test.web.client.TestRestTemplate[] responds by configuring the client appropriately.
58+
If you have that on your classpath, the javadoc:org.springframework.boot.resttestclient.TestRestTemplate[] responds by configuring the client appropriately.
5959
If you do use Apache's HTTP client it is configured to ignore cookies (so the template is stateless).
6060

61-
javadoc:org.springframework.boot.test.web.client.TestRestTemplate[] can be instantiated directly in your integration tests, as shown in the following example:
61+
javadoc:org.springframework.boot.resttestclient.TestRestTemplate[] can be instantiated directly in your integration tests, as shown in the following example:
6262

6363
include-code::MyTests[]
6464

65-
Alternatively, if you use the javadoc:org.springframework.boot.test.context.SpringBootTest[format=annotation] annotation with `WebEnvironment.RANDOM_PORT` or `WebEnvironment.DEFINED_PORT`, you can inject a fully configured javadoc:org.springframework.boot.test.web.client.TestRestTemplate[] and start using it.
65+
Alternatively, if you use the javadoc:org.springframework.boot.test.context.SpringBootTest[format=annotation] annotation with `WebEnvironment.RANDOM_PORT` or `WebEnvironment.DEFINED_PORT`, you can inject a fully configured javadoc:org.springframework.boot.resttestclient.TestRestTemplate[] and start using it.
6666
If necessary, additional customizations can be applied through the javadoc:org.springframework.boot.web.client.RestTemplateBuilder[] bean.
6767
Any URLs that do not specify a host and port automatically connect to the embedded server, as shown in the following example:
6868

module/spring-boot-resttestclient/src/main/java/org/springframework/boot/resttestclient/TestRestTemplate.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import org.springframework.boot.http.client.HttpRedirects;
4545
import org.springframework.boot.restclient.RestTemplateBuilder;
4646
import org.springframework.boot.restclient.RootUriTemplateHandler;
47+
import org.springframework.boot.resttestclient.autoconfigure.AutoConfigureTestRestTemplate;
4748
import org.springframework.boot.ssl.SslBundle;
4849
import org.springframework.core.ParameterizedTypeReference;
4950
import org.springframework.http.HttpEntity;
@@ -77,9 +78,11 @@
7778
* {@link #getRestTemplate()}.
7879
* <p>
7980
* If you are using the {@code @SpringBootTest} annotation with an embedded server, a
80-
* {@link TestRestTemplate} is automatically available and can be {@code @Autowired} into
81-
* your test. If you need customizations (for example to adding additional message
82-
* converters) use a {@link RestTemplateBuilder} {@code @Bean}.
81+
* {@link TestRestTemplate} can be auto-configured by adding
82+
* {@link AutoConfigureTestRestTemplate @AutoConfigureTestRestTemplate} to your test
83+
* class. It can then be {@code @Autowired} into your test. If you need customizations
84+
* (for example to adding additional message converters) use a {@link RestTemplateBuilder}
85+
* {@code @Bean}.
8386
*
8487
* @author Dave Syer
8588
* @author Phillip Webb

0 commit comments

Comments
 (0)