From 50688b852d1c80281fb7d8f6bfeec06380e8ae75 Mon Sep 17 00:00:00 2001 From: Dat Vu Date: Wed, 29 Mar 2023 10:46:06 +0700 Subject: [PATCH] update unit test --- .../test/java/com/jayway/jsonpath/Issue_908 | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 json-path/src/test/java/com/jayway/jsonpath/Issue_908 diff --git a/json-path/src/test/java/com/jayway/jsonpath/Issue_908 b/json-path/src/test/java/com/jayway/jsonpath/Issue_908 new file mode 100644 index 00000000..e905ca80 --- /dev/null +++ b/json-path/src/test/java/com/jayway/jsonpath/Issue_908 @@ -0,0 +1,25 @@ +package com.jayway.jsonpath; + +import org.junit.Test; + +public class Issue_908 { + + @Test(expected = InvalidPathException.class) + public void test_when_current_context_is_null() { + JsonPath + .parse("{\"test\" : null }") + .read("$.test[?(@ != null)]"); + } + + @Test + public void test_suppress_exception_when_current_context_is_null() { + + Object rs = JsonPath.using(Configuration.builder() + .options(Option.SUPPRESS_EXCEPTIONS).build()) + .parse("{\"test\" : null }") + .read("$.test[?(@ != null)]"); + System.out.println(rs); + assert(rs.toString().equals("[]")); + } + +}