类 ContentRequestMatchers
java.lang.Object
cn.taketoday.test.web.client.match.ContentRequestMatchers
Factory for request content
RequestMatcher's. An instance of this
class is typically accessed via MockRestRequestMatchers.content().- 从以下版本开始:
- 4.0
- 作者:
- Rossen Stoyanchev
-
嵌套类概要
嵌套类 -
字段概要
字段 -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明bytes(byte[] expectedContent) Compare the body of the request to the given byte array.contentType(cn.taketoday.http.MediaType expectedContentType) Assert the request content type as aMediaType.contentType(String expectedContentType) Assert the request content type as a String.contentTypeCompatibleWith(cn.taketoday.http.MediaType contentType) Assert the request content type is compatible with the given content type as defined byMediaType.isCompatibleWith(MediaType).contentTypeCompatibleWith(String contentType) Assert the request content type is compatible with the given content type as defined byMediaType.isCompatibleWith(MediaType).Parse the body as form data and compare to the givenMultiValueMap.private RequestMatcherformDataContains(Map<String, String> expected) Variant offormData(MultiValueMap)that matches the given subset of expected form parameters.Parse the expected and actual strings as JSON and assert the two are "similar" - i.e. they contain the same attribute-value pairs regardless of formatting with a lenient checking (extensible, and non-strict array ordering).Parse the request body and the given string as JSON and assert the two are "similar" - i.e. they contain the same attribute-value pairs regardless of formatting.multipartData(cn.taketoday.util.MultiValueMap<String, ?> expectedMap) Parse the body as multipart data and assert it contains exactly the values from the givenMultiValueMap.private RequestMatchermultipartData(cn.taketoday.util.MultiValueMap<String, ?> expectedMap, boolean containsExactly) multipartDataContains(Map<String, ?> expectedMap) Variant ofmultipartData(MultiValueMap)that does the same but only for a subset of the actual values.Parse the request content asNodeand apply the givenMatcher.Parse the request content asDOMSourceand apply the givenMatcher.Get the body of the request as a UTF-8 string and compare it to the given String.Get the body of the request as a UTF-8 string and apply the givenMatcher.Parse the request body and the given String as XML and assert that the two are "similar" - i.e. they contain the same elements and attributes regardless of order.
-
字段详细资料
-
xmlHelper
-
jsonHelper
-
-
构造器详细资料
-
ContentRequestMatchers
protected ContentRequestMatchers()Class constructor, not for direct instantiation. UseMockRestRequestMatchers.content().
-
-
方法详细资料
-
contentType
Assert the request content type as a String. -
contentType
Assert the request content type as aMediaType. -
contentTypeCompatibleWith
Assert the request content type is compatible with the given content type as defined byMediaType.isCompatibleWith(MediaType). -
contentTypeCompatibleWith
Assert the request content type is compatible with the given content type as defined byMediaType.isCompatibleWith(MediaType). -
string
Get the body of the request as a UTF-8 string and apply the givenMatcher. -
string
Get the body of the request as a UTF-8 string and compare it to the given String. -
bytes
Compare the body of the request to the given byte array. -
formData
Parse the body as form data and compare to the givenMultiValueMap. -
formDataContains
Variant offormData(MultiValueMap)that matches the given subset of expected form parameters. -
formData
private RequestMatcher formData(cn.taketoday.util.MultiValueMap<String, String> expectedMap, boolean containsExactly) -
multipartData
Parse the body as multipart data and assert it contains exactly the values from the givenMultiValueMap. Values may be of type:String- form fieldResource- content from a filebyte[]- other raw content
Note: This method uses the Apache Commons FileUpload library to parse the multipart data and it must be on the test classpath.
- 参数:
expectedMap- the expected multipart values
-
multipartDataContains
Variant ofmultipartData(MultiValueMap)that does the same but only for a subset of the actual values.- 参数:
expectedMap- the expected multipart values
-
multipartData
private RequestMatcher multipartData(cn.taketoday.util.MultiValueMap<String, ?> expectedMap, boolean containsExactly) -
xml
Parse the request body and the given String as XML and assert that the two are "similar" - i.e. they contain the same elements and attributes regardless of order.Use of this matcher assumes the XMLUnit library is available.
- 参数:
expectedXmlContent- the expected XML content
-
node
Parse the request content asNodeand apply the givenMatcher. -
source
Parse the request content asDOMSourceand apply the givenMatcher. -
json
Parse the expected and actual strings as JSON and assert the two are "similar" - i.e. they contain the same attribute-value pairs regardless of formatting with a lenient checking (extensible, and non-strict array ordering).Use of this matcher requires the JSONassert library.
- 参数:
expectedJsonContent- the expected JSON content
-
json
Parse the request body and the given string as JSON and assert the two are "similar" - i.e. they contain the same attribute-value pairs regardless of formatting.Can compare in two modes, depending on
strictparameter value:true: strict checking. Not extensible, and strict array ordering.false: lenient checking. Extensible, and non-strict array ordering.
Use of this matcher requires the JSONassert library.
- 参数:
expectedJsonContent- the expected JSON contentstrict- enables strict checking
-