diff --git a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/utilities/testresttemplate/MySpringBootTests.java b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/utilities/testresttemplate/MySpringBootTests.java index 305b1a476c7..4abeb71040d 100644 --- a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/utilities/testresttemplate/MySpringBootTests.java +++ b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/utilities/testresttemplate/MySpringBootTests.java @@ -28,7 +28,8 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.context.TestConfiguration; import org.springframework.context.annotation.Bean; -import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; import static org.assertj.core.api.Assertions.assertThat; @@ -41,8 +42,9 @@ class MySpringBootTests { @Test void testRequest() { - HttpHeaders headers = this.template.getForEntity("/example", String.class).getHeaders(); - assertThat(headers.getLocation()).hasHost("other.example.com"); + ResponseEntity response = this.template.getForEntity("/example", String.class); + assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); + // Other assertions to verify the response } @TestConfiguration(proxyBeanMethods = false) diff --git a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/utilities/testresttemplate/MyTests.java b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/utilities/testresttemplate/MyTests.java index 932030b2e56..793b283fe7b 100644 --- a/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/utilities/testresttemplate/MyTests.java +++ b/documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/utilities/testresttemplate/MyTests.java @@ -19,6 +19,7 @@ package org.springframework.boot.docs.testing.utilities.testresttemplate; import org.junit.jupiter.api.Test; import org.springframework.boot.resttestclient.TestRestTemplate; +import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import static org.assertj.core.api.Assertions.assertThat; @@ -29,8 +30,10 @@ class MyTests { @Test void testRequest() { - ResponseEntity headers = this.template.getForEntity("https://myhost.example.com/example", String.class); - assertThat(headers.getHeaders().getLocation()).hasHost("other.example.com"); + ResponseEntity response = this.template.getForEntity("https://myhost.example.com/example", + String.class); + assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); + // Other assertions to verify the response } } diff --git a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/utilities/testresttemplate/MySpringBootTests.kt b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/utilities/testresttemplate/MySpringBootTests.kt index 6a25710ca43..ed212753bee 100644 --- a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/utilities/testresttemplate/MySpringBootTests.kt +++ b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/utilities/testresttemplate/MySpringBootTests.kt @@ -26,6 +26,7 @@ import org.springframework.boot.restclient.RestTemplateBuilder import org.springframework.boot.resttestclient.TestRestTemplate import org.springframework.boot.resttestclient.autoconfigure.AutoConfigureTestRestTemplate import org.springframework.context.annotation.Bean +import org.springframework.http.HttpStatus import java.time.Duration @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) @@ -34,8 +35,9 @@ class MySpringBootTests(@Autowired val template: TestRestTemplate) { @Test fun testRequest() { - val headers = template.getForEntity("/example", String::class.java).headers - assertThat(headers.location).hasHost("other.example.com") + val response = template.getForEntity("/example", String::class.java) + assertThat(response.statusCode).isEqualTo(HttpStatus.OK) + // Other assertions to verify the response } @TestConfiguration(proxyBeanMethods = false) diff --git a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/utilities/testresttemplate/MyTests.kt b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/utilities/testresttemplate/MyTests.kt index bedcf12d034..f7a1a9e1668 100644 --- a/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/utilities/testresttemplate/MyTests.kt +++ b/documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/utilities/testresttemplate/MyTests.kt @@ -19,6 +19,7 @@ package org.springframework.boot.docs.testing.utilities.testresttemplate import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.springframework.boot.resttestclient.TestRestTemplate +import org.springframework.http.HttpStatus class MyTests { @@ -26,8 +27,9 @@ class MyTests { @Test fun testRequest() { - val headers = template.getForEntity("https://myhost.example.com/example", String::class.java) - assertThat(headers.headers.location).hasHost("other.example.com") + val response = template.getForEntity("https://myhost.example.com/example", String::class.java) + assertThat(response.statusCode).isEqualTo(HttpStatus.OK) + // Other assertions to verify the response } }