Merge branch '3.5.x'

Closes gh-48336
This commit is contained in:
Stéphane Nicoll
2025-11-28 16:05:30 +01:00
4 changed files with 18 additions and 9 deletions
@@ -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<String> response = this.template.getForEntity("/example", String.class);
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
// Other assertions to verify the response
}
@TestConfiguration(proxyBeanMethods = false)
@@ -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<String> headers = this.template.getForEntity("https://myhost.example.com/example", String.class);
assertThat(headers.getHeaders().getLocation()).hasHost("other.example.com");
ResponseEntity<String> response = this.template.getForEntity("https://myhost.example.com/example",
String.class);
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
// Other assertions to verify the response
}
}
@@ -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)
@@ -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
}
}