Browse Source

Upgrade json-path to 0.9.0 version

This version fixed bugs and improved performance.
New features: "select multiple attributes" and
"Array operations and slicing improved" (a new example
has been added in tests to reflect that).

See https://github.com/jayway/JsonPath/blob/master/README

Issue: SPR-10990
pull/386/merge
Brian Clozel 12 years ago committed by Rossen Stoyanchev
parent
commit
efa86e80d8
  1. 5
      build.gradle
  2. 8
      spring-test-mvc/src/test/java/org/springframework/test/web/client/samples/matchers/JsonPathRequestMatcherTests.java

5
build.gradle

@ -756,7 +756,7 @@ project("spring-test") { @@ -756,7 +756,7 @@ project("spring-test") {
optional(project(":spring-orm"))
optional(project(":spring-web"))
optional(project(":spring-webmvc"))
optional(project(":spring-webmvc-portlet"), )
optional(project(":spring-webmvc-portlet"))
optional("junit:junit:${junitVersion}")
optional("org.testng:testng:6.8.5")
optional("javax.servlet:javax.servlet-api:3.0.1")
@ -799,9 +799,10 @@ project("spring-test-mvc") { @@ -799,9 +799,10 @@ project("spring-test-mvc") {
dependencies {
optional(project(":spring-context"))
provided(project(":spring-webmvc"))
provided(project(":spring-webmvc-tiles3"))
provided("javax.servlet:javax.servlet-api:3.0.1")
optional("org.hamcrest:hamcrest-core:1.3")
optional("com.jayway.jsonpath:json-path:0.8.1")
optional("com.jayway.jsonpath:json-path:0.9.0")
optional("xmlunit:xmlunit:1.3")
testCompile("org.slf4j:slf4j-jcl:${slf4jVersion}")
testCompile("javax.servlet:jstl:1.2")

8
spring-test-mvc/src/test/java/org/springframework/test/web/client/samples/matchers/JsonPathRequestMatcherTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@ package org.springframework.test.web.client.samples.matchers; @@ -18,6 +18,7 @@ package org.springframework.test.web.client.samples.matchers;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.endsWith;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.isIn;
import static org.hamcrest.Matchers.startsWith;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.content;
@ -92,8 +93,8 @@ public class JsonPathRequestMatcherTests { @@ -92,8 +93,8 @@ public class JsonPathRequestMatcherTests {
public void testDoesNotExist() throws Exception {
this.mockServer.expect(requestTo("/composers"))
.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[?(@.name == 'Edvard Grieeeeeeg')]").doesNotExist())
.andExpect(jsonPath("$.composers[?(@.name == 'Robert Schuuuuuuman')]").doesNotExist())
.andExpect(jsonPath("$.composers[-1]").doesNotExist())
.andExpect(jsonPath("$.composers[4]").doesNotExist())
.andRespond(withSuccess());
@ -124,6 +125,7 @@ public class JsonPathRequestMatcherTests { @@ -124,6 +125,7 @@ public class JsonPathRequestMatcherTests {
.andExpect(jsonPath("$.performers[0].name", endsWith("Ashkenazy")))
.andExpect(jsonPath("$.performers[1].name", containsString("di Me")))
.andExpect(jsonPath("$.composers[1].name", isIn(Arrays.asList("Johann Sebastian Bach", "Johannes Brahms"))))
.andExpect(jsonPath("$.composers[:3].name", hasItem("Johannes Brahms")))
.andRespond(withSuccess());
this.restTemplate.put(new URI("/composers"), this.people);

Loading…
Cancel
Save