@@ -32,14 +32,14 @@ enum Choice { YES, NO; }
32
32
* Another enum type, but this time forcing sub-classing
33
33
*/
34
34
enum ComplexChoice {
35
- MAYBE (true ), PROBABLY_NOT (false );
35
+ MAYBE (true ), PROBABLY_NOT (false );
36
36
37
- private boolean state ;
37
+ private boolean state ;
38
38
39
- private ComplexChoice (boolean b ) { state = b ; }
39
+ private ComplexChoice (boolean b ) { state = b ; }
40
40
41
41
@ Override
42
- public String toString () { return String .valueOf (state ); }
42
+ public String toString () { return String .valueOf (state ); }
43
43
}
44
44
45
45
// [JACKSON-311]
@@ -113,6 +113,24 @@ public void testBeanAsObject() throws Exception
113
113
assertEquals ("abc" , ((StringBean ) result [0 ]).name );
114
114
}
115
115
116
+ // with 2.5, another test to check that "as-property" is valid option
117
+ public void testBeanAsObjectUsingAsProperty () throws Exception
118
+ {
119
+ ObjectMapper m = new ObjectMapper ();
120
+ m .enableDefaultTypingAsProperty (ObjectMapper .DefaultTyping .NON_FINAL ,
121
+ ".hype" );
122
+ // note: need to wrap, to get declared as Object
123
+ String json = m .writeValueAsString (new StringBean ("abc" ));
124
+
125
+ System .err .println ("JSON == " +json );
126
+
127
+ // Ok: serialization seems to work as expected. Now deserialize:
128
+ Object result = m .readValue (json , Object .class );
129
+ assertNotNull (result );
130
+ assertEquals (StringBean .class , result .getClass ());
131
+ assertEquals ("abc" , ((StringBean ) result ).name );
132
+ }
133
+
116
134
/**
117
135
* Unit test that verifies that an abstract bean is stored with type information
118
136
* if default type information is enabled for non-concrete types.
0 commit comments