From efa86e80d8be934519de189cecaaba9f05c6ebbc Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Thu, 17 Oct 2013 14:28:44 +0200 Subject: [PATCH] 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 --- build.gradle | 5 +++-- .../samples/matchers/JsonPathRequestMatcherTests.java | 8 +++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index a4d05cf220f..75c51e2e02d 100644 --- a/build.gradle +++ b/build.gradle @@ -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") { 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") diff --git a/spring-test-mvc/src/test/java/org/springframework/test/web/client/samples/matchers/JsonPathRequestMatcherTests.java b/spring-test-mvc/src/test/java/org/springframework/test/web/client/samples/matchers/JsonPathRequestMatcherTests.java index 1b4a7b9da97..9dd693931e0 100644 --- a/spring-test-mvc/src/test/java/org/springframework/test/web/client/samples/matchers/JsonPathRequestMatcherTests.java +++ b/spring-test-mvc/src/test/java/org/springframework/test/web/client/samples/matchers/JsonPathRequestMatcherTests.java @@ -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; 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 { 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 { .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);