File tree Expand file tree Collapse file tree 2 files changed +20
-34
lines changed
src/test/java/com/fasterxml/jackson Expand file tree Collapse file tree 2 files changed +20
-34
lines changed Original file line number Diff line number Diff line change 6
6
import com .fasterxml .jackson .annotation .JsonTypeInfo ;
7
7
8
8
import com .fasterxml .jackson .databind .*;
9
+ import com .fasterxml .jackson .databind .ObjectMapper .DefaultTyping ;
9
10
10
11
public class PolymorphicViaRefTypeTest extends BaseMapTest
11
12
{
@@ -28,6 +29,15 @@ static class TypeInfoAtomic {
28
29
public AtomicReference <BaseForAtomic > value ;
29
30
}
30
31
32
+ static class AtomicStringWrapper {
33
+ public AtomicReference <StringWrapper > wrapper ;
34
+
35
+ protected AtomicStringWrapper () { }
36
+ public AtomicStringWrapper (String str ) {
37
+ wrapper = new AtomicReference <StringWrapper >(new StringWrapper (str ));
38
+ }
39
+ }
40
+
31
41
/*
32
42
/**********************************************************************
33
43
/* Test methods
@@ -44,4 +54,14 @@ public void testPolymorphicAtomicRefProperty() throws Exception
44
54
TypeInfoAtomic result = MAPPER .readValue (json , TypeInfoAtomic .class );
45
55
assertNotNull (result );
46
56
}
57
+
58
+ public void testAtomicRefViaDefaultTyping () throws Exception
59
+ {
60
+ ObjectMapper mapper = new ObjectMapper ();
61
+ mapper .enableDefaultTyping (DefaultTyping .NON_FINAL );
62
+ AtomicStringWrapper data = new AtomicStringWrapper ("foo" );
63
+ String json = mapper .writerWithDefaultPrettyPrinter ().writeValueAsString (data );
64
+ AtomicStringWrapper result = mapper .readValue (json , AtomicStringWrapper .class );
65
+ assertNotNull (result );
66
+ }
47
67
}
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments