Support customization of WebTestClient.Builder when using @SpringBootTest
Closes gh-15132
This commit is contained in:
@@ -33,6 +33,11 @@ import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||
import org.springframework.http.server.reactive.ServerHttpResponse;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient.Builder;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Integration test for {@link WebTestClientContextCustomizer}.
|
||||
@@ -46,8 +51,12 @@ class WebTestClientContextCustomizerIntegrationTests {
|
||||
@Autowired
|
||||
private WebTestClient webTestClient;
|
||||
|
||||
@Autowired
|
||||
private WebTestClientBuilderCustomizer clientBuilderCustomizer;
|
||||
|
||||
@Test
|
||||
void test() {
|
||||
verify(this.clientBuilderCustomizer).customize(any(Builder.class));
|
||||
this.webTestClient.get().uri("/").exchange().expectBody(String.class).isEqualTo("hello");
|
||||
}
|
||||
|
||||
@@ -60,6 +69,11 @@ class WebTestClientContextCustomizerIntegrationTests {
|
||||
return new TomcatReactiveWebServerFactory(0);
|
||||
}
|
||||
|
||||
@Bean
|
||||
WebTestClientBuilderCustomizer clientBuilderCustomizer() {
|
||||
return mock(WebTestClientBuilderCustomizer.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static class TestHandler implements HttpHandler {
|
||||
|
||||
Reference in New Issue
Block a user