Skip to content

Commit

Permalink
Add failing test for FasterXML#1647
Browse files Browse the repository at this point in the history
  • Loading branch information
slobo-showbie committed Jun 8, 2017
1 parent e2476e0 commit f3ce171
Showing 1 changed file with 32 additions and 0 deletions.
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);
}
}

0 comments on commit f3ce171

Please sign in to comment.