Skip to content

Commit aef6b20

Browse files
committed
Removed tests for invalid -1 index (for compatibility with JsonPath 2.1)
1 parent 9bb72e8 commit aef6b20

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

spring-test/src/test/java/org/springframework/test/web/client/samples/matchers/JsonPathRequestMatchersIntegrationTests.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ public void doesNotExist() throws Exception {
7878
.andExpect(content().contentType("application/json;charset=UTF-8"))
7979
.andExpect(jsonPath("$.composers[?(@.name == 'Edvard Grieeeeeeg')]").doesNotExist())
8080
.andExpect(jsonPath("$.composers[?(@.name == 'Robert Schuuuuuuman')]").doesNotExist())
81-
.andExpect(jsonPath("$.composers[-1]").doesNotExist())
8281
.andExpect(jsonPath("$.composers[4]").doesNotExist())
8382
.andRespond(withSuccess());
8483
}

spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/JsonPathAssertionTests.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public class JsonPathAssertionTests {
4545

4646
private MockMvc mockMvc;
4747

48+
4849
@Before
4950
public void setup() {
5051
this.mockMvc = standaloneSetup(new MusicController())
@@ -54,9 +55,9 @@ public void setup() {
5455
.build();
5556
}
5657

57-
@Test
58-
public void testExists() throws Exception {
5958

59+
@Test
60+
public void exists() throws Exception {
6061
String composerByName = "$.composers[?(@.name == '%s')]";
6162
String performerByName = "$.performers[?(@.name == '%s')]";
6263

@@ -74,16 +75,15 @@ public void testExists() throws Exception {
7475
}
7576

7677
@Test
77-
public void testDoesNotExist() throws Exception {
78+
public void doesNotExist() throws Exception {
7879
this.mockMvc.perform(get("/music/people"))
7980
.andExpect(jsonPath("$.composers[?(@.name == 'Edvard Grieeeeeeg')]").doesNotExist())
8081
.andExpect(jsonPath("$.composers[?(@.name == 'Robert Schuuuuuuman')]").doesNotExist())
81-
.andExpect(jsonPath("$.composers[-1]").doesNotExist())
8282
.andExpect(jsonPath("$.composers[4]").doesNotExist());
8383
}
8484

8585
@Test
86-
public void testEqualTo() throws Exception {
86+
public void equality() throws Exception {
8787
this.mockMvc.perform(get("/music/people"))
8888
.andExpect(jsonPath("$.composers[0].name").value("Johann Sebastian Bach"))
8989
.andExpect(jsonPath("$.performers[1].name").value("Yehudi Menuhin"));
@@ -95,7 +95,7 @@ public void testEqualTo() throws Exception {
9595
}
9696

9797
@Test
98-
public void testHamcrestMatcher() throws Exception {
98+
public void hamcrestMatcher() throws Exception {
9999
this.mockMvc.perform(get("/music/people"))
100100
.andExpect(jsonPath("$.composers[0].name", startsWith("Johann")))
101101
.andExpect(jsonPath("$.performers[0].name", endsWith("Ashkenazy")))
@@ -104,8 +104,7 @@ public void testHamcrestMatcher() throws Exception {
104104
}
105105

106106
@Test
107-
public void testHamcrestMatcherWithParameterizedJsonPath() throws Exception {
108-
107+
public void hamcrestMatcherWithParameterizedJsonPath() throws Exception {
109108
String composerName = "$.composers[%s].name";
110109
String performerName = "$.performers[%s].name";
111110

@@ -135,4 +134,5 @@ public MultiValueMap<String, Person> get() {
135134
return map;
136135
}
137136
}
137+
138138
}

0 commit comments

Comments
 (0)