Added strict compare mode for Json
Issue: SPR-13607
This commit is contained in:
committed by
Sebastien Deleuze
parent
9334fabe26
commit
1d60a6a6af
@@ -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