public static interface WebTestClient.Builder
WebClient used to test with,
internally delegating to a
WebClient.Builder.| Modifier and Type | Method and Description |
|---|---|
WebTestClient.Builder |
apply(WebTestClientConfigurer configurer)
Apply the given configurer to this builder instance.
|
WebTestClient.Builder |
baseUrl(String baseUrl)
Configure a base URI as described in
WebClient.create(String). |
WebTestClient |
build()
Build the
WebTestClient instance. |
WebTestClient.Builder |
defaultCookie(String cookieName,
String... cookieValues)
Add the given header to all requests that haven't added it.
|
WebTestClient.Builder |
defaultCookies(Consumer<MultiValueMap<String,String>> cookiesConsumer)
Manipulate the default cookies with the given consumer.
|
WebTestClient.Builder |
defaultHeader(String headerName,
String... headerValues)
Add the given header to all requests that haven't added it.
|
WebTestClient.Builder |
defaultHeaders(Consumer<HttpHeaders> headersConsumer)
Manipulate the default headers with the given consumer.
|
WebTestClient.Builder |
exchangeStrategies(Consumer<ExchangeStrategies.Builder> configurer)
Customize the strategies configured via
exchangeStrategies(ExchangeStrategies). |
WebTestClient.Builder |
exchangeStrategies(ExchangeStrategies strategies)
Configure the
ExchangeStrategies to use. |
WebTestClient.Builder |
filter(ExchangeFilterFunction filter)
Add the given filter to the filter chain.
|
WebTestClient.Builder |
filters(Consumer<List<ExchangeFilterFunction>> filtersConsumer)
Manipulate the filters with the given consumer.
|
WebTestClient.Builder |
responseTimeout(Duration timeout)
Max amount of time to wait for responses.
|
WebTestClient.Builder |
uriBuilderFactory(UriBuilderFactory uriBuilderFactory)
Provide a pre-configured
UriBuilderFactory instance as an
alternative to and effectively overriding baseUrl(String). |
WebTestClient.Builder baseUrl(String baseUrl)
WebClient.create(String).WebTestClient.Builder uriBuilderFactory(UriBuilderFactory uriBuilderFactory)
UriBuilderFactory instance as an
alternative to and effectively overriding baseUrl(String).WebTestClient.Builder defaultHeader(String headerName, String... headerValues)
headerName - the header nameheaderValues - the header valuesWebTestClient.Builder defaultHeaders(Consumer<HttpHeaders> headersConsumer)
HttpHeaders methods.headersConsumer - a function that consumes the HttpHeadersWebTestClient.Builder defaultCookie(String cookieName, String... cookieValues)
cookieName - the cookie namecookieValues - the cookie valuesWebTestClient.Builder defaultCookies(Consumer<MultiValueMap<String,String>> cookiesConsumer)
MultiValueMap methods.cookiesConsumer - a function that consumes the cookies mapWebTestClient.Builder filter(ExchangeFilterFunction filter)
filter - the filter to be added to the chainWebTestClient.Builder filters(Consumer<List<ExchangeFilterFunction>> filtersConsumer)
filtersConsumer - a function that consumes the filter listWebTestClient.Builder exchangeStrategies(ExchangeStrategies strategies)
ExchangeStrategies to use.
Note that in a scenario where the builder is configured by
multiple parties, it is preferable to use
exchangeStrategies(Consumer) in order to customize the same
ExchangeStrategies. This method here sets the strategies that
everyone else then can customize.
By default this is ExchangeStrategies.withDefaults().
strategies - the strategies to useWebTestClient.Builder exchangeStrategies(Consumer<ExchangeStrategies.Builder> configurer)
exchangeStrategies(ExchangeStrategies). This method is
designed for use in scenarios where multiple parties wish to update
the ExchangeStrategies.WebTestClient.Builder responseTimeout(Duration timeout)
By default 5 seconds.
timeout - the response timeout valueWebTestClient.Builder apply(WebTestClientConfigurer configurer)
This can be useful for applying pre-packaged customizations.
configurer - the configurer to applyWebTestClient build()
WebTestClient instance.