Package org.springframework.test.util
Class JsonExpectationsHelper
java.lang.Object
org.springframework.test.util.JsonExpectationsHelper
A helper class for assertions on JSON content.
 
Use of this class requires the JSONassert library.
- Since:
- 4.1
- Author:
- Sebastien Deleuze
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidassertJsonEqual(String expected, String actual) Parse the expected and actual strings as JSON and assert the two are "similar" - i.e.voidassertJsonEqual(String expected, String actual, boolean strict) Parse the expected and actual strings as JSON and assert the two are "similar" - i.e.voidassertJsonNotEqual(String expected, String actual) Parse the expected and actual strings as JSON and assert the two are "not similar" - i.e.voidassertJsonNotEqual(String expected, String actual, boolean strict) Parse the expected and actual strings as JSON and assert the two are "not similar" - i.e.
- 
Constructor Details- 
JsonExpectationsHelperpublic JsonExpectationsHelper()
 
- 
- 
Method Details- 
assertJsonEqualParse 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).- Parameters:
- expected- the expected JSON content
- actual- the actual JSON content
- Throws:
- Exception
- Since:
- 4.1
- See Also:
 
- 
assertJsonEqualParse 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.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.
 - Parameters:
- expected- the expected JSON content
- actual- the actual JSON content
- strict- enables strict checking
- Throws:
- Exception
- Since:
- 4.2
 
- 
assertJsonNotEqualParse the expected and actual strings as JSON and assert the two are "not similar" - i.e. they contain different attribute-value pairs regardless of formatting with a lenient checking (extensible, and non-strict array ordering).- Parameters:
- expected- the expected JSON content
- actual- the actual JSON content
- Throws:
- Exception
- Since:
- 4.1
- See Also:
 
- 
assertJsonNotEqualParse the expected and actual strings as JSON and assert the two are "not similar" - i.e. they contain different 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.
 - Parameters:
- expected- the expected JSON content
- actual- the actual JSON content
- strict- enables strict checking
- Throws:
- Exception
- Since:
- 4.2
 
 
-