11package com .fasterxml .jackson .databind ;
22
3- import java .io .*;
43import java .util .*;
54
65import com .fasterxml .jackson .annotation .*;
7- import org .junit .jupiter .api .Test ;
86
97import com .fasterxml .jackson .databind .type .TypeFactory ;
108
@@ -101,7 +99,7 @@ class FooNameImpl extends FooName { }
10199 */
102100 private final ObjectMapper MAPPER = newJsonMapper ();
103101
104- public void testConfigs () throws IOException
102+ public void testConfigs () throws Exception
105103 {
106104 byte [] base = jdkSerialize (MAPPER .getDeserializationConfig ().getBaseSettings ());
107105 assertNotNull (jdkDeserialize (base ));
@@ -122,7 +120,7 @@ public void testConfigs() throws IOException
122120 }
123121
124122 // for [databind#899]
125- public void testEnumHandlers () throws IOException
123+ public void testEnumHandlers () throws Exception
126124 {
127125 ObjectMapper mapper = newJsonMapper ();
128126 // ensure we have serializers and/or deserializers, first
@@ -155,7 +153,7 @@ public void testEnumHandlers() throws IOException
155153 assertNotNull (result2 );
156154 }
157155
158- public void testObjectWriter () throws IOException
156+ public void testObjectWriter () throws Exception
159157 {
160158 ObjectWriter origWriter = MAPPER .writer ();
161159 final String EXP_JSON = "{\" x\" :2,\" y\" :3}" ;
@@ -169,7 +167,7 @@ public void testObjectWriter() throws IOException
169167 assertEquals (EXP_JSON , writer2 .writeValueAsString (p ));
170168 }
171169
172- public void testObjectReader () throws IOException
170+ public void testObjectReader () throws Exception
173171 {
174172 ObjectReader origReader = MAPPER .readerFor (MyPojo .class );
175173 String JSON = "{\" x\" :1,\" y\" :2}" ;
@@ -189,7 +187,7 @@ public void testObjectReader() throws IOException
189187 assertEquals (Integer .valueOf (2 ), any2 .properties ().get ("y" ));
190188 }
191189
192- public void testObjectMapper () throws IOException
190+ public void testObjectMapper () throws Exception
193191 {
194192 final String EXP_JSON = "{\" x\" :2,\" y\" :3}" ;
195193 final MyPojo p = new MyPojo (2 , 3 );
@@ -236,13 +234,14 @@ public void testObjectReaderSerializationWithPolymorphism()
236234 };
237235
238236 for (Class <?> clazz : classes ) {
237+ // Should be enough to ask for reader for polymorphic type
238+ // (no need to actually serialize/deserialize)
239239 ObjectReader reader = newJsonMapper ()
240240 .readerFor (clazz );
241241
242- ByteArrayOutputStream baos = new ByteArrayOutputStream ();
243- ObjectOutputStream oos = new ObjectOutputStream (baos );
244- oos .writeObject (reader ); // This line should throw NotSerializableException
245- oos .close ();
242+ byte [] bytes = jdkSerialize (reader );
243+ ObjectReader result = jdkDeserialize (bytes );
244+ assertNotNull (result );
246245 }
247246 }
248247}
0 commit comments