From e748c60eb10ba5605ca6c00f37df0d843f9592bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bence=20Er=C5=91s?= Date: Tue, 26 Apr 2016 23:31:43 +0200 Subject: [PATCH] tests for improved failure handling --- src/test/org/json/junit/JSONPointerTest.java | 10 ++++++++++ src/test/org/json/junit/jsonpointer-testdoc.json | 5 ++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/test/org/json/junit/JSONPointerTest.java b/src/test/org/json/junit/JSONPointerTest.java index 103c5a8..3818e82 100644 --- a/src/test/org/json/junit/JSONPointerTest.java +++ b/src/test/org/json/junit/JSONPointerTest.java @@ -94,4 +94,14 @@ public class JSONPointerTest { new JSONPointer("key"); } + @Test(expected = JSONPointerException.class) + public void arrayIndexFailure() { + query("/foo/2"); + } + + @Test(expected = JSONPointerException.class) + public void primitiveFailure() { + query("/obj/key/failure"); + } + } diff --git a/src/test/org/json/junit/jsonpointer-testdoc.json b/src/test/org/json/junit/jsonpointer-testdoc.json index 386bdb7..621ce93 100644 --- a/src/test/org/json/junit/jsonpointer-testdoc.json +++ b/src/test/org/json/junit/jsonpointer-testdoc.json @@ -12,5 +12,8 @@ "i\\j": 5, "k\"l": 6, " ": 7, - "m~n": 8 + "m~n": 8, + "obj" : { + "key" : "value" + } } \ No newline at end of file