Package org.springframework.test.util
Class JsonExpectationsHelper
- java.lang.Object
- org.springframework.test.util.JsonExpectationsHelper
public class JsonExpectationsHelper extends Object
A helper class for assertions on JSON content.Use of this class requires the JSONassert library.
- Since:
- 4.1
- Author:
- Sebastien Deleuze
Constructor Summary
Constructors Constructor Description JsonExpectationsHelper()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
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 Detail
JsonExpectationsHelper
public JsonExpectationsHelper()
Method Detail
assertJsonEqual
public void assertJsonEqual(String expected, String actual) throws Exception
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).- Parameters:
expected
- the expected JSON contentactual
- the actual JSON content- Throws:
Exception
- Since:
- 4.1
- See Also:
assertJsonEqual(String, String, boolean)
assertJsonEqual
public void assertJsonEqual(String expected, String actual, boolean strict) throws Exception
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
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
assertJsonNotEqual
public void assertJsonNotEqual(String expected, String actual) throws Exception
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(String, String, boolean)
assertJsonNotEqual
public void assertJsonNotEqual(String expected, String actual, boolean strict) throws Exception
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