类 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.
- 从以下版本开始:
- 4.1
- 作者:
- Sebastien Deleuze
构造器概要
构造器 构造器 说明 JsonExpectationsHelper()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
assertJsonEqual(String expected, String actual)
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).void
assertJsonEqual(String expected, String actual, boolean strict)
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.void
assertJsonNotEqual(String expected, String actual)
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).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. they contain different attribute-value pairs regardless of formatting.
构造器详细资料
JsonExpectationsHelper
public JsonExpectationsHelper()
方法详细资料
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).- 参数:
expected
- the expected JSON contentactual
- the actual JSON content- 抛出:
Exception
- 从以下版本开始:
- 4.1
- 另请参阅:
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.
- 参数:
expected
- the expected JSON contentactual
- the actual JSON contentstrict
- enables strict checking- 抛出:
Exception
- 从以下版本开始:
- 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).- 参数:
expected
- the expected JSON contentactual
- the actual JSON content- 抛出:
Exception
- 从以下版本开始:
- 4.1
- 另请参阅:
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.
- 参数:
expected
- the expected JSON contentactual
- the actual JSON contentstrict
- enables strict checking- 抛出:
Exception
- 从以下版本开始:
- 4.2