diff --git a/json-path/src/main/java/com/jayway/jsonpath/Criteria.java b/json-path/src/main/java/com/jayway/jsonpath/Criteria.java index 0640cb2e..8ab2f7aa 100644 --- a/json-path/src/main/java/com/jayway/jsonpath/Criteria.java +++ b/json-path/src/main/java/com/jayway/jsonpath/Criteria.java @@ -50,7 +50,7 @@ public class Criteria implements Predicate { @Override boolean eval(Object expected, Object actual, PredicateContext ctx) { boolean res = (0 == safeCompare(expected, actual)); - logger.debug("[{}] {} [{}] => {}", actual, name(), expected, res); + if(logger.isDebugEnabled()) logger.debug("[{}] {} [{}] => {}", actual, name(), expected, res); return res; } }, @@ -58,7 +58,7 @@ public class Criteria implements Predicate { @Override boolean eval(Object expected, Object actual, PredicateContext ctx) { boolean res = (0 != safeCompare(expected, actual)); - logger.debug("[{}] {} [{}] => {}", actual, name(), expected, res); + if(logger.isDebugEnabled()) logger.debug("[{}] {} [{}] => {}", actual, name(), expected, res); return res; } }, @@ -69,7 +69,7 @@ public class Criteria implements Predicate { return false; } boolean res = (0 > safeCompare(expected, actual)); - logger.debug("[{}] {} [{}] => {}", actual, name(), expected, res); + if(logger.isDebugEnabled()) logger.debug("[{}] {} [{}] => {}", actual, name(), expected, res); return res; } }, @@ -80,7 +80,7 @@ public class Criteria implements Predicate { return false; } boolean res = (0 >= safeCompare(expected, actual)); - logger.debug("[{}] {} [{}] => {}", actual, name(), expected, res); + if(logger.isDebugEnabled()) logger.debug("[{}] {} [{}] => {}", actual, name(), expected, res); return res; } }, @@ -91,7 +91,7 @@ public class Criteria implements Predicate { return false; } boolean res = (0 < safeCompare(expected, actual)); - logger.debug("[{}] {} [{}] => {}", actual, name(), expected, res); + if(logger.isDebugEnabled()) logger.debug("[{}] {} [{}] => {}", actual, name(), expected, res); return res; } }, @@ -102,7 +102,7 @@ public class Criteria implements Predicate { return false; } boolean res = (0 <= safeCompare(expected, actual)); - logger.debug("[{}] {} [{}] => {}", actual, name(), expected, res); + if(logger.isDebugEnabled()) logger.debug("[{}] {} [{}] => {}", actual, name(), expected, res); return res; } }, @@ -117,7 +117,7 @@ public class Criteria implements Predicate { break; } } - logger.debug("[{}] {} [{}] => {}", actual, name(), join(", ", exps), res); + if(logger.isDebugEnabled()) logger.debug("[{}] {} [{}] => {}", actual, name(), join(", ", exps), res); return res; } }, @@ -126,7 +126,7 @@ public class Criteria implements Predicate { boolean eval(Object expected, Object actual, PredicateContext ctx) { Collection nexps = (Collection) expected; boolean res = !nexps.contains(actual); - logger.debug("[{}] {} [{}] => {}", actual, name(), join(", ", nexps), res); + if(logger.isDebugEnabled()) logger.debug("[{}] {} [{}] => {}", actual, name(), join(", ", nexps), res); return res; } }, @@ -149,10 +149,10 @@ public class Criteria implements Predicate { break; } } - logger.debug("[{}] {} [{}] => {}", join(", ", ctx.configuration().jsonProvider().toIterable(actual)), name(), join(", ", exps), res); + if(logger.isDebugEnabled()) logger.debug("[{}] {} [{}] => {}", join(", ", ctx.configuration().jsonProvider().toIterable(actual)), name(), join(", ", exps), res); } else { res = false; - logger.debug("[{}] {} [{}] => {}", "", name(), join(", ", exps), res); + if(logger.isDebugEnabled()) logger.debug("[{}] {} [{}] => {}", "", name(), join(", ", exps), res); } return res; } @@ -165,14 +165,14 @@ public class Criteria implements Predicate { if (ctx.configuration().jsonProvider().isArray(actual)) { int length = ctx.configuration().jsonProvider().length(actual); res = (length == size); - logger.debug("Array with size {} {} {} => {}", length, name(), size, res); + if(logger.isDebugEnabled()) logger.debug("Array with size {} {} {} => {}", length, name(), size, res); } else if (actual instanceof String) { int length = ((String) actual).length(); res = length == size; - logger.debug("String with length {} {} {} => {}", length, name(), size, res); + if(logger.isDebugEnabled()) logger.debug("String with length {} {} {} => {}", length, name(), size, res); } else { res = false; - logger.debug("{} {} {} => {}", actual == null ? "null" : actual.getClass().getName(), name(), size, res); + if(logger.isDebugEnabled()) logger.debug("{} {} {} => {}", actual == null ? "null" : actual.getClass().getName(), name(), size, res); } return res; } @@ -201,7 +201,7 @@ public class Criteria implements Predicate { if (actual != null && actual instanceof String) { res = pattern.matcher(actual.toString()).matches(); } - logger.debug("[{}] {} [{}] => {}", actual, name(), expected.toString(), res); + if(logger.isDebugEnabled()) logger.debug("[{}] {} [{}] => {}", actual, name(), expected.toString(), res); return res; } }, @@ -221,11 +221,11 @@ public class Criteria implements Predicate { if (ctx.configuration().jsonProvider().isArray(actual)) { int len = ctx.configuration().jsonProvider().length(actual); res = (0 != len); - logger.debug("array length = {} {} => {}", len, name(), res); + if(logger.isDebugEnabled()) logger.debug("array length = {} {} => {}", len, name(), res); } else if (actual instanceof String) { int len = ((String) actual).length(); res = (0 != len); - logger.debug("string length = {} {} => {}", len, name(), res); + if(logger.isDebugEnabled()) logger.debug("string length = {} {} => {}", len, name(), res); } } return res; diff --git a/json-path/src/main/java/com/jayway/jsonpath/internal/PathCompiler.java b/json-path/src/main/java/com/jayway/jsonpath/internal/PathCompiler.java index b1a451ad..da88c8a3 100644 --- a/json-path/src/main/java/com/jayway/jsonpath/internal/PathCompiler.java +++ b/json-path/src/main/java/com/jayway/jsonpath/internal/PathCompiler.java @@ -74,7 +74,7 @@ public class PathCompiler { String cacheKey = path + isRootPath + filterList.toString(); Path p = cache.get(cacheKey); if (p != null) { - logger.debug("Using cached path"); + if(logger.isDebugEnabled()) logger.debug("Using cached path"); return p; } diff --git a/json-path/src/test/java/com/jayway/jsonpath/InlineFilterTest.java b/json-path/src/test/java/com/jayway/jsonpath/InlineFilterTest.java index 68477fec..98fae129 100644 --- a/json-path/src/test/java/com/jayway/jsonpath/InlineFilterTest.java +++ b/json-path/src/test/java/com/jayway/jsonpath/InlineFilterTest.java @@ -43,7 +43,7 @@ public class InlineFilterTest extends BaseTest { Object read = reader.read("$.store.book[?(@.display-price <= $.max-price)]"); - System.out.println(read); + //System.out.println(read); } } diff --git a/json-path/src/test/java/com/jayway/jsonpath/old/HttpProviderTest.java b/json-path/src/test/java/com/jayway/jsonpath/old/HttpProviderTest.java index 18e553ed..cc46a378 100644 --- a/json-path/src/test/java/com/jayway/jsonpath/old/HttpProviderTest.java +++ b/json-path/src/test/java/com/jayway/jsonpath/old/HttpProviderTest.java @@ -11,7 +11,6 @@ import java.net.URL; import static junit.framework.Assert.assertEquals; -@Ignore public class HttpProviderTest { @@ -21,6 +20,7 @@ public class HttpProviderTest { "}"; @Test + @Ignore public void http_get() throws Exception { URL url = new URL("http://maps.googleapis.com/maps/api/geocode/json?sensor=false"); diff --git a/json-path/src/test/java/com/jayway/jsonpath/old/NullHandlingTest.java b/json-path/src/test/java/com/jayway/jsonpath/old/NullHandlingTest.java index 87b678d0..8e35c939 100644 --- a/json-path/src/test/java/com/jayway/jsonpath/old/NullHandlingTest.java +++ b/json-path/src/test/java/com/jayway/jsonpath/old/NullHandlingTest.java @@ -77,8 +77,9 @@ public class NullHandlingTest { List result = JsonPath.using(Configuration.defaultConfiguration().setOptions(Option.DEFAULT_PATH_LEAF_TO_NULL)).parse(json).read("a[?(@.b==5)].d"); + Assertions.assertThat(result).hasSize(1); + Assertions.assertThat(result.get(0)).isNull(); - System.out.println(result); } diff --git a/json-path/src/test/resources/simplelogger.properties b/json-path/src/test/resources/simplelogger.properties index 158cfb5f..eddc5f90 100644 --- a/json-path/src/test/resources/simplelogger.properties +++ b/json-path/src/test/resources/simplelogger.properties @@ -1 +1,2 @@ -#org.slf4j.simpleLogger.defaultLogLevel=warn \ No newline at end of file +org.slf4j.simpleLogger.log.com.jayway=debug +