Skip to content

Commit 249a252

Browse files
committed
Add failing test for FasterXML#1647
1 parent 2f93aed commit 249a252

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.fasterxml.jackson.failing;
2+
3+
import java.io.IOException;
4+
5+
import com.fasterxml.jackson.annotation.JsonProperty;
6+
import com.fasterxml.jackson.databind.BaseMapTest;
7+
import com.fasterxml.jackson.databind.type.TypeFactory;
8+
9+
10+
// https://github.com/FasterXML/jackson-databind/issues/1647
11+
public class TestTypeFactoryWithRecursiveTypes extends BaseMapTest {
12+
13+
static interface IFace<T> {
14+
}
15+
16+
static class Base implements IFace<Sub> {
17+
@JsonProperty int base = 1;
18+
}
19+
20+
static class Sub extends Base {
21+
@JsonProperty int sub = 2;
22+
}
23+
24+
public void testBasePropertiesIncludedWhenSerializingSubWhenSubTypeLoadedAfterBaseType() throws IOException {
25+
TypeFactory tf = TypeFactory.defaultInstance();
26+
tf.constructType(Base.class);
27+
tf.constructType(Sub.class);
28+
Sub sub = new Sub();
29+
String serialized = objectMapper().writeValueAsString(sub);
30+
assertEquals("{\"base\":1,\"sub\":2}", serialized);
31+
}
32+
}

0 commit comments

Comments
 (0)