1
1
package com .fasterxml .jackson .databind ;
2
2
3
- import java .io .*;
4
3
import java .util .*;
5
4
6
5
import com .fasterxml .jackson .annotation .*;
7
- import org .junit .jupiter .api .Test ;
8
6
9
7
import com .fasterxml .jackson .databind .type .TypeFactory ;
10
8
@@ -101,7 +99,7 @@ class FooNameImpl extends FooName { }
101
99
*/
102
100
private final ObjectMapper MAPPER = newJsonMapper ();
103
101
104
- public void testConfigs () throws IOException
102
+ public void testConfigs () throws Exception
105
103
{
106
104
byte [] base = jdkSerialize (MAPPER .getDeserializationConfig ().getBaseSettings ());
107
105
assertNotNull (jdkDeserialize (base ));
@@ -122,7 +120,7 @@ public void testConfigs() throws IOException
122
120
}
123
121
124
122
// for [databind#899]
125
- public void testEnumHandlers () throws IOException
123
+ public void testEnumHandlers () throws Exception
126
124
{
127
125
ObjectMapper mapper = newJsonMapper ();
128
126
// ensure we have serializers and/or deserializers, first
@@ -155,7 +153,7 @@ public void testEnumHandlers() throws IOException
155
153
assertNotNull (result2 );
156
154
}
157
155
158
- public void testObjectWriter () throws IOException
156
+ public void testObjectWriter () throws Exception
159
157
{
160
158
ObjectWriter origWriter = MAPPER .writer ();
161
159
final String EXP_JSON = "{\" x\" :2,\" y\" :3}" ;
@@ -169,7 +167,7 @@ public void testObjectWriter() throws IOException
169
167
assertEquals (EXP_JSON , writer2 .writeValueAsString (p ));
170
168
}
171
169
172
- public void testObjectReader () throws IOException
170
+ public void testObjectReader () throws Exception
173
171
{
174
172
ObjectReader origReader = MAPPER .readerFor (MyPojo .class );
175
173
String JSON = "{\" x\" :1,\" y\" :2}" ;
@@ -189,7 +187,7 @@ public void testObjectReader() throws IOException
189
187
assertEquals (Integer .valueOf (2 ), any2 .properties ().get ("y" ));
190
188
}
191
189
192
- public void testObjectMapper () throws IOException
190
+ public void testObjectMapper () throws Exception
193
191
{
194
192
final String EXP_JSON = "{\" x\" :2,\" y\" :3}" ;
195
193
final MyPojo p = new MyPojo (2 , 3 );
@@ -236,13 +234,14 @@ public void testObjectReaderSerializationWithPolymorphism()
236
234
};
237
235
238
236
for (Class <?> clazz : classes ) {
237
+ // Should be enough to ask for reader for polymorphic type
238
+ // (no need to actually serialize/deserialize)
239
239
ObjectReader reader = newJsonMapper ()
240
240
.readerFor (clazz );
241
241
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 );
246
245
}
247
246
}
248
247
}
0 commit comments