Browse Source

Merge branch '3.5.x'

Closes gh-48336
pull/46766/merge
Stéphane Nicoll 3 weeks ago
parent
commit
811ddcd1b8
  1. 8
      documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/utilities/testresttemplate/MySpringBootTests.java
  2. 7
      documentation/spring-boot-docs/src/main/java/org/springframework/boot/docs/testing/utilities/testresttemplate/MyTests.java
  3. 6
      documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/utilities/testresttemplate/MySpringBootTests.kt
  4. 6
      documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/testing/utilities/testresttemplate/MyTests.kt

8
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; @@ -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 { @@ -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)

7
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; @@ -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 { @@ -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
}
}

6
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 @@ -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) { @@ -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)

6
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 @@ -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 { @@ -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
}
}

Loading…
Cancel
Save