forked from FasterXML/jackson-databind
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7d112ec
commit 5b3cc59
Showing
2 changed files
with
51 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
46 changes: 46 additions & 0 deletions
46
src/test/java/com/fasterxml/jackson/databind/exc/CustomExceptionDeser4071Test.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,46 @@ | ||
package com.fasterxml.jackson.databind.exc; | ||
|
||
import com.fasterxml.jackson.databind.BaseMapTest; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
// [databind#4071]: Ignore "message" for custom exceptions with only default constructor | ||
public class CustomExceptionDeser4071Test extends BaseMapTest | ||
{ | ||
static class CustomThrowable4071 extends Throwable { } | ||
|
||
static class CustomRuntimeException4071 extends RuntimeException { } | ||
|
||
static class CustomCheckedException4071 extends Exception { } | ||
|
||
private final ObjectMapper MAPPER = newJsonMapper(); | ||
|
||
public void testCustomException() throws Exception | ||
{ | ||
String exStr = MAPPER.writeValueAsString(new CustomThrowable4071()); | ||
assertNotNull(MAPPER.readValue(exStr, CustomThrowable4071.class)); | ||
} | ||
|
||
public void testCustomRuntimeException() throws Exception | ||
{ | ||
String exStr = MAPPER.writeValueAsString(new CustomRuntimeException4071()); | ||
assertNotNull(MAPPER.readValue(exStr, CustomRuntimeException4071.class)); | ||
} | ||
|
||
public void testCustomCheckedException() throws Exception | ||
{ | ||
String exStr = MAPPER.writeValueAsString(new CustomCheckedException4071()); | ||
assertNotNull(MAPPER.readValue(exStr, CustomCheckedException4071.class)); | ||
} | ||
|
||
public void testDeserAsThrowable() throws Exception | ||
{ | ||
_testDeserAsThrowable(MAPPER.writeValueAsString(new CustomRuntimeException4071())); | ||
_testDeserAsThrowable(MAPPER.writeValueAsString(new CustomCheckedException4071())); | ||
_testDeserAsThrowable(MAPPER.writeValueAsString(new CustomThrowable4071())); | ||
} | ||
|
||
private void _testDeserAsThrowable(String exStr) throws Exception | ||
{ | ||
assertNotNull(MAPPER.readValue(exStr, Throwable.class)); | ||
} | ||
} |