• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.fasterxml.jackson.failing;
2 
3 import java.util.*;
4 
5 import com.fasterxml.jackson.annotation.JsonCreator;
6 import com.fasterxml.jackson.databind.*;
7 
8 public class DelegatingCreatorWithAbstractProp2252Test extends BaseMapTest
9 {
10     static class DelegatingWithAbstractSetter
11     {
12         Map<String, Object> _stuff;
13 
14         @JsonCreator(mode = JsonCreator.Mode.DELEGATING)
DelegatingWithAbstractSetter(Map<String, Object> stuff)15         public DelegatingWithAbstractSetter(Map<String, Object> stuff) {
16             _stuff = stuff;
17         }
18 
setNeverUsed(MyAbstractList bogus)19         public void setNeverUsed(MyAbstractList bogus) { }
20     }
21 
22     // NOTE! Abstract POJO is fine, only Map/Collection causes issues for some reason
23 
24 //    static abstract class MyAbstractMap extends AbstractMap<String, Object> { }
25 
26     @SuppressWarnings("serial")
27     static abstract class MyAbstractList extends ArrayList<String> { }
28 
29     private final ObjectMapper MAPPER = newJsonMapper();
30 
31     // loosely based on [databind#2251], in which delegating creator is used, but
32     // theoretically necessary type for setter can cause issues -- shouldn't, as no
33     // setters (or fields, getter-as-setter) are ever needed due to delegation
testDelegatingWithUnsupportedSetterType()34     public void testDelegatingWithUnsupportedSetterType() throws Exception
35     {
36         DelegatingWithAbstractSetter result = MAPPER.readValue("{ \"bogus\": 3 }",DelegatingWithAbstractSetter.class);
37         assertNotNull(result);
38     }
39 }
40