Skip to content

Commit 0a25195

Browse files
committed
Minor test streamlining
1 parent fa4898d commit 0a25195

File tree

7 files changed

+22
-20
lines changed

7 files changed

+22
-20
lines changed

src/test/java/com/fasterxml/jackson/databind/TestJDKSerialization.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public Map<String,Object> properties() {
6666
* ObjectMapper here can lead to strange unit test suite failures, so
6767
* let's create a private copy for this class only.
6868
*/
69-
private final ObjectMapper MAPPER = new ObjectMapper();
69+
private final ObjectMapper MAPPER = newJsonMapper();
7070

7171
public void testConfigs() throws IOException
7272
{
@@ -91,7 +91,7 @@ public void testConfigs() throws IOException
9191
// for [databind#899]
9292
public void testEnumHandlers() throws IOException
9393
{
94-
ObjectMapper mapper = new ObjectMapper();
94+
ObjectMapper mapper = newJsonMapper();
9595
// ensure we have serializers and/or deserializers, first
9696
String json = mapper.writerFor(EnumPOJO.class)
9797
.writeValueAsString(new EnumPOJO());
@@ -212,7 +212,7 @@ public void testLRUMap() throws Exception
212212

213213
protected byte[] jdkSerialize(Object o) throws IOException
214214
{
215-
ByteArrayOutputStream bytes = new ByteArrayOutputStream(1000);
215+
ByteArrayOutputStream bytes = new ByteArrayOutputStream(2000);
216216
ObjectOutputStream obOut = new ObjectOutputStream(bytes);
217217
obOut.writeObject(o);
218218
obOut.close();

src/test/java/com/fasterxml/jackson/databind/access/TestAnyGetterAccess.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public Map<?,?> getProperties()
5151
/**********************************************************
5252
*/
5353

54-
private final ObjectMapper MAPPER = new ObjectMapper();
54+
private final ObjectMapper MAPPER = newJsonMapper();
5555

5656
public void testDynaBean() throws Exception
5757
{

src/test/java/com/fasterxml/jackson/databind/big/TestBiggerData.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,11 @@ static class Area {
7272
/**********************************************************
7373
*/
7474

75+
private final ObjectMapper MAPPER = newJsonMapper();
76+
7577
public void testReading() throws Exception
7678
{
77-
ObjectMapper mapper = objectMapper();
78-
Citm citm = mapper.readValue(getClass().getResourceAsStream("/data/citm_catalog.json"),
79+
Citm citm = MAPPER.readValue(getClass().getResourceAsStream("/data/citm_catalog.json"),
7980
Citm.class);
8081
assertNotNull(citm);
8182
assertNotNull(citm.areaNames);
@@ -99,14 +100,13 @@ public void testReading() throws Exception
99100

100101
public void testRoundTrip() throws Exception
101102
{
102-
ObjectMapper mapper = objectMapper();
103-
Citm citm = mapper.readValue(getClass().getResourceAsStream("/data/citm_catalog.json"),
103+
Citm citm = MAPPER.readValue(getClass().getResourceAsStream("/data/citm_catalog.json"),
104104
Citm.class);
105105

106-
ObjectWriter w = mapper.writerWithDefaultPrettyPrinter();
106+
ObjectWriter w = MAPPER.writerWithDefaultPrettyPrinter();
107107

108108
String json1 = w.writeValueAsString(citm);
109-
Citm citm2 = mapper.readValue(json1, Citm.class);
109+
Citm citm2 = MAPPER.readValue(json1, Citm.class);
110110
String json2 = w.writeValueAsString(citm2);
111111

112112
assertEquals(json1, json2);

src/test/java/com/fasterxml/jackson/databind/contextual/TestContextualDeserialization.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
1515
import com.fasterxml.jackson.databind.deser.ContextualDeserializer;
1616
import com.fasterxml.jackson.databind.deser.std.StdScalarDeserializer;
17+
import com.fasterxml.jackson.databind.json.JsonMapper;
1718
import com.fasterxml.jackson.databind.module.SimpleModule;
1819

1920
/**
@@ -181,6 +182,12 @@ static class GenericBean {
181182
/**********************************************************
182183
*/
183184

185+
private final ObjectMapper ANNOTATED_CTXT_MAPPER = JsonMapper.builder()
186+
.addModule(new SimpleModule("test", Version.unknownVersion())
187+
.addDeserializer(StringValue.class, new AnnotatedContextualDeserializer()
188+
))
189+
.build();
190+
184191
public void testSimple() throws Exception
185192
{
186193
ObjectMapper mapper = new ObjectMapper();
@@ -296,12 +303,7 @@ public void testContextualType() throws Exception {
296303
/**********************************************************
297304
*/
298305

299-
private ObjectMapper _mapperWithAnnotatedContextual()
300-
{
301-
ObjectMapper mapper = new ObjectMapper();
302-
SimpleModule module = new SimpleModule("test", Version.unknownVersion());
303-
module.addDeserializer(StringValue.class, new AnnotatedContextualDeserializer());
304-
mapper.registerModule(module);
305-
return mapper;
306+
private ObjectMapper _mapperWithAnnotatedContextual() {
307+
return ANNOTATED_CTXT_MAPPER;
306308
}
307309
}

src/test/java/com/fasterxml/jackson/databind/deser/creators/ImplicitNameMatch792Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public String asString() {
8989
/**********************************************************
9090
*/
9191

92-
private final ObjectMapper MAPPER = objectMapper();
92+
private final ObjectMapper MAPPER = sharedMapper();
9393

9494
public void testBindingOfImplicitCreatorNames() throws Exception
9595
{

src/test/java/com/fasterxml/jackson/databind/ser/TestArraySerialization.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
public class TestArraySerialization
77
extends BaseMapTest
88
{
9-
private final ObjectMapper MAPPER = objectMapper();
9+
private final ObjectMapper MAPPER = newJsonMapper();
1010

1111
public void testLongStringArray() throws Exception
1212
{

src/test/java/com/fasterxml/jackson/databind/util/TestObjectBuffer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public void testTyped()
2929
private void _testObjectBuffer(Class<?> clz)
3030
{
3131
int[] SIZES = new int[] {
32-
3, 19, 99, 1007, 79000, 256001
32+
3, 19, 99, 1007, 19999, 99001
3333
};
3434

3535
// Let's loop separately for reused instance, new instance

0 commit comments

Comments
 (0)