Skip to content

Commit 811ddcd

Browse files
committed
Merge branch '3.5.x'
Closes gh-48336
2 parents c63dbe7 + 5a20176 commit 811ddcd

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed

documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/utilities/testresttemplate/MySpringBootTests.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
2929
import org.springframework.boot.test.context.TestConfiguration;
3030
import org.springframework.context.annotation.Bean;
31-
import org.springframework.http.HttpHeaders;
31+
import org.springframework.http.HttpStatus;
32+
import org.springframework.http.ResponseEntity;
3233

3334
import static org.assertj.core.api.Assertions.assertThat;
3435

@@ -41,8 +42,9 @@ class MySpringBootTests {
4142

4243
@Test
4344
void testRequest() {
44-
HttpHeaders headers = this.template.getForEntity("/example", String.class).getHeaders();
45-
assertThat(headers.getLocation()).hasHost("other.example.com");
45+
ResponseEntity<String> response = this.template.getForEntity("/example", String.class);
46+
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
47+
// Other assertions to verify the response
4648
}
4749

4850
@TestConfiguration(proxyBeanMethods = false)

documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/utilities/testresttemplate/MyTests.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.junit.jupiter.api.Test;
2020

2121
import org.springframework.boot.resttestclient.TestRestTemplate;
22+
import org.springframework.http.HttpStatus;
2223
import org.springframework.http.ResponseEntity;
2324

2425
import static org.assertj.core.api.Assertions.assertThat;
@@ -29,8 +30,10 @@ class MyTests {
2930

3031
@Test
3132
void testRequest() {
32-
ResponseEntity<String> headers = this.template.getForEntity("https://myhost.example.com/example", String.class);
33-
assertThat(headers.getHeaders().getLocation()).hasHost("other.example.com");
33+
ResponseEntity<String> response = this.template.getForEntity("https://myhost.example.com/example",
34+
String.class);
35+
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
36+
// Other assertions to verify the response
3437
}
3538

3639
}

documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/utilities/testresttemplate/MySpringBootTests.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import org.springframework.boot.restclient.RestTemplateBuilder
2626
import org.springframework.boot.resttestclient.TestRestTemplate
2727
import org.springframework.boot.resttestclient.autoconfigure.AutoConfigureTestRestTemplate
2828
import org.springframework.context.annotation.Bean
29+
import org.springframework.http.HttpStatus
2930
import java.time.Duration
3031

3132
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
@@ -34,8 +35,9 @@ class MySpringBootTests(@Autowired val template: TestRestTemplate) {
3435

3536
@Test
3637
fun testRequest() {
37-
val headers = template.getForEntity("/example", String::class.java).headers
38-
assertThat(headers.location).hasHost("other.example.com")
38+
val response = template.getForEntity("/example", String::class.java)
39+
assertThat(response.statusCode).isEqualTo(HttpStatus.OK)
40+
// Other assertions to verify the response
3941
}
4042

4143
@TestConfiguration(proxyBeanMethods = false)

documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/utilities/testresttemplate/MyTests.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,17 @@ package org.springframework.boot.docs.testing.utilities.testresttemplate
1919
import org.assertj.core.api.Assertions.assertThat
2020
import org.junit.jupiter.api.Test
2121
import org.springframework.boot.resttestclient.TestRestTemplate
22+
import org.springframework.http.HttpStatus
2223

2324
class MyTests {
2425

2526
private val template = TestRestTemplate()
2627

2728
@Test
2829
fun testRequest() {
29-
val headers = template.getForEntity("https://myhost.example.com/example", String::class.java)
30-
assertThat(headers.headers.location).hasHost("other.example.com")
30+
val response = template.getForEntity("https://myhost.example.com/example", String::class.java)
31+
assertThat(response.statusCode).isEqualTo(HttpStatus.OK)
32+
// Other assertions to verify the response
3133
}
3234

3335
}

0 commit comments

Comments
 (0)