Class ExchangeResult
java.lang.Object
org.springframework.test.web.reactive.server.ExchangeResult
- Direct Known Subclasses:
EntityExchangeResult,FluxExchangeResult
Container for request and response details for exchanges performed through
WebTestClient.
Note that a decoded response body is not exposed at this level since the
body may not have been decoded and consumed yet. Subtypes
EntityExchangeResult and FluxExchangeResult provide access
to a decoded response entity and a decoded (but not consumed) response body
respectively.
- Since:
- 5.0
- Author:
- Rossen Stoyanchev, Sam Brannen
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidassertWithDiagnostics(Runnable assertion) Execute the given Runnable, catch anyAssertionError, log details about the request and response at ERROR level under the class log category, and after that re-throw the error.org.springframework.http.HttpMethodReturn the method of the request.Return the result from the mock server exchange, if applicable, for further assertions on the state of the server response.intDeprecated, for removal: This API element is subject to removal in a future version.byte[]Return the raw request body content written through the request.org.springframework.http.HttpHeadersReturn the request headers sent to the server.byte[]Return the raw request body content written to the response.org.springframework.util.MultiValueMap<String,org.springframework.http.ResponseCookie> Return response cookies received from the server.org.springframework.http.HttpHeadersReturn the response headers received from the server.org.springframework.http.HttpStatusCodeReturn the HTTP status code as anHttpStatusCodevalue.Return the original URI template used to prepare the request, if any.getUrl()Return the URI of the request.toString()
-
Method Details
-
getMethod
public org.springframework.http.HttpMethod getMethod()Return the method of the request. -
getUrl
Return the URI of the request. -
getUriTemplate
Return the original URI template used to prepare the request, if any. -
getRequestHeaders
public org.springframework.http.HttpHeaders getRequestHeaders()Return the request headers sent to the server. -
getRequestBodyContent
@Nullable public byte[] getRequestBodyContent()Return the raw request body content written through the request.Note: If the request content has not been consumed for any reason yet, use of this method will trigger consumption.
- Throws:
IllegalStateException- if the request body has not been fully written.
-
getStatus
public org.springframework.http.HttpStatusCode getStatus()Return the HTTP status code as anHttpStatusCodevalue. -
getRawStatusCode
Deprecated, for removal: This API element is subject to removal in a future version.in favor ofgetStatus(), for removal in 7.0Return the HTTP status code as an integer.- Since:
- 5.1.10
-
getResponseHeaders
public org.springframework.http.HttpHeaders getResponseHeaders()Return the response headers received from the server. -
getResponseCookies
public org.springframework.util.MultiValueMap<String,org.springframework.http.ResponseCookie> getResponseCookies()Return response cookies received from the server. -
getResponseBodyContent
@Nullable public byte[] getResponseBodyContent()Return the raw request body content written to the response.Note: If the response content has not been consumed yet, use of this method will trigger consumption.
- Throws:
IllegalStateException- if the response has not been fully read.
-
getMockServerResult
Return the result from the mock server exchange, if applicable, for further assertions on the state of the server response.- Since:
- 5.3
- See Also:
-
assertWithDiagnostics
Execute the given Runnable, catch anyAssertionError, log details about the request and response at ERROR level under the class log category, and after that re-throw the error. -
toString
-
getStatus(), for removal in 7.0