类 ExchangeResult
- java.lang.Object
- org.springframework.test.web.reactive.server.ExchangeResult
public class ExchangeResult extends Object
Container for request and response details for exchanges performed throughWebTestClient.Note that a decoded response body is not exposed at this level since the body may not have been decoded and consumed yet. Sub-types
EntityExchangeResultandFluxExchangeResultprovide access to a decoded response entity and a decoded (but not consumed) response body respectively.- 从以下版本开始:
- 5.0
- 作者:
- Rossen Stoyanchev
- 另请参阅:
EntityExchangeResult,FluxExchangeResult
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 voidassertWithDiagnostics(Runnable assertion)Execute the given Runnable, catch anyAssertionError, decorate withAssertionErrorcontaining diagnostic information about the request and response, and then re-throw.HttpMethodgetMethod()Return the method of the request.intgetRawStatusCode()Return the HTTP status code (potentially non-standard and not resolvable through theHttpStatusenum) as an integer.byte[]getRequestBodyContent()Return the raw request body content written through the request.HttpHeadersgetRequestHeaders()Return the request headers sent to the server.byte[]getResponseBodyContent()Return the raw request body content written to the response.MultiValueMap<String,ResponseCookie>getResponseCookies()Return response cookies received from the server.HttpHeadersgetResponseHeaders()Return the response headers received from the server.HttpStatusgetStatus()Return the HTTP status code as anHttpStatusenum value.StringgetUriTemplate()Return the original URI template used to prepare the request, if any.URIgetUrl()Return the URI of the request.StringtoString()
方法详细资料
getMethod
public HttpMethod getMethod()
Return the method of the request.
getUriTemplate
@Nullable public String getUriTemplate()
Return the original URI template used to prepare the request, if any.
getRequestHeaders
public 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.
- 抛出:
IllegalStateException- if the request body is not been fully written.
getStatus
public HttpStatus getStatus()
Return the HTTP status code as anHttpStatusenum value.
getRawStatusCode
public int getRawStatusCode()
Return the HTTP status code (potentially non-standard and not resolvable through theHttpStatusenum) as an integer.- 从以下版本开始:
- 5.1.10
getResponseHeaders
public HttpHeaders getResponseHeaders()
Return the response headers received from the server.
getResponseCookies
public MultiValueMap<String,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.
- 抛出:
IllegalStateException- if the response is not been fully read.
assertWithDiagnostics
public void assertWithDiagnostics(Runnable assertion)
Execute the given Runnable, catch anyAssertionError, decorate withAssertionErrorcontaining diagnostic information about the request and response, and then re-throw.