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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
assertJsonEqual
(String expected, String actual) Parse the expected and actual strings as JSON and assert the two are "similar" - i.e.void
assertJsonEqual
(String expected, String actual, boolean strict) Parse the expected and actual strings as JSON and assert the two are "similar" - i.e.void
assertJsonNotEqual
(String expected, String actual) Parse the expected and actual strings as JSON and assert the two are "not similar" - i.e.void
assertJsonNotEqual
(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
-
JsonExpectationsHelper
public JsonExpectationsHelper()
-
-
Method Details
-
assertJsonEqual
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 lenient checking (extensible content and non-strict array ordering).- Parameters:
expected
- the expected JSON contentactual
- the actual JSON content- Throws:
Exception
- Since:
- 4.1
- See Also:
-
assertJsonEqual
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.Can compare in two modes, depending on the
strict
parameter value:true
: strict checking. Not extensible and strict array ordering.false
: lenient checking. Extensible and non-strict array ordering.
- Parameters:
expected
- the expected JSON contentactual
- the actual JSON contentstrict
- enables strict checking iftrue
- Throws:
Exception
- Since:
- 4.2
-
assertJsonNotEqual
Parse 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 contentactual
- the actual JSON content- Throws:
Exception
- Since:
- 4.1
- See Also:
-
assertJsonNotEqual
Parse 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
strict
parameter value:true
: strict checking. Not extensible, and strict array ordering.false
: lenient checking. Extensible, and non-strict array ordering.
- Parameters:
expected
- the expected JSON contentactual
- the actual JSON contentstrict
- enables strict checking- Throws:
Exception
- Since:
- 4.2
-