From aef6b206261b613606d4e33406b8dcddfa82d05b Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Fri, 27 Nov 2015 14:11:40 +0100 Subject: [PATCH] Removed tests for invalid -1 index (for compatibility with JsonPath 2.1) --- .../JsonPathRequestMatchersIntegrationTests.java | 1 - .../resultmatchers/JsonPathAssertionTests.java | 16 ++++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/spring-test/src/test/java/org/springframework/test/web/client/samples/matchers/JsonPathRequestMatchersIntegrationTests.java b/spring-test/src/test/java/org/springframework/test/web/client/samples/matchers/JsonPathRequestMatchersIntegrationTests.java index dc0ca6db93..91d670b347 100644 --- a/spring-test/src/test/java/org/springframework/test/web/client/samples/matchers/JsonPathRequestMatchersIntegrationTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/client/samples/matchers/JsonPathRequestMatchersIntegrationTests.java @@ -78,7 +78,6 @@ public class JsonPathRequestMatchersIntegrationTests { .andExpect(content().contentType("application/json;charset=UTF-8")) .andExpect(jsonPath("$.composers[?(@.name == 'Edvard Grieeeeeeg')]").doesNotExist()) .andExpect(jsonPath("$.composers[?(@.name == 'Robert Schuuuuuuman')]").doesNotExist()) - .andExpect(jsonPath("$.composers[-1]").doesNotExist()) .andExpect(jsonPath("$.composers[4]").doesNotExist()) .andRespond(withSuccess()); } diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/JsonPathAssertionTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/JsonPathAssertionTests.java index 0b006f5c5c..f7f5a025a2 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/JsonPathAssertionTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/JsonPathAssertionTests.java @@ -45,6 +45,7 @@ public class JsonPathAssertionTests { private MockMvc mockMvc; + @Before public void setup() { this.mockMvc = standaloneSetup(new MusicController()) @@ -54,9 +55,9 @@ public class JsonPathAssertionTests { .build(); } - @Test - public void testExists() throws Exception { + @Test + public void exists() throws Exception { String composerByName = "$.composers[?(@.name == '%s')]"; String performerByName = "$.performers[?(@.name == '%s')]"; @@ -74,16 +75,15 @@ public class JsonPathAssertionTests { } @Test - public void testDoesNotExist() throws Exception { + public void doesNotExist() throws Exception { this.mockMvc.perform(get("/music/people")) .andExpect(jsonPath("$.composers[?(@.name == 'Edvard Grieeeeeeg')]").doesNotExist()) .andExpect(jsonPath("$.composers[?(@.name == 'Robert Schuuuuuuman')]").doesNotExist()) - .andExpect(jsonPath("$.composers[-1]").doesNotExist()) .andExpect(jsonPath("$.composers[4]").doesNotExist()); } @Test - public void testEqualTo() throws Exception { + public void equality() throws Exception { this.mockMvc.perform(get("/music/people")) .andExpect(jsonPath("$.composers[0].name").value("Johann Sebastian Bach")) .andExpect(jsonPath("$.performers[1].name").value("Yehudi Menuhin")); @@ -95,7 +95,7 @@ public class JsonPathAssertionTests { } @Test - public void testHamcrestMatcher() throws Exception { + public void hamcrestMatcher() throws Exception { this.mockMvc.perform(get("/music/people")) .andExpect(jsonPath("$.composers[0].name", startsWith("Johann"))) .andExpect(jsonPath("$.performers[0].name", endsWith("Ashkenazy"))) @@ -104,8 +104,7 @@ public class JsonPathAssertionTests { } @Test - public void testHamcrestMatcherWithParameterizedJsonPath() throws Exception { - + public void hamcrestMatcherWithParameterizedJsonPath() throws Exception { String composerName = "$.composers[%s].name"; String performerName = "$.performers[%s].name"; @@ -135,4 +134,5 @@ public class JsonPathAssertionTests { return map; } } + }