From 5a1741e2e83516efc18aea79dc1f517863871cf6 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Tue, 23 Aug 2016 15:48:40 +0100 Subject: [PATCH] Improve documentation of when TestRestTemplate is auto-configured Closes gh-6729 --- .../src/main/asciidoc/spring-boot-features.adoc | 7 ++++--- .../springframework/boot/test/context/SpringBootTest.java | 3 ++- 2 files changed, 6 insertions(+), 4 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 6ecb8b23ddc..d810cdc8da4 100644 --- a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -5488,9 +5488,10 @@ public class MyTest { } ---- -If you are using the `@SpringBootTest` annotation, you can just inject a fully configured -`TestRestTemplate` and start using it. If necessary, additional customizations can be -applied via the `RestTemplateBuilder` bean: +If you are using the `@SpringBootTest` annotation with `WebEnvironment.RANDOM_PORT` or +`WebEnvironment.DEFINED_PORT`, you can just inject a fully configured `TestRestTemplate` +and start using it. If necessary, additional customizations can be applied via the +`RestTemplateBuilder` bean: [source,java,indent=0] ---- diff --git a/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootTest.java b/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootTest.java index 2ec896c9ef3..860564aa176 100644 --- a/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootTest.java +++ b/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootTest.java @@ -55,7 +55,8 @@ import org.springframework.web.context.WebApplicationContext; * {@link WebEnvironment#DEFINED_PORT defined} or {@link WebEnvironment#RANDOM_PORT * random} port. *
  • Registers a {@link org.springframework.boot.test.web.client.TestRestTemplate - * TestRestTemplate} bean for use in web tests.
  • + * TestRestTemplate} bean for use in web tests that are using a fully running container + * * * * @author Phillip Webb