forked from FasterXML/jackson-databind
-
Notifications
You must be signed in to change notification settings - Fork 1
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
e2476e0
commit 9b9e47b
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
src/test/java/com/fasterxml/jackson/failing/TestTypeFactoryWithRecursiveTypes.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,32 @@ | ||
package com.fasterxml.jackson.failing; | ||
|
||
import java.io.IOException; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.databind.BaseMapTest; | ||
import com.fasterxml.jackson.databind.type.TypeFactory; | ||
|
||
|
||
// https://github.com/FasterXML/jackson-databind/issues/1647 | ||
public class TestTypeFactoryWithRecursiveTypes extends BaseMapTest { | ||
|
||
static interface IFace<T> { | ||
} | ||
|
||
static class Base implements IFace<Sub> { | ||
@JsonProperty int base = 1; | ||
} | ||
|
||
static class Sub extends Base { | ||
@JsonProperty int sub = 2; | ||
} | ||
|
||
public void testBasePropertiesIncludedWhenSerializingSubWhenSubTypeLoadedAfterBaseType() throws IOException { | ||
TypeFactory tf = TypeFactory.defaultInstance(); | ||
tf.constructType(Base.class); | ||
tf.constructType(Sub.class); | ||
Sub sub = new Sub(); | ||
String serialized = objectMapper().writeValueAsString(sub); | ||
assertEquals("{\"base\":1,\"sub\":2}", serialized); | ||
} | ||
} |