接口 WebTestClient.BodyContentSpec
- 封闭接口:
- WebTestClient
public static interface WebTestClient.BodyContentSpec
Spec for expectations on the response body content.
-
方法概要
修饰符和类型方法说明consumeWith(Consumer<EntityExchangeResult<byte[]>> consumer) Assert the response body content with the givenConsumer.isEmpty()Assert the response body is empty and return the exchange result.default WebTestClient.BodyContentSpecParse the expected and actual response content as JSON and perform a comparison verifying that they contain the same attribute-value pairs regardless of formatting with lenient checking (extensible and non-strict array ordering).Parse the expected and actual response content as JSON and perform a comparison verifying that they contain the same attribute-value pairs regardless of formatting.Access to response body assertions using a JsonPath expression to inspect a specific subset of the body.EntityExchangeResult<byte[]>Exit the chained API and return anExchangeResultwith the raw response content.Parse expected and actual response content as XML and assert that the two are "similar", i.e. they contain the same elements and attributes regardless of order.default XpathAssertionsAccess to response body assertions using an XPath expression to inspect a specific subset of the body.Access to response body assertions with specific namespaces using an XPath expression to inspect a specific subset of the body.
-
方法详细资料
-
isEmpty
EntityExchangeResult<Void> isEmpty()Assert the response body is empty and return the exchange result. -
json
Parse the expected and actual response content as JSON and perform a comparison verifying that they contain the same attribute-value pairs regardless of formatting with lenient checking (extensible and non-strict array ordering).Use of this method requires the JSONassert library to be on the classpath.
- 参数:
expectedJson- the expected JSON content- 另请参阅:
-
json
Parse the expected and actual response content as JSON and perform a comparison verifying that they contain the same attribute-value pairs regardless of formatting.Can compare in two modes, depending on the
strictparameter value:true: strict checking. Not extensible and strict array ordering.false: lenient checking. Extensible and non-strict array ordering.
Use of this method requires the JSONassert library to be on the classpath.
- 参数:
expectedJson- the expected JSON contentstrict- enables strict checking iftrue- 另请参阅:
-
xml
Parse expected and actual response content as XML and assert that the two are "similar", i.e. they contain the same elements and attributes regardless of order.Use of this method requires the XMLUnit library on the classpath.
- 参数:
expectedXml- the expected JSON content.- 另请参阅:
-
jsonPath
Access to response body assertions using a JsonPath expression to inspect a specific subset of the body.The JSON path expression can be a parameterized string using formatting specifiers as defined in
String.format(java.lang.String, java.lang.Object...).- 参数:
expression- the JsonPath expressionargs- arguments to parameterize the expression
-
xpath
Access to response body assertions using an XPath expression to inspect a specific subset of the body.The XPath expression can be a parameterized string using formatting specifiers as defined in
String.format(java.lang.String, java.lang.Object...).- 参数:
expression- the XPath expressionargs- arguments to parameterize the expression- 另请参阅:
-
xpath
Access to response body assertions with specific namespaces using an XPath expression to inspect a specific subset of the body.The XPath expression can be a parameterized string using formatting specifiers as defined in
String.format(java.lang.String, java.lang.Object...).- 参数:
expression- the XPath expressionnamespaces- the namespaces to useargs- arguments to parameterize the expression
-
consumeWith
Assert the response body content with the givenConsumer.- 参数:
consumer- the consumer for the response body; the inputbyte[]may benullif there was no response body.
-
returnResult
EntityExchangeResult<byte[]> returnResult()Exit the chained API and return anExchangeResultwith the raw response content.
-