Support customization of WebTestClient.Builder when using @SpringBootTest

Closes gh-15132
This commit is contained in:
Andy Wilkinson
2019-09-23 12:45:16 +01:00
parent 100fc8cf2c
commit 96f85a40de
7 changed files with 74 additions and 7 deletions

View File

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