Skip to content

Commit

Permalink
bump dependency versions and fix build issues
Browse files Browse the repository at this point in the history
  • Loading branch information
kallestenflo committed Mar 28, 2019
1 parent f058efa commit 4bdf9b7
Show file tree
Hide file tree
Showing 24 changed files with 66 additions and 65 deletions.
29 changes: 18 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,31 @@ buildscript {
}
dependencies {
classpath 'me.champeau.gradle:gradle-javadoc-hotfix-plugin:0.1'
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.3'
classpath 'me.champeau.gradle:japicmp-gradle-plugin:0.1.0'
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.3'
}
}

ext {
libs = [
slf4jApi: 'org.slf4j:slf4j-api:1.7.25',
jsonSmart: 'net.minidev:json-smart:2.3',
jacksonDatabind: 'com.fasterxml.jackson.core:jackson-databind:2.6.3',
gson: 'com.google.code.gson:gson:2.3.1',
jettison: 'org.codehaus.jettison:jettison:1.3.7',
jsonOrg: 'org.json:json:20140107',
tapestryJson: 'org.apache.tapestry:tapestry-json:5.4.3',
gson: 'com.google.code.gson:gson:2.8.5',
hamcrestCore: 'org.hamcrest:hamcrest-core:1.3',
hamcrestLibrary: 'org.hamcrest:hamcrest-library:1.3',
jacksonDatabind: 'com.fasterxml.jackson.core:jackson-databind:2.9.8',
jettison: 'org.codehaus.jettison:jettison:1.3.7',
jsonOrg: 'org.json:json:20140107',
jsonSmart: 'net.minidev:json-smart:2.3',
slf4jApi: 'org.slf4j:slf4j-api:1.7.26',
tapestryJson: 'org.apache.tapestry:tapestry-json:5.4.4',

test: ['org.slf4j:slf4j-simple:1.7.16', 'org.assertj:assertj-core:2.1.0', 'commons-io:commons-io:2.4','org.hamcrest:hamcrest-core:1.3', 'org.hamcrest:hamcrest-library:1.3', 'junit:junit:4.12']
test: [
'commons-io:commons-io:2.4',
'junit:junit:4.12',
'org.assertj:assertj-core:3.11.1',
'org.hamcrest:hamcrest-core:1.3',
'org.hamcrest:hamcrest-library:1.3',
'org.slf4j:slf4j-simple:1.7.26'
]
]
snapshotVersion = false
}
Expand All @@ -45,8 +52,8 @@ subprojects {
apply plugin: 'signing'
apply plugin: 'osgi'

sourceCompatibility = 1.6
targetCompatibility = 1.6
sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ public interface JsonAsserter {
<T> JsonAsserter assertThat(String path, Matcher<T> matcher);

/**
* @param path
* @param matcher
* @param message
* @param <T>
* @return
* @param path the json path specifying the value being compared
* @param matcher an expression, built of Matchers, specifying allowed values
* @param message the explanation message
* @param <T> the static type that should be returned by the path
* @return this to allow fluent assertion chains
*/
<T> JsonAsserter assertThat(String path, Matcher<T> matcher, String message);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void describeTo(Description description) {
@Override
protected void describeMismatchSafely(ReadContext context, Description mismatchDescription) {
try {
T value = jsonPath.read(context.json());
T value = jsonPath.read(context.jsonString());
mismatchDescription
.appendText("json path ")
.appendValue(jsonPath.getPath())
Expand Down
11 changes: 3 additions & 8 deletions json-path/src/main/java/com/jayway/jsonpath/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,7 @@
import com.jayway.jsonpath.spi.json.JsonProvider;
import com.jayway.jsonpath.spi.mapper.MappingProvider;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumSet;
import java.util.Set;
import java.util.*;

import static com.jayway.jsonpath.internal.Utils.notNull;
import static java.util.Arrays.asList;
Expand Down Expand Up @@ -142,15 +137,15 @@ public Configuration addOptions(Option... options) {
/**
* Creates a new configuration with the provided options. Options in this configuration are discarded.
* @param options
* @return
* @return the new configuration instance
*/
public Configuration setOptions(Option... options) {
return Configuration.builder().jsonProvider(jsonProvider).mappingProvider(mappingProvider).options(options).evaluationListener(evaluationListeners).build();
}

/**
* Returns the options used by this configuration
* @return
* @return the new configuration instance
*/
public Set<Option> getOptions() {
return options;
Expand Down
2 changes: 1 addition & 1 deletion json-path/src/main/java/com/jayway/jsonpath/Filter.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static Filter filter(Predicate predicate) {
/**
* Create a new Filter based on given list of criteria.
* @param predicates list of criteria all needs to evaluate to true
* @return
* @return the filter
*/
public static Filter filter(Collection<Predicate> predicates) {
return new AndFilter(predicates);
Expand Down
10 changes: 4 additions & 6 deletions json-path/src/main/java/com/jayway/jsonpath/JsonPath.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@
package com.jayway.jsonpath;


import com.jayway.jsonpath.internal.EvaluationContext;
import com.jayway.jsonpath.internal.ParseContextImpl;
import com.jayway.jsonpath.internal.Path;
import com.jayway.jsonpath.internal.PathRef;
import com.jayway.jsonpath.internal.Utils;
import com.jayway.jsonpath.internal.*;
import com.jayway.jsonpath.internal.path.PathCompiler;
import com.jayway.jsonpath.spi.json.JsonProvider;

Expand Down Expand Up @@ -289,7 +285,7 @@ public <T> T add(Object jsonObject, Object value, Configuration configuration) {
* Adds or updates the Object this path points to in the provided jsonObject with a key with a value
*
* @param jsonObject a json object
* @param value the key to add or update
* @param key the key to add or update
* @param value the new value
* @param configuration configuration to use
* @param <T> expected return type
Expand Down Expand Up @@ -628,6 +624,7 @@ public static DocumentContext parse(File json) throws IOException {
* @param json url
* @return a read context
*/
@Deprecated
public static DocumentContext parse(URL json) throws IOException {
return new ParseContextImpl().parse(json);
}
Expand Down Expand Up @@ -683,6 +680,7 @@ public static DocumentContext parse(File json, Configuration configuration) thro
* @param json input
* @return a read context
*/
@Deprecated
public static DocumentContext parse(URL json, Configuration configuration) throws IOException {
return new ParseContextImpl(configuration).parse(json);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public DocumentContext parse(File json) throws IOException {
}

@Override
@Deprecated
public DocumentContext parse(URL url) throws IOException {
notNull(url, "url can not be null");
InputStream fis = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public interface PathFunction {
* Eval context, state bag used as the path is traversed, maintains the result of executing
*
* @param parameters
* @return
* @return result
*/
Object invoke(String currentPath, PathRef parent, Object model, EvaluationContext ctx, List<Parameter> parameters);
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public JsonLateBindingValue(JsonProvider jsonProvider, Parameter jsonParameter)
* Evaluate the JSON document at the point of need using the JSON parameter and associated document model which may
* itself originate from yet another function thus recursively invoking late binding methods.
*
* @return
* @return the late value
*/
@Override
public Object get() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import com.jayway.jsonpath.Configuration;
import com.jayway.jsonpath.internal.Path;
import com.jayway.jsonpath.internal.function.ParamType;

/**
* Defines the contract for late bindings, provides document state and enough context to perform the evaluation at a later
Expand All @@ -39,7 +38,7 @@ public PathLateBindingValue(final Path path, final Object rootDocument, final Co
/**
* Evaluate the expression at the point of need for Path type expressions
*
* @return
* @return the late value
*/
public Object get() {
return path.evaluate(rootDocument, rootDocument, configuration).getValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private void evaluateParameters(String currentPath, PathRef parent, Object model
* Return the actual value by indicating true. If this return was false then we'd return the value in an array which
* isn't what is desired - true indicates the raw value is returned.
*
* @return
* @return true if token is definite
*/
@Override
public boolean isTokenDefinite() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ public interface Cache {
* @param key cache key to lookup the JsonPath
* @return JsonPath
*/
public JsonPath get(String key);
JsonPath get(String key);

/**
* Add JsonPath to the cache
* @param key cache key to store the JsonPath
* @param value JsonPath to be cached
* @return void
* @throws InvalidJsonException
*/
public void put(String key, JsonPath value);
void put(String key, JsonPath value);
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public Object getArrayIndex(Object obj, int idx) {
return ((List) obj).get(idx);
}

@Deprecated
public final Object getArrayIndex(Object obj, int idx, boolean unwrap){
return getArrayIndex(obj, idx);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ private void setValueInObjectNode(ObjectNode objectNode, Object key, Object valu
} else if (value == null) {
objectNode.set(key.toString(), null); // this will create a null-node
} else {
objectNode.put(key.toString(), createJsonElement(value));
objectNode.set(key.toString(), createJsonElement(value));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
public class JacksonJsonProvider extends AbstractJsonProvider {

private static final ObjectMapper defaultObjectMapper = new ObjectMapper();
private static final ObjectReader defaultObjectReader = defaultObjectMapper.reader().withType(Object.class);
private static final ObjectReader defaultObjectReader = defaultObjectMapper.reader().forType(Object.class);

protected ObjectMapper objectMapper;
protected ObjectReader objectReader;
Expand All @@ -51,7 +51,7 @@ public JacksonJsonProvider() {
* @param objectMapper the ObjectMapper to use
*/
public JacksonJsonProvider(ObjectMapper objectMapper) {
this(objectMapper, objectMapper.reader().withType(Object.class));
this(objectMapper, objectMapper.reader().forType(Object.class));
}

/**
Expand Down
18 changes: 9 additions & 9 deletions json-path/src/test/java/com/jayway/jsonpath/FilterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -418,13 +418,13 @@ public void type_evals() {
//----------------------------------------------------------------------------
@Test
public void not_empty_evals() {
assertThat(filter(where("string-key").notEmpty()).apply(createPredicateContext(json))).isEqualTo(true);
assertThat(filter(where("string-key-empty").notEmpty()).apply(createPredicateContext(json))).isEqualTo(false);
assertThat(filter(where("string-key").empty(false)).apply(createPredicateContext(json))).isEqualTo(true);
assertThat(filter(where("string-key-empty").empty(false)).apply(createPredicateContext(json))).isEqualTo(false);

assertThat(filter(where("int-arr").notEmpty()).apply(createPredicateContext(json))).isEqualTo(true);
assertThat(filter(where("arr-empty").notEmpty()).apply(createPredicateContext(json))).isEqualTo(false);
assertThat(filter(where("int-arr").empty(false)).apply(createPredicateContext(json))).isEqualTo(true);
assertThat(filter(where("arr-empty").empty(false)).apply(createPredicateContext(json))).isEqualTo(false);

assertThat(filter(where("null-key").notEmpty()).apply(createPredicateContext(json))).isEqualTo(false);
assertThat(filter(where("null-key").empty(false)).apply(createPredicateContext(json))).isEqualTo(false);
}

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -516,11 +516,11 @@ public void testFilterWithOrShortCircuit2() throws Exception {
@Test
public void criteria_can_be_parsed() {

Criteria criteria = Criteria.parse("@.foo == 'baar'");
assertThat(criteria.toString()).isEqualTo("@['foo'] == 'baar'");
Filter criteria = Filter.parse("[?(@.foo == 'baar')]");
assertThat(criteria.toString()).isEqualTo("[?(@['foo'] == 'baar')]");

criteria = Criteria.parse("@.foo");
assertThat(criteria.toString()).isEqualTo("@['foo']");
criteria = Filter.parse("[?(@.foo)]");
assertThat(criteria.toString()).isEqualTo("[?(@['foo'])]");
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.junit.runners.Parameterized;

import java.util.Arrays;
import java.util.HashMap;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
Expand Down Expand Up @@ -84,7 +85,7 @@ private static String json() {
}

private Predicate.PredicateContext createPredicateContext() {
return createPredicateContext(Maps.newHashMap());
return createPredicateContext(new HashMap<>());
}

}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.jayway.jsonpath.internal.function;

import com.jayway.jsonpath.JsonPath;
import org.assertj.core.util.Maps;
import org.junit.Test;

import java.util.HashMap;
import java.util.Map;

import static org.assertj.core.api.Assertions.assertThat;
Expand All @@ -27,7 +27,7 @@ public class Issue234 {

@Test
public void testIssue234() {
Map<String, String> context = Maps.newHashMap();
Map<String, String> context = new HashMap<>();
context.put("key", "first");
Object value = JsonPath.read(context, "concat(\"/\", $.key)");
assertThat(value).isEqualTo("/first");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import java.util.List;

import static junit.framework.Assert.assertEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import static com.jayway.jsonpath.Criteria.where;
import static com.jayway.jsonpath.Filter.filter;
import static java.util.Arrays.asList;
import static junit.framework.Assert.*;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;

Expand Down Expand Up @@ -409,10 +409,10 @@ public void not_empty_filter_evaluates() {

Object doc = Configuration.defaultConfiguration().jsonProvider().parse(json);

List<Map<String, Object>> result = JsonPath.read(doc, "$.fields[?]", filter(where("errors").notEmpty()));
List<Map<String, Object>> result = JsonPath.read(doc, "$.fields[?]", filter(where("errors").empty(false)));
assertEquals(1, result.size());

List<Map<String, Object>> result2 = JsonPath.read(doc, "$.fields[?]", filter(where("name").notEmpty()));
List<Map<String, Object>> result2 = JsonPath.read(doc, "$.fields[?]", filter(where("name").empty(false)));
assertEquals(2, result2.size());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
import static com.jayway.jsonpath.Filter.filter;
import static com.jayway.jsonpath.JsonPath.read;
import static com.jayway.jsonpath.JsonPath.using;
import static junit.framework.Assert.assertNull;
import static junit.framework.Assert.assertTrue;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.failBecauseExceptionWasNotThrown;
import static org.hamcrest.Matchers.is;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

import java.util.List;

import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNull;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

public class NullHandlingTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import java.util.List;

import static junit.framework.Assert.assertNull;
import static org.junit.Assert.assertNull;
import static org.assertj.core.api.Assertions.assertThat;

public class PropertyPathTokenTest {
Expand Down
2 changes: 1 addition & 1 deletion system.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
java.runtime.version=1.7
java.runtime.version=1.8

0 comments on commit 4bdf9b7

Please sign in to comment.