From 495d73a288d4619a35c9a1cffc6502524a809ee0 Mon Sep 17 00:00:00 2001 From: Aled Sage Date: Wed, 2 Aug 2017 12:35:18 +0100 Subject: [PATCH] Upgrade json-path to 2.4.0 (from 2.0.0) This supports `.size()` Also fix the json-path dependency, to exclude conflicting versions --- .../brooklyn/feed/http/JsonFunctionsTest.java | 15 ++++++++ karaf/features/src/main/feature/feature.xml | 3 +- parent/pom.xml | 37 ++++++++++++++----- pom.xml | 7 ++-- 4 files changed, 48 insertions(+), 14 deletions(-) diff --git a/core/src/test/java/org/apache/brooklyn/feed/http/JsonFunctionsTest.java b/core/src/test/java/org/apache/brooklyn/feed/http/JsonFunctionsTest.java index ba654a4e84..d1a5d0aca3 100644 --- a/core/src/test/java/org/apache/brooklyn/feed/http/JsonFunctionsTest.java +++ b/core/src/test/java/org/apache/brooklyn/feed/http/JsonFunctionsTest.java @@ -28,6 +28,7 @@ import org.testng.Assert; import org.testng.annotations.Test; +import com.google.common.collect.ImmutableList; import com.google.gson.JsonElement; import com.google.gson.JsonParser; import com.jayway.jsonpath.PathNotFoundException; @@ -120,6 +121,20 @@ public void testGetPath2(){ Assert.assertEquals(obj, "dark"); } + @Test + public void testGetPathSizeOfMap(){ + JsonElement json = JsonFunctions.asJson().apply("{\"mymap\": {\"k1\": \"v1\", \"k2\": \"v2\"}}"); + Integer obj = (Integer) JsonFunctions.getPath("$.mymap.size()").apply(json); + Assert.assertEquals(obj, (Integer)2); + } + + @Test + public void testGetPathSizeOfList(){ + JsonElement json = JsonFunctions.asJson().apply("{\"mylist\": [\"a\", \"b\", \"c\"]}"); + Integer obj = (Integer) JsonFunctions.getPath("$.mylist.size()").apply(json); + Assert.assertEquals(obj, (Integer)3); + } + @Test public void testGetMissingPathIsNullOrThrows(){ try { diff --git a/karaf/features/src/main/feature/feature.xml b/karaf/features/src/main/feature/feature.xml index d6a50381bf..be16e90ba2 100644 --- a/karaf/features/src/main/feature/feature.xml +++ b/karaf/features/src/main/feature/feature.xml @@ -142,7 +142,8 @@ mvn:com.fasterxml.jackson.core/jackson-databind/${fasterxml.jackson.version} mvn:com.fasterxml.jackson.core/jackson-annotations/${fasterxml.jackson.version} mvn:net.minidev/json-smart/${jsonSmart.version} - mvn:net.minidev/asm/${minidev.asm.version} + mvn:net.minidev/accessors-smart/${minidev.accessors-smart.version} + mvn:org.ow2.asm/asm/${ow2.asm.version} mvn:com.thoughtworks.xstream/xstream/${xstream.version} mvn:org.freemarker/freemarker/${freemarker.version} mvn:com.hierynomus/sshj/${sshj.version} diff --git a/parent/pom.xml b/parent/pom.xml index 10e5ea48fe..d559d1ecff 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -463,6 +463,33 @@ com.jayway.jsonpath json-path ${jsonPath.version} + + + + org.slf4j + slf4j-api + + + + com.fasterxml.jackson.core + jackson-databind + + + + + net.minidev + json-smart + ${jsonSmart.version} + + + net.minidev + accessors-smart + ${minidev.accessors-smart.version} + + + org.ow2.asm + asm + ${ow2.asm.version} com.maxmind.geoip2 @@ -474,16 +501,6 @@ jline ${jline.version} - - net.minidev - json-smart - ${jsonSmart.version} - - - net.minidev - asm - ${minidev.asm.version} - diff --git a/pom.xml b/pom.xml index 919ff565a2..6bc718aca1 100644 --- a/pom.xml +++ b/pom.xml @@ -142,7 +142,7 @@ 20121111 2.3.25-incubating 2.4 - 2.0.0 + 2.4.0 1.4 1.1.0.Final 1.1.1 @@ -183,8 +183,9 @@ 1.2.17 1.2 2.12 - 2.1.1 - 1.0.2 + 2.3 + 1.2 + 5.0.4 1.9.1 3.2.1 1.4.4