File tree Expand file tree Collapse file tree
src/test/java/com/fasterxml/jackson/failing Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package com .fasterxml .jackson .failing ;
2+
3+ import java .util .*;
4+
5+ import com .fasterxml .jackson .annotation .JsonTypeInfo ;
6+ import com .fasterxml .jackson .databind .*;
7+
8+ // [databind#1391]
9+ public class DefaultTypingOverride1391Test extends BaseMapTest
10+ {
11+ final static ObjectMapper WITH_OBJECT_AND_NON_CONCRETE = new ObjectMapper ().enableDefaultTypingAsProperty (
12+ ObjectMapper .DefaultTyping .OBJECT_AND_NON_CONCRETE , "$type" );
13+
14+ final static ObjectMapper PLAIN_OBJECT_MAPPER = new ObjectMapper ();
15+
16+ static class MyClass {
17+
18+ private final SortedSet <String > treeSetStrings = new TreeSet <>();
19+
20+ @ JsonTypeInfo (use = JsonTypeInfo .Id .NONE )
21+ public SortedSet <String > getTreeSetStrings () {
22+ return this .treeSetStrings ;
23+ }
24+ }
25+
26+ public void testCollectionTyping () throws Exception {
27+
28+ final MyClass toSerialize = new MyClass ();
29+
30+ final String fromPlainObjectMapper = PLAIN_OBJECT_MAPPER .writeValueAsString (toSerialize );
31+ System .out .println ("\n from plain ObjectMapper:\n " + fromPlainObjectMapper );
32+
33+ final String fromObjectMapperWithDefaultTyping = WITH_OBJECT_AND_NON_CONCRETE .writeValueAsString (toSerialize );
34+ System .out .println ("\n from ObjectMapper with default typing:\n " + fromObjectMapperWithDefaultTyping );
35+
36+ assertEquals (fromPlainObjectMapper , fromObjectMapperWithDefaultTyping );
37+ }
38+ }
You can’t perform that action at this time.
0 commit comments