Skip to content

Commit

Permalink
Adding another failing test for FasterXML#1565.
Browse files Browse the repository at this point in the history
  • Loading branch information
slobo-showbie committed Jun 14, 2017
1 parent 6029344 commit 78bc4d6
Showing 1 changed file with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.fasterxml.jackson.failing;

import java.io.IOException;

import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonSubTypes.Type;
import com.fasterxml.jackson.annotation.JsonTypeInfo.As;
import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.BaseMapTest;
import com.fasterxml.jackson.databind.ObjectMapper;

public class TestDeserializePolymorphicDefaultImpl1565 extends BaseMapTest {

public void testDeserializeWithSameDefaultImplOnBothBaseClasses() throws JsonProcessingException, IOException {
try {
ObjectMapper om = objectMapper();
om.readerFor(Scenario.Sub1.class).readValue("{\"type\":\"sub1\"}");
fail("JsonProcessingException was not thrown.");
}
catch (IllegalArgumentException e) { // should this throw another type of exception?
}
}

/**
* Multiple levels of inheritance. 2 Base classes 3 Subs. TypeInfo on both higher and lower base class with same defaultImpl.
*/
static class Scenario {
@JsonTypeInfo(include=As.PROPERTY, property="type", use=Id.NAME, defaultImpl=Sub3.class)
@JsonSubTypes({@Type(name="sub1", value=Sub1.class), @Type(name="sub2", value=Sub2.class), @Type(name="sub3", value=Sub3.class)})
static abstract class BaseHigh {}
@JsonTypeInfo(include=As.PROPERTY, property="type", use=Id.NAME, defaultImpl=Sub3.class)
@JsonSubTypes({@Type(name="sub1", value=Sub1.class), @Type(name="sub2", value=Sub2.class)})
static abstract class BaseLow extends BaseHigh {}
static class Sub1 extends BaseLow {}
static class Sub2 extends BaseLow {}
static class Sub3 extends BaseHigh {}
}

}

0 comments on commit 78bc4d6

Please sign in to comment.