public interface WebTestClient
WebClient
, and actually delegating to a WebClient
instance, but with a focus on testing.
The WebTestClient
has 3 setup options without a running server:
bindToController(java.lang.Object...)
bindToApplicationContext(org.springframework.context.ApplicationContext)
bindToRouterFunction(org.springframework.web.reactive.function.server.RouterFunction<?>)
and 1 option for actual requests on a socket:
Modifier and Type | Interface and Description |
---|---|
static interface |
WebTestClient.BodySpec
Specification to apply additional assertions on the response body.
|
static interface |
WebTestClient.Builder
Steps for customizing the
WebClient used to test with
internally delegating to a WebClient.Builder . |
static interface |
WebTestClient.ControllerSpec
Specification for customizing controller configuration equivalent to, and
internally delegating to, a
WebFluxConfigurer . |
static interface |
WebTestClient.HeaderSpec
Specification for adding request headers and performing an exchange.
|
static interface |
WebTestClient.ListBodySpec
Specification to assert a list of values extracted from the response.
|
static interface |
WebTestClient.MapBodySpec
Specification to assert response the body extracted as a map.
|
static interface |
WebTestClient.ResponseSpec
Specification for processing the response and applying expectations.
|
static interface |
WebTestClient.SingleValueBodySpec
Specification to assert a single value extracted from the response body.
|
static interface |
WebTestClient.TypeBodySpec
Specification for extracting entities from the response body.
|
static interface |
WebTestClient.UriSpec
Specification for providing the URI of a request.
|
Modifier and Type | Method and Description |
---|---|
static WebTestClient.Builder |
bindToApplicationContext(ApplicationContext applicationContext)
Integration testing without a server, with WebFlux infrastructure detected
from an
ApplicationContext such as @EnableWebFlux
Java config and annotated controller Spring beans. |
static WebTestClient.ControllerSpec |
bindToController(java.lang.Object... controllers)
Integration testing without a server, targeting specific annotated,
WebFlux controllers.
|
static WebTestClient.Builder |
bindToRouterFunction(RouterFunction<?> routerFunction)
Integration testing without a server, targeting WebFlux functional endpoints.
|
static WebTestClient.Builder |
bindToServer()
Complete end-to-end integration tests with actual requests to a running server.
|
WebTestClient.UriSpec |
delete()
Prepare an HTTP DELETE request.
|
WebTestClient |
filter(ExchangeFilterFunction filterFunction)
Filter the client with the given
ExchangeFilterFunction . |
WebTestClient.UriSpec |
get()
Prepare an HTTP GET request.
|
WebTestClient.UriSpec |
head()
Prepare an HTTP HEAD request.
|
WebTestClient.UriSpec |
options()
Prepare an HTTP OPTIONS request.
|
WebTestClient.UriSpec |
patch()
Prepare an HTTP PATCH request.
|
WebTestClient.UriSpec |
post()
Prepare an HTTP POST request.
|
WebTestClient.UriSpec |
put()
Prepare an HTTP PUT request.
|
WebTestClient.UriSpec get()
WebTestClient.UriSpec head()
WebTestClient.UriSpec post()
WebTestClient.UriSpec put()
WebTestClient.UriSpec patch()
WebTestClient.UriSpec delete()
WebTestClient.UriSpec options()
WebTestClient filter(ExchangeFilterFunction filterFunction)
ExchangeFilterFunction
.filterFunction
- the filter to apply to this clientExchangeFilterFunction.apply(ExchangeFunction)
static WebTestClient.ControllerSpec bindToController(java.lang.Object... controllers)
@EnableWebFlux
but can also be further customized through the returned spec.controllers
- the controllers to teststatic WebTestClient.Builder bindToApplicationContext(ApplicationContext applicationContext)
ApplicationContext
such as @EnableWebFlux
Java config and annotated controller Spring beans.applicationContext
- the contextWebTestClient
builderEnableWebFlux
static WebTestClient.Builder bindToRouterFunction(RouterFunction<?> routerFunction)
routerFunction
- the RouterFunction to testWebTestClient
builderstatic WebTestClient.Builder bindToServer()
WebTestClient
builder