From c88638c4efe092cda93224395ad31ae82c2d601e Mon Sep 17 00:00:00 2001 From: Kalle Stenflo Date: Mon, 4 Aug 2014 12:33:25 +0200 Subject: [PATCH] Fixed issues --- .../jsonassert/impl/JsonAsserterImpl.java | 8 +- .../com/jayway/jsonassert/JsonAssertTest.java | 10 +-- .../com/jayway/jsonpath/Configuration.java | 7 +- .../java/com/jayway/jsonpath/JsonPath.java | 9 +-- .../internal/spi/compiler/PathCompiler.java | 28 +++++-- .../internal/spi/compiler/PathToken.java | 2 +- .../java/com/jayway/jsonpath/IssuesTest.java | 78 ++++++++++++++++++- .../com/jayway/jsonpath/NullHandlingTest.java | 5 ++ .../internal/PropertyPathTokenTest.java | 14 +++- 9 files changed, 132 insertions(+), 29 deletions(-) diff --git a/json-path-assert/src/main/java/com/jayway/jsonassert/impl/JsonAsserterImpl.java b/json-path-assert/src/main/java/com/jayway/jsonassert/impl/JsonAsserterImpl.java index b4ebe937..2faa8aee 100644 --- a/json-path-assert/src/main/java/com/jayway/jsonassert/impl/JsonAsserterImpl.java +++ b/json-path-assert/src/main/java/com/jayway/jsonassert/impl/JsonAsserterImpl.java @@ -65,9 +65,7 @@ public class JsonAsserterImpl implements JsonAsserter { public JsonAsserter assertNotDefined(String path) { try { - //Object o = JsonPath.read(jsonObject, path); - - Configuration c = Configuration.builder().options(Option.THROW_ON_MISSING_PROPERTY).build(); + Configuration c = Configuration.defaultConfiguration(); JsonPath.using(c).parse(jsonObject).read(path); throw new AssertionError(format("Document contains the path <%s> but was expected not to.", path)); @@ -79,9 +77,7 @@ public class JsonAsserterImpl implements JsonAsserter { @Override public JsonAsserter assertNotDefined(String path, String message) { try { - //Object o = JsonPath.read(jsonObject, path); - - Configuration c = Configuration.builder().options(Option.THROW_ON_MISSING_PROPERTY).build(); + Configuration c = Configuration.defaultConfiguration(); JsonPath.using(c).parse(jsonObject).read(path); diff --git a/json-path-assert/src/test/java/com/jayway/jsonassert/JsonAssertTest.java b/json-path-assert/src/test/java/com/jayway/jsonassert/JsonAssertTest.java index e683aab4..d6cd02a3 100644 --- a/json-path-assert/src/test/java/com/jayway/jsonassert/JsonAssertTest.java +++ b/json-path-assert/src/test/java/com/jayway/jsonassert/JsonAssertTest.java @@ -55,20 +55,20 @@ public class JsonAssertTest { } @Test - @Ignore //TODO: finalize behaviour + //@Ignore //TODO: finalize behaviour public void links_document() throws Exception { with(getResourceAsStream("links.json")).assertEquals("count", 2) - .assertThat("links.gc:this.href", endsWith("?pageNumber=1&pageSize=2")) - .assertNotDefined("links.gc:prev") - .assertNotDefined("links.gc:next") + .assertThat("links['gc:this']href", endsWith("?pageNumber=1&pageSize=2")) + .assertNotDefined("links['gc:prev']") + .assertNotDefined("links['gc:next']") .assertThat("rows", collectionWithSize(equalTo(2))); } @Test - @Ignore //TODO: finalize behaviour + //@Ignore //TODO: finalize behaviour public void a_document_can_be_expected_not_to_contain_a_path() throws Exception { with(JSON).assertNotDefined("$.store.bicycle.cool"); } diff --git a/json-path/src/main/java/com/jayway/jsonpath/Configuration.java b/json-path/src/main/java/com/jayway/jsonpath/Configuration.java index a1d1a092..379e9ced 100644 --- a/json-path/src/main/java/com/jayway/jsonpath/Configuration.java +++ b/json-path/src/main/java/com/jayway/jsonpath/Configuration.java @@ -55,9 +55,14 @@ public class Configuration { } public Set