-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent ClassCastException when deleting missing path with suppress e…
…xceptions enabled
- Loading branch information
Showing
2 changed files
with
67 additions
and
1 deletion.
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
65 changes: 65 additions & 0 deletions
65
json-path/src/test/java/com/jayway/jsonpath/DeleteMissingPathTest.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,65 @@ | ||
package com.jayway.jsonpath; | ||
|
||
import com.jayway.jsonpath.spi.json.*; | ||
import org.junit.Test; | ||
|
||
public class DeleteMissingPathTest { | ||
|
||
private DocumentContext getDocumentContextFromProvider(JsonProvider jsonProvider) { | ||
|
||
Configuration configuration = Configuration.builder() | ||
.jsonProvider(jsonProvider) | ||
.options(Option.SUPPRESS_EXCEPTIONS) | ||
.build(); | ||
|
||
return JsonPath.parse("{}", configuration); | ||
} | ||
|
||
@Test | ||
public void test_delete_missing_path_with_suppress_exceptions_does_not_throw_gson() { | ||
getDocumentContextFromProvider(new GsonJsonProvider()) | ||
.delete("$..this..path..is..missing"); | ||
} | ||
|
||
@Test | ||
public void test_delete_missing_path_with_suppress_exceptions_does_not_throw_jackson_json_node() { | ||
getDocumentContextFromProvider(new JacksonJsonNodeJsonProvider()) | ||
.delete("$..this..path..is..missing"); | ||
} | ||
|
||
@Test | ||
public void test_delete_missing_path_with_suppress_exceptions_does_not_throw_jackson() { | ||
getDocumentContextFromProvider(new JacksonJsonProvider()) | ||
.delete("$..this..path..is..missing"); | ||
} | ||
|
||
@Test | ||
public void test_delete_missing_path_with_suppress_exceptions_does_not_throw_jakarta() { | ||
getDocumentContextFromProvider(new JakartaJsonProvider()) | ||
.delete("$..this..path..is..missing"); | ||
} | ||
|
||
@Test | ||
public void test_delete_missing_path_with_suppress_exceptions_does_not_throw_jettison() { | ||
getDocumentContextFromProvider(new JettisonProvider()) | ||
.delete("$..this..path..is..missing"); | ||
} | ||
|
||
@Test | ||
public void test_delete_missing_path_with_suppress_exceptions_does_not_throw_json_org() { | ||
getDocumentContextFromProvider(new JsonOrgJsonProvider()) | ||
.delete("$..this..path..is..missing"); | ||
} | ||
|
||
@Test | ||
public void test_delete_missing_path_with_suppress_exceptions_does_not_throw_json_smart() { | ||
getDocumentContextFromProvider(new JsonSmartJsonProvider()) | ||
.delete("$..this..path..is..missing"); | ||
} | ||
|
||
@Test | ||
public void test_delete_missing_path_with_suppress_exceptions_does_not_throw_tapestry() { | ||
getDocumentContextFromProvider(new TapestryJsonProvider()) | ||
.delete("$..this..path..is..missing"); | ||
} | ||
} |