From 4e4e15f515b69dee32cf244b2e98636c6d3bf8fd Mon Sep 17 00:00:00 2001 From: kalle Date: Wed, 9 Feb 2011 08:32:23 +0100 Subject: [PATCH] changed hamcrest dependency from hamcrest-all to hamcrest-library --- json-path-assert/pom.xml | 5 +++-- .../jayway/jsonassert/impl/JsonAsserterImpl.java | 13 +++++++++---- json-path/pom.xml | 5 +++-- pom.xml | 7 ++++--- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/json-path-assert/pom.xml b/json-path-assert/pom.xml index bf8032fb..4b003130 100644 --- a/json-path-assert/pom.xml +++ b/json-path-assert/pom.xml @@ -14,7 +14,8 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> - + 4.0.0 json-path-parent @@ -46,7 +47,7 @@ org.hamcrest - hamcrest-all + hamcrest-library 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 fb650aaf..f2c38e2d 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 @@ -5,7 +5,6 @@ import com.jayway.jsonassert.JsonAsserter; import com.jayway.jsonpath.JsonPath; import com.jayway.jsonpath.PathUtil; import org.hamcrest.Matcher; -import org.hamcrest.MatcherAssert; import static java.lang.String.format; import static org.hamcrest.Matchers.*; @@ -40,9 +39,15 @@ public class JsonAsserterImpl implements JsonAsserter { String reason = "When processing json path: " + path; if (PathUtil.isPathDefinite(path)) { - MatcherAssert.assertThat(reason, JsonPath.readOne(jsonObject, path), matcher); + if (!matcher.matches(JsonPath.readOne(jsonObject, path))) { + throw new AssertionError(reason + matcher.toString()); + } + //MatcherAssert.assertThat(reason, JsonPath.readOne(jsonObject, path), matcher); } else { - MatcherAssert.assertThat(reason, (T) JsonPath.read(jsonObject, path), matcher); + if (!matcher.matches(JsonPath.read(jsonObject, path))) { + throw new AssertionError(reason + matcher.toString()); + } + //MatcherAssert.assertThat(reason, (T) JsonPath.read(jsonObject, path), matcher); } return this; } @@ -60,7 +65,7 @@ public class JsonAsserterImpl implements JsonAsserter { public JsonAsserter assertNotDefined(String path) { Object o = JsonPath.readOne(jsonObject, path); - if(o != null){ + if (o != null) { throw new AssertionError(format("Document contains the path <%s> but was expected not to.", path)); } return this; diff --git a/json-path/pom.xml b/json-path/pom.xml index 45ba5546..b462cdb0 100644 --- a/json-path/pom.xml +++ b/json-path/pom.xml @@ -14,7 +14,8 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> - + 4.0.0 com.jayway.jsonpath @@ -47,7 +48,7 @@ org.hamcrest - hamcrest-all + hamcrest-library test diff --git a/pom.xml b/pom.xml index d3b166dd..e021cac1 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,8 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> - + 4.0.0 org.sonatype.oss @@ -31,7 +32,7 @@ 2011 GitHub Issue Tracking - + @@ -139,7 +140,7 @@ org.hamcrest - hamcrest-all + hamcrest-library 1.1