类 ExchangeResult
java.lang.Object
cn.taketoday.test.web.reactive.server.ExchangeResult
- 直接已知子类:
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.
- 从以下版本开始:
- 4.0
- 作者:
- Rossen Stoyanchev, Sam Brannen
- 另请参阅:
-
字段概要
字段修饰符和类型字段说明private booleanEnsure single logging, e.g. for expectAll.private static final cn.taketoday.logging.Loggerprivate final Objectprivate static final List<cn.taketoday.http.MediaType>private final cn.taketoday.http.client.reactive.ClientHttpRequestprivate final reactor.core.publisher.Mono<byte[]>private final cn.taketoday.http.client.reactive.ClientHttpResponseprivate final reactor.core.publisher.Mono<byte[]>private final Durationprivate final String -
构造器概要
构造器构造器说明ExchangeResult(cn.taketoday.http.client.reactive.ClientHttpRequest request, cn.taketoday.http.client.reactive.ClientHttpResponse response, reactor.core.publisher.Mono<byte[]> requestBody, reactor.core.publisher.Mono<byte[]> responseBody, Duration timeout, String uriTemplate, Object serverResult) Create an instance with an HTTP request and response along with promises for the serialized request and response body content.ExchangeResult(ExchangeResult other) Copy constructor to use after body is decoded and/or consumed. -
方法概要
修饰符和类型方法说明voidassertWithDiagnostics(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.private StringformatBody(cn.taketoday.http.MediaType contentType, reactor.core.publisher.Mono<byte[]> body) private StringformatHeaders(cn.taketoday.http.HttpHeaders headers, String delimiter) private Stringprivate StringformatStatus(cn.taketoday.http.HttpStatusCode statusCode) cn.taketoday.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.intReturn the HTTP status code as an integer.byte[]Return the raw request body content written through the request.cn.taketoday.http.HttpHeadersReturn the request headers sent to the server.byte[]Return the raw request body content written to the response.cn.taketoday.util.MultiValueMap<String,cn.taketoday.http.ResponseCookie> Return response cookies received from the server.cn.taketoday.http.HttpHeadersReturn the response headers received from the server.cn.taketoday.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()
-
字段详细资料
-
logger
private static final cn.taketoday.logging.Logger logger -
PRINTABLE_MEDIA_TYPES
-
request
private final cn.taketoday.http.client.reactive.ClientHttpRequest request -
response
private final cn.taketoday.http.client.reactive.ClientHttpResponse response -
requestBody
private final reactor.core.publisher.Mono<byte[]> requestBody -
responseBody
private final reactor.core.publisher.Mono<byte[]> responseBody -
timeout
-
uriTemplate
-
mockServerResult
-
diagnosticsLogged
private boolean diagnosticsLoggedEnsure single logging, e.g. for expectAll.
-
-
构造器详细资料
-
ExchangeResult
ExchangeResult(cn.taketoday.http.client.reactive.ClientHttpRequest request, cn.taketoday.http.client.reactive.ClientHttpResponse response, reactor.core.publisher.Mono<byte[]> requestBody, reactor.core.publisher.Mono<byte[]> responseBody, Duration timeout, @Nullable String uriTemplate, @Nullable Object serverResult) Create an instance with an HTTP request and response along with promises for the serialized request and response body content.- 参数:
request- the HTTP requestresponse- the HTTP responserequestBody- capture of serialized request body contentresponseBody- capture of serialized response body contenttimeout- how long to wait for content to materializeuriTemplate- the URI template used to set up the request, if anyserverResult- the result of a mock server exchange if applicable.
-
ExchangeResult
ExchangeResult(ExchangeResult other) Copy constructor to use after body is decoded and/or consumed.
-
-
方法详细资料
-
getMethod
public cn.taketoday.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 cn.taketoday.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.
- 抛出:
IllegalStateException- if the request body has not been fully written.
-
getStatus
public cn.taketoday.http.HttpStatusCode getStatus()Return the HTTP status code as anHttpStatusCodevalue. -
getRawStatusCode
public int getRawStatusCode()Return the HTTP status code as an integer. -
getResponseHeaders
public cn.taketoday.http.HttpHeaders getResponseHeaders()Return the response headers received from the server. -
getResponseCookies
public cn.taketoday.util.MultiValueMap<String,cn.taketoday.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.
- 抛出:
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. -
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
-
formatStatus
-
formatHeaders
-
formatBody
@Nullable private String formatBody(@Nullable cn.taketoday.http.MediaType contentType, reactor.core.publisher.Mono<byte[]> body) -
formatMockServerResult
-