open class ContentResultMatchers
Factory for response content assertions.
An instance of this class is typically accessed via MockMvcResultMatchers#content.
Author
Rossen Stoyanchev
Since
3.2
open fun bytes(expectedContent: ByteArray): ResultMatcher
Assert the response body content as a byte array. |
|
open fun contentType(contentType: String): ResultMatcher
Assert the ServletResponse content type. The given content type must fully match including type, sub-type, and parameters. For checking only the type and sub-type see open fun contentType(contentType: MediaType): ResultMatcher
Assert the ServletResponse content type after parsing it as a MediaType. The given content type must fully match including type, sub-type, and parameters. For checking only the type and sub-type see |
|
open fun contentTypeCompatibleWith(contentType: String): ResultMatcheropen fun contentTypeCompatibleWith(contentType: MediaType): ResultMatcher
Assert the ServletResponse content type is compatible with the given content type as defined by |
|
open fun encoding(characterEncoding: String): ResultMatcher
Assert the character encoding in the ServletResponse. |
|
open fun json(jsonContent: String): ResultMatcher
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). open fun json(jsonContent: String, strict: Boolean): ResultMatcher
Parse the response content 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
Use of this matcher requires the JSONassert library. |
|
open fun node(matcher: Matcher<in Node>): ResultMatcher
Parse the response content as Node and apply the given Hamcrest Matcher. |
|
open fun source(matcher: Matcher<in Source>): ResultMatcher
Parse the response content as DOMSource and apply the given Hamcrest Matcher. |
|
open fun string(matcher: Matcher<in String>): ResultMatcher
Assert the response body content with a Hamcrest Matcher.
open fun string(expectedContent: String): ResultMatcher
Assert the response body content as a String. |
|
open fun xml(xmlContent: String): ResultMatcher
Parse the response content and the given string as XML and assert the two are "similar" - i.e. they contain the same elements and attributes regardless of order. Use of this matcher requires the XMLUnit library. |