Skip to content

Commit c8a233c

Browse files
committed
...
1 parent ba3b369 commit c8a233c

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

src/test/java/com/fasterxml/jackson/databind/TestJDKSerialization.java renamed to src/test/java/com/fasterxml/jackson/databind/MapperJDKSerializationTest.java

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* platforms, such as Android, where memory management is handled
2323
* much more aggressively.
2424
*/
25-
public class TestJDKSerialization extends BaseMapTest
25+
public class MapperJDKSerializationTest extends BaseMapTest
2626
{
2727
static class MyPojo {
2828
public int x;
@@ -82,7 +82,7 @@ public void testConfigs() throws IOException
8282
assertNotNull(jdkDeserialize(base));
8383

8484
// first things first: underlying BaseSettings
85-
85+
8686
DeserializationConfig origDC = MAPPER.deserializationConfig();
8787
SerializationConfig origSC = MAPPER.serializationConfig();
8888
byte[] dcBytes = jdkSerialize(origDC);
@@ -185,7 +185,7 @@ public void testMapperWithModule() throws IOException
185185
byte[] b = jdkSerialize(module);
186186
assertNotNull(b);
187187
}
188-
188+
189189
ObjectMapper mapper = ObjectMapper.builder()
190190
.enable(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS)
191191
.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
@@ -199,12 +199,30 @@ public void testMapperWithModule() throws IOException
199199

200200
byte[] bytes = jdkSerialize(mapper);
201201
ObjectMapper mapper2 = jdkDeserialize(bytes);
202+
203+
// verify settings
204+
assertTrue(mapper.isEnabled(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS));
205+
assertTrue(mapper.isEnabled(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY));
206+
202207
assertEquals(EXP_JSON, mapper2.writeValueAsString(p));
203208
MyPojo p2 = mapper2.readValue(EXP_JSON, MyPojo.class);
204209
assertEquals(p.x, p2.x);
205210
assertEquals(p.y, p2.y);
211+
212+
// and then reconfigure a bit
213+
ObjectMapper mapper3 = mapper2.rebuild()
214+
.disable(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS)
215+
.disable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
216+
.build();
217+
assertFalse(mapper3.isEnabled(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS));
218+
assertFalse(mapper3.isEnabled(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY));
219+
bytes = jdkSerialize(mapper3);
220+
ObjectMapper mapper4 = jdkDeserialize(bytes);
221+
222+
assertFalse(mapper4.isEnabled(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS));
223+
assertFalse(mapper4.isEnabled(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY));
206224
}
207-
225+
208226
public void testTypeFactory() throws Exception
209227
{
210228
TypeFactory orig = TypeFactory.defaultInstance();

0 commit comments

Comments
 (0)