mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-22 05:49:04 +00:00
Added strict compare mode for Json
Issue: SPR-13607
This commit is contained in:
committed by
Sebastien Deleuze
parent
9334fabe26
commit
1d60a6a6af
+15
-4
@@ -79,17 +79,28 @@ public class ContentResultMatchersTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void json() throws Exception {
|
||||
new ContentResultMatchers().json("{\n \"foo\" : \"bar\" \n}").match(getStubMvcResult());
|
||||
public void jsonLenientMatch() throws Exception {
|
||||
new ContentResultMatchers().json("{\n \"foo\" : \"bar\" \n}").match(getStubMvcResult());
|
||||
new ContentResultMatchers().json("{\n \"foo\" : \"bar\" \n}", false).match(getStubMvcResult());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jsonStrictMatch() throws Exception {
|
||||
new ContentResultMatchers().json("{\n \"foo\":\"bar\", \"foo array\":[\"foo\",\"bar\"] \n}", true).match(getStubMvcResult());
|
||||
new ContentResultMatchers().json("{\n \"foo array\":[\"foo\",\"bar\"], \"foo\":\"bar\" \n}", true).match(getStubMvcResult());
|
||||
}
|
||||
|
||||
@Test(expected=AssertionError.class)
|
||||
public void jsonNoMatch() throws Exception {
|
||||
public void jsonLenientNoMatch() throws Exception {
|
||||
new ContentResultMatchers().json("{\n\"fooo\":\"bar\"\n}").match(getStubMvcResult());
|
||||
}
|
||||
|
||||
@Test(expected=AssertionError.class)
|
||||
public void jsonStrictNoMatch() throws Exception {
|
||||
new ContentResultMatchers().json("{\"foo\":\"bar\", \"foo array\":[\"bar\",\"foo\"]}", true).match(getStubMvcResult());
|
||||
}
|
||||
|
||||
private static final String CONTENT = "{\"foo\":\"bar\"}";
|
||||
private static final String CONTENT = "{\"foo\":\"bar\",\"foo array\":[\"foo\",\"bar\"]}";
|
||||
|
||||
private StubMvcResult getStubMvcResult() throws Exception {
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
|
||||
Reference in New Issue
Block a user