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 |
codecs(Consumer<ClientCodecConfigurer> configurer)
|
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)
Deprecated.
as of 5.1.13 in favor of
codecs(Consumer) |
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 HttpHeaders
WebTestClient.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 codecs(Consumer<ClientCodecConfigurer> configurer)
configurer
- the configurer to applyWebTestClient.Builder exchangeStrategies(ExchangeStrategies strategies)
ExchangeStrategies
to use.
For most cases, prefer using codecs(Consumer)
which allows
customizing the codecs in the ExchangeStrategies
rather than
replace them. That ensures multiple parties can contribute to codecs
configuration.
By default this is set to ExchangeStrategies.withDefaults()
.
strategies
- the strategies to use@Deprecated WebTestClient.Builder exchangeStrategies(Consumer<ExchangeStrategies.Builder> configurer)
codecs(Consumer)
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.