@@ -145,72 +145,5 @@ public void testTypeAsArray() throws Exception
145
145
assertEquals ("Amadeus" , doggie .get ("name" ));
146
146
assertEquals (Integer .valueOf (7 ), doggie .get ("boneCount" ));
147
147
}
148
-
149
- /* !!! 30-Jan-2010, tatus: I am not completely sure below works as it should
150
- * Problem is, context of "untyped" map should prevent type information
151
- * being added to Animal entries, because Object.class has no type.
152
- * If type information is included, it will not be useful for deserialization,
153
- * since static type does not carry through (unlike in serialization).
154
- *
155
- * But it is not quite clear how type information should be pushed through
156
- * array types...
157
- */
158
- @ SuppressWarnings ("unchecked" )
159
- @ Test
160
- public void testInArray () throws Exception
161
- {
162
- // ensure we'll use mapper with default configs
163
- ObjectMapper m = jsonMapperBuilder ()
164
- // ... so this should NOT be needed...
165
- .deactivateDefaultTyping ()
166
- .build ();
167
-
168
- Animal [] animals = new Animal [] { new Cat ("Miuku" , "white" ), new Dog ("Murre" , 9 ) };
169
- Map <String ,Object > map = new HashMap <String ,Object >();
170
- map .put ("a" , animals );
171
- String json = m .writeValueAsString (map );
172
- Map <String ,Object > result = m .readValue (json , Map .class );
173
- assertEquals (1 , result .size ());
174
- Object ob = result .get ("a" );
175
- if (!(ob instanceof List <?>)) {
176
- // 03-Feb-2010, tatu: Weird; seems to fail sometimes...
177
- fail ("Did not map to entry with 'a' as List (but as " +ob .getClass ().getName ()+"): JSON == '" +json +"'" );
178
- }
179
- List <?> l = (List <?>)ob ;
180
- assertNotNull (l );
181
- assertEquals (2 , l .size ());
182
- Map <?,?> a1 = (Map <?,?>) l .get (0 );
183
- assertEquals (3 , a1 .size ());
184
- String classProp = Id .CLASS .getDefaultPropertyName ();
185
- assertEquals (Cat .class .getName (), a1 .get (classProp ));
186
- Map <?,?> a2 = (Map <?,?>) l .get (1 );
187
- assertEquals (3 , a2 .size ());
188
- assertEquals (Dog .class .getName (), a2 .get (classProp ));
189
- }
190
-
191
- /**
192
- * Simple unit test to verify that serializing "empty" beans is ok
193
- */
194
- @ Test
195
- public void testEmptyBean () throws Exception
196
- {
197
- ObjectMapper m = jsonMapperBuilder ()
198
- .configure (SerializationFeature .FAIL_ON_EMPTY_BEANS , false )
199
- .build ();
200
- assertEquals ("{\" @type\" :\" empty\" }" , m .writeValueAsString (new Empty ()));
201
- }
202
-
203
- @ Test
204
- public void testTypedMaps () throws Exception
205
- {
206
- ObjectMapper mapper = newJsonMapper ();
207
-
208
- Map <Long , Collection <Super >> map = new HashMap <Long , Collection <Super >>();
209
- List <Super > list = new ArrayList <Super >();
210
- list .add (new A ());
211
- map .put (1L , list );
212
- String json = mapper .writerFor (new TypeReference <Map <Long , Collection <Super >>>() {}).writeValueAsString (map );
213
- assertTrue (json .contains ("@class" ), "JSON does not contain '@class': " +json );
214
- }
215
148
}
216
149
0 commit comments