-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #4688 2.18.0-rc1 Regression deserializing with no-arg delegating …
…JsonCreator (#4689)
- Loading branch information
1 parent
5e0d5f6
commit 04a6719
Showing
4 changed files
with
89 additions
and
0 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
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
78 changes: 78 additions & 0 deletions
78
...st/java/com/fasterxml/jackson/databind/deser/creators/SingletonDelegatingCreatorTest.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,78 @@ | ||
package com.fasterxml.jackson.databind.deser.creators; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.testutil.DatabindTestUtil; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertSame; | ||
|
||
// [databind#4688] | ||
public class SingletonDelegatingCreatorTest extends DatabindTestUtil | ||
{ | ||
static final class NoFieldSingletonWithDelegatingCreator { | ||
static final NoFieldSingletonWithDelegatingCreator INSTANCE = new NoFieldSingletonWithDelegatingCreator(); | ||
|
||
private NoFieldSingletonWithDelegatingCreator() {} | ||
|
||
@JsonCreator(mode = JsonCreator.Mode.DELEGATING) | ||
static NoFieldSingletonWithDelegatingCreator of() { | ||
return INSTANCE; | ||
} | ||
} | ||
|
||
static final class NoFieldSingletonWithPropertiesCreator { | ||
static final NoFieldSingletonWithPropertiesCreator INSTANCE = new NoFieldSingletonWithPropertiesCreator(); | ||
|
||
private NoFieldSingletonWithPropertiesCreator() {} | ||
|
||
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES) | ||
static NoFieldSingletonWithPropertiesCreator of() { | ||
return INSTANCE; | ||
} | ||
} | ||
|
||
static final class NoFieldSingletonWithDefaultCreator { | ||
static final NoFieldSingletonWithDefaultCreator INSTANCE = new NoFieldSingletonWithDefaultCreator(); | ||
|
||
private NoFieldSingletonWithDefaultCreator() {} | ||
|
||
@JsonCreator | ||
static NoFieldSingletonWithDefaultCreator of() { | ||
return INSTANCE; | ||
} | ||
} | ||
|
||
/* | ||
/********************************************************************** | ||
/* Test methods | ||
/********************************************************************** | ||
*/ | ||
|
||
private final ObjectMapper MAPPER = newJsonMapper(); | ||
|
||
@Test | ||
public void testNoFieldSingletonWithDelegatingCreator() throws Exception | ||
{ | ||
NoFieldSingletonWithDelegatingCreator deserialized = MAPPER.readValue("{}", | ||
NoFieldSingletonWithDelegatingCreator.class); | ||
assertSame(NoFieldSingletonWithDelegatingCreator.INSTANCE, deserialized); | ||
} | ||
|
||
@Test | ||
public void testNoFieldSingletonWithPropertiesCreator() throws Exception | ||
{ | ||
NoFieldSingletonWithPropertiesCreator deserialized = MAPPER.readValue("{}", | ||
NoFieldSingletonWithPropertiesCreator.class); | ||
assertSame(NoFieldSingletonWithPropertiesCreator.INSTANCE, deserialized); | ||
} | ||
|
||
@Test | ||
public void testNoFieldSingletonWithDefaultCreator() throws Exception | ||
{ | ||
NoFieldSingletonWithDefaultCreator deserialized = MAPPER.readValue("{}", | ||
NoFieldSingletonWithDefaultCreator.class); | ||
assertSame(NoFieldSingletonWithDefaultCreator.INSTANCE, deserialized); | ||
} | ||
} |