-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug 612 and add two testcases (#711)
* fix bug 612 * modify fix bug 612 * modify fix bug 612, add one more testcase Co-authored-by: CindyChow123 <CindyChow123>
- Loading branch information
1 parent
7384e96
commit 78a9420
Showing
3 changed files
with
63 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
json-path/src/test/java/com/jayway/jsonpath/internal/function/Issue612.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.jayway.jsonpath.internal.function; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.node.ArrayNode; | ||
import com.jayway.jsonpath.*; | ||
import com.jayway.jsonpath.spi.json.JacksonJsonNodeJsonProvider; | ||
import com.jayway.jsonpath.spi.mapper.JacksonMappingProvider; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import static com.jayway.jsonpath.JsonPath.using; | ||
import static com.jayway.jsonpath.internal.path.PathCompiler.fail; | ||
|
||
public class Issue612 { | ||
@Test | ||
public void test() { | ||
Configuration config = Configuration.builder() | ||
.options(Option.SUPPRESS_EXCEPTIONS) | ||
.build(); | ||
String json = "{\"1\":{\"2\":null}}"; | ||
DocumentContext documentContext = JsonPath.using(config).parse(json); | ||
JsonPath query = JsonPath.compile("$.1.2.a.b.c"); | ||
Assert.assertNull(documentContext.read(query)); | ||
Assert.assertNull(documentContext.map(query, (object, configuration) -> object)); | ||
} | ||
@Test(expected = Exception.class) | ||
public void test2() { | ||
Configuration config = Configuration.builder() | ||
.build(); | ||
String json = "{\"1\":{\"2\":null}}"; | ||
DocumentContext documentContext = JsonPath.using(config).parse(json); | ||
JsonPath query = JsonPath.compile("$.1.2.a.b.c"); | ||
documentContext.map(query, (object, configuration) -> object); | ||
} | ||
} |