Skip to content

Commit 18991f7

Browse files
committed
Fix 3.0 compilation
1 parent 9e73c85 commit 18991f7

26 files changed

+96
-82
lines changed

datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/ModuleTestBase.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import com.fasterxml.jackson.databind.ObjectMapper;
77
import com.fasterxml.jackson.databind.cfg.MapperBuilder;
8+
import com.fasterxml.jackson.databind.json.JsonMapper;
89

910
public class ModuleTestBase
1011
{
@@ -18,12 +19,12 @@ protected static ObjectMapper newMapper() {
1819
}
1920

2021
protected static MapperBuilder<?,?> newMapperBuilder() {
21-
return ObjectMapper.builder()
22+
return JsonMapper.builder()
2223
.addModule(new JavaTimeModule());
2324
}
2425

2526
protected static MapperBuilder<?,?> newMapperBuilder(TimeZone tz) {
26-
return ObjectMapper.builder()
27+
return JsonMapper.builder()
2728
.defaultTimeZone(tz)
2829
.addModule(new JavaTimeModule());
2930
}

datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/TestDurationKeySerialization.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
import com.fasterxml.jackson.core.type.TypeReference;
1010
import com.fasterxml.jackson.databind.ObjectMapper;
11+
import com.fasterxml.jackson.databind.json.JsonMapper;
12+
1113
import org.junit.Before;
1214
import org.junit.Test;
1315

@@ -23,7 +25,7 @@ public class TestDurationKeySerialization {
2325

2426
@Before
2527
public void setUp() {
26-
this.om = ObjectMapper.builder()
28+
this.om = JsonMapper.builder()
2729
.addModule(new JavaTimeModule())
2830
.build();
2931
map = new HashMap<>();

datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/TestInstantKeySerialization.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
import com.fasterxml.jackson.core.type.TypeReference;
1010
import com.fasterxml.jackson.databind.ObjectMapper;
11+
import com.fasterxml.jackson.databind.json.JsonMapper;
12+
1113
import org.junit.Assert;
1214
import org.junit.Before;
1315
import org.junit.Test;
@@ -26,7 +28,7 @@ public class TestInstantKeySerialization {
2628

2729
@Before
2830
public void setUp() {
29-
this.om = ObjectMapper.builder()
31+
this.om = JsonMapper.builder()
3032
.addModule(new JavaTimeModule())
3133
.build();
3234
map = new HashMap<>();

datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/TestLocalDateKeySerialization.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
import com.fasterxml.jackson.core.type.TypeReference;
1010
import com.fasterxml.jackson.databind.ObjectMapper;
11+
import com.fasterxml.jackson.databind.json.JsonMapper;
12+
1113
import org.junit.Before;
1214
import org.junit.Test;
1315

@@ -23,7 +25,7 @@ public class TestLocalDateKeySerialization {
2325

2426
@Before
2527
public void setUp() {
26-
this.om = ObjectMapper.builder()
28+
this.om = JsonMapper.builder()
2729
.addModule(new JavaTimeModule())
2830
.build();
2931
map = new HashMap<>();

datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/TestLocalDateSerializationWithCustomFormatter.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import static org.hamcrest.core.StringContains.containsString;
77

88
import com.fasterxml.jackson.databind.ObjectMapper;
9+
import com.fasterxml.jackson.databind.json.JsonMapper;
910
import com.fasterxml.jackson.databind.module.SimpleModule;
1011
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
1112
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
@@ -34,7 +35,7 @@ public void testSerialization() throws Exception {
3435
}
3536

3637
private String serializeWith(LocalDate date, DateTimeFormatter f) throws Exception {
37-
ObjectMapper mapper = ObjectMapper.builder()
38+
ObjectMapper mapper = JsonMapper.builder()
3839
.addModule(new SimpleModule()
3940
.addSerializer(new LocalDateSerializer(f)))
4041
.build();
@@ -48,7 +49,7 @@ public void testDeserialization() throws Exception {
4849
}
4950

5051
private LocalDate deserializeWith(String json, DateTimeFormatter f) throws Exception {
51-
ObjectMapper mapper = ObjectMapper.builder()
52+
ObjectMapper mapper = JsonMapper.builder()
5253
.addModule(new SimpleModule()
5354
.addDeserializer(LocalDate.class, new LocalDateDeserializer(f)))
5455
.build();

datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/TestLocalDateTimeDeserialization.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.fasterxml.jackson.databind.ObjectReader;
1111
import com.fasterxml.jackson.databind.deser.DeserializationProblemHandler;
1212
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
13+
import com.fasterxml.jackson.databind.json.JsonMapper;
1314

1415
import org.junit.Test;
1516

@@ -69,12 +70,11 @@ public void testDeserializationAsArrayEnabled() throws Throwable
6970
@Test
7071
public void testDeserializationAsEmptyArrayEnabled() throws Throwable
7172
{
72-
String json="[]";
73-
LocalDateTime value = ObjectMapper.builder()
73+
LocalDateTime value = JsonMapper.builder()
7474
.enable(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS,
7575
DeserializationFeature.ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT)
7676
.build()
77-
.readerFor(LocalDateTime.class).readValue(aposToQuotes(json));
77+
.readerFor(LocalDateTime.class).readValue("[]");
7878
assertNull(value);
7979
}
8080

datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/TestLocalDateTimeKeySerialization.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ public class TestLocalDateTimeKeySerialization
2828
private static final LocalDateTime DATE_TIME = LocalDateTime.of(2015, 3, 14, 9, 26, 53, 590 * 1000 * 1000);
2929
private static final String DATE_TIME_STRING = "2015-03-14T09:26:53.590";
3030

31-
private final ObjectMapper om = ObjectMapper.builder()
32-
.addModule(new JavaTimeModule())
33-
.build();
31+
private final ObjectMapper om = newMapper();
3432

3533
@Test
3634
public void testSerialization0() throws Exception {

datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/TestLocalDateTimeSerializationWithCustomFormatter.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import static org.hamcrest.core.StringContains.containsString;
66

77
import com.fasterxml.jackson.databind.ObjectMapper;
8+
import com.fasterxml.jackson.databind.json.JsonMapper;
89
import com.fasterxml.jackson.databind.module.SimpleModule;
910
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
1011
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
@@ -33,7 +34,7 @@ public void testSerialization() throws Exception {
3334
}
3435

3536
private String serializeWith(LocalDateTime dateTime, DateTimeFormatter f) throws Exception {
36-
ObjectMapper mapper = ObjectMapper.builder()
37+
ObjectMapper mapper = JsonMapper.builder()
3738
.addModule(new SimpleModule()
3839
.addSerializer(new LocalDateTimeSerializer(f)))
3940
.build();
@@ -47,7 +48,7 @@ public void testDeserialization() throws Exception {
4748
}
4849

4950
private LocalDateTime deserializeWith(String json, DateTimeFormatter f) throws Exception {
50-
ObjectMapper mapper = ObjectMapper.builder()
51+
ObjectMapper mapper = JsonMapper.builder()
5152
.addModule(new SimpleModule()
5253
.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(f)))
5354
.build();

datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/TestLocalTimeKeySerialization.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
import com.fasterxml.jackson.core.type.TypeReference;
88
import com.fasterxml.jackson.databind.ObjectMapper;
9+
import com.fasterxml.jackson.databind.json.JsonMapper;
10+
911
import org.junit.Assert;
1012
import org.junit.Before;
1113
import org.junit.Test;
@@ -27,7 +29,7 @@ public class TestLocalTimeKeySerialization {
2729

2830
@Before
2931
public void setUp() {
30-
this.om = ObjectMapper.builder()
32+
this.om = JsonMapper.builder()
3133
.addModule(new JavaTimeModule())
3234
.build();
3335
map = new HashMap<>();

datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/TestLocalTimeSerializationWithCustomFormatter.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import static org.hamcrest.core.StringContains.containsString;
66

77
import com.fasterxml.jackson.databind.ObjectMapper;
8+
import com.fasterxml.jackson.databind.json.JsonMapper;
89
import com.fasterxml.jackson.databind.module.SimpleModule;
910
import com.fasterxml.jackson.datatype.jsr310.deser.LocalTimeDeserializer;
1011
import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer;
@@ -33,7 +34,7 @@ public void testSerialization() throws Exception {
3334
}
3435

3536
private String serializeWith(LocalTime dateTime, DateTimeFormatter f) throws Exception {
36-
ObjectMapper mapper = ObjectMapper.builder()
37+
ObjectMapper mapper = JsonMapper.builder()
3738
.addModule(new SimpleModule()
3839
.addSerializer(new LocalTimeSerializer(f)))
3940
.build();
@@ -47,7 +48,7 @@ public void testDeserialization() throws Exception {
4748
}
4849

4950
private LocalTime deserializeWith(String json, DateTimeFormatter f) throws Exception {
50-
ObjectMapper mapper = ObjectMapper.builder()
51+
ObjectMapper mapper = JsonMapper.builder()
5152
.addModule(new SimpleModule()
5253
.addDeserializer(LocalTime.class, new LocalTimeDeserializer(f)))
5354
.build();

datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/TestMonthDayKeySerialization.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import com.fasterxml.jackson.core.type.TypeReference;
1111
import com.fasterxml.jackson.databind.ObjectMapper;
12+
import com.fasterxml.jackson.databind.json.JsonMapper;
1213

1314
public class TestMonthDayKeySerialization
1415
{
@@ -17,7 +18,7 @@ public class TestMonthDayKeySerialization
1718
private static final MonthDay MONTH_DAY = MonthDay.of(3, 14);
1819
private static final String MONTH_DAY_STRING = "--03-14";
1920

20-
private final ObjectMapper MAPPER = ObjectMapper.builder()
21+
private final ObjectMapper MAPPER = JsonMapper.builder()
2122
.addModule(new JavaTimeModule())
2223
.build();
2324

datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/TestMonthDaySerialization.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
import com.fasterxml.jackson.annotation.JsonFormat;
2828
import com.fasterxml.jackson.databind.ObjectMapper;
29+
import com.fasterxml.jackson.databind.json.JsonMapper;
2930

3031
import org.junit.Before;
3132
import org.junit.Test;
@@ -45,7 +46,7 @@ public Wrapper() { }
4546
@Before
4647
public void setUp()
4748
{
48-
MAPPER = ObjectMapper.builder()
49+
MAPPER = JsonMapper.builder()
4950
.addModule(new JavaTimeModule())
5051
.build();
5152
}
@@ -73,7 +74,7 @@ public void testSerialization02() throws Exception
7374
@Test
7475
public void testSerializationWithTypeInfo01() throws Exception
7576
{
76-
final ObjectMapper mapper = ObjectMapper.builder()
77+
final ObjectMapper mapper = JsonMapper.builder()
7778
.addModule(new JavaTimeModule())
7879
.addMixIn(TemporalAccessor.class, MockObjectConfiguration.class)
7980
.build();
@@ -105,7 +106,7 @@ public void testDeserialization02() throws Exception
105106
@Test
106107
public void testDeserializationWithTypeInfo01() throws Exception
107108
{
108-
final ObjectMapper mapper = ObjectMapper.builder()
109+
final ObjectMapper mapper = JsonMapper.builder()
109110
.addModule(new JavaTimeModule())
110111
.addMixIn(TemporalAccessor.class, MockObjectConfiguration.class)
111112
.build();

datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/TestOffsetDateTimeKeySerialization.java

+11-16
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88

99
import com.fasterxml.jackson.core.type.TypeReference;
1010
import com.fasterxml.jackson.databind.ObjectMapper;
11+
import com.fasterxml.jackson.databind.json.JsonMapper;
12+
1113
import org.junit.Assert;
12-
import org.junit.Before;
1314
import org.junit.Test;
1415

1516
public class TestOffsetDateTimeKeySerialization {
@@ -23,23 +24,13 @@ public class TestOffsetDateTimeKeySerialization {
2324
private static final OffsetDateTime DATE_TIME_2 = OffsetDateTime.of(2015, 3, 14, 9, 26, 53, 590 * 1000 * 1000, ZoneOffset.ofHours(6));
2425
private static final String DATE_TIME_2_STRING = "2015-03-14T09:26:53.590+06:00";
2526

26-
private ObjectMapper om;
27-
private Map<OffsetDateTime, String> map;
28-
29-
@Before
30-
public void setUp() {
31-
om = ObjectMapper.builder()
32-
.addModule(new JavaTimeModule())
33-
.build();
34-
map = new HashMap<>();
35-
}
36-
37-
/*
38-
* ObjectMapper configuration is not respected at deserialization and serialization at the moment.
39-
*/
27+
private ObjectMapper om = JsonMapper.builder()
28+
.addModule(new JavaTimeModule())
29+
.build();
4030

4131
@Test
4232
public void testSerialization0() throws Exception {
33+
Map<OffsetDateTime, String> map = new HashMap<>();
4334
map.put(DATE_TIME_0, "test");
4435

4536
String value = om.writeValueAsString(map);
@@ -49,6 +40,7 @@ public void testSerialization0() throws Exception {
4940

5041
@Test
5142
public void testSerialization1() throws Exception {
43+
Map<OffsetDateTime, String> map = new HashMap<>();
5244
map.put(DATE_TIME_1, "test");
5345

5446
String value = om.writeValueAsString(map);
@@ -58,6 +50,7 @@ public void testSerialization1() throws Exception {
5850

5951
@Test
6052
public void testSerialization2() throws Exception {
53+
Map<OffsetDateTime, String> map = new HashMap<>();
6154
map.put(DATE_TIME_2, "test");
6255

6356
String value = om.writeValueAsString(map);
@@ -69,6 +62,7 @@ public void testSerialization2() throws Exception {
6962
public void testDeserialization0() throws Exception {
7063
Map<OffsetDateTime, String> value = om.readValue(map(DATE_TIME_0_STRING, "test"), TYPE_REF);
7164

65+
Map<OffsetDateTime, String> map = new HashMap<>();
7266
map.put(DATE_TIME_0, "test");
7367
Assert.assertEquals("Value is incorrect", map, value);
7468
}
@@ -77,6 +71,7 @@ public void testDeserialization0() throws Exception {
7771
public void testDeserialization1() throws Exception {
7872
Map<OffsetDateTime, String> value = om.readValue(map(DATE_TIME_1_STRING, "test"), TYPE_REF);
7973

74+
Map<OffsetDateTime, String> map = new HashMap<>();
8075
map.put(DATE_TIME_1, "test");
8176
Assert.assertEquals("Value is incorrect", map, value);
8277
}
@@ -85,12 +80,12 @@ public void testDeserialization1() throws Exception {
8580
public void testDeserialization2() throws Exception {
8681
Map<OffsetDateTime, String> value = om.readValue(map(DATE_TIME_2_STRING, "test"), TYPE_REF);
8782

83+
Map<OffsetDateTime, String> map = new HashMap<>();
8884
map.put(DATE_TIME_2, "test");
8985
Assert.assertEquals("Value is incorrect", map, value);
9086
}
9187

9288
private String map(String key, String value) {
9389
return String.format("{\"%s\":\"%s\"}", key, value);
9490
}
95-
9691
}

datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/TestOffsetTimeKeySerialization.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
import com.fasterxml.jackson.core.type.TypeReference;
99
import com.fasterxml.jackson.databind.ObjectMapper;
10+
import com.fasterxml.jackson.databind.json.JsonMapper;
11+
1012
import org.junit.Assert;
1113
import org.junit.Before;
1214
import org.junit.Test;
@@ -22,14 +24,13 @@ public class TestOffsetTimeKeySerialization {
2224
private static final OffsetTime TIME_2 = OffsetTime.of(3, 14, 15, 920 * 1000 * 1000, ZoneOffset.ofHours(6));
2325
private static final String TIME_2_STRING = "03:14:15.920+06:00";
2426

25-
private ObjectMapper om;
27+
private ObjectMapper om = JsonMapper.builder()
28+
.addModule(new JavaTimeModule())
29+
.build();
2630
private Map<OffsetTime, String> map;
2731

2832
@Before
2933
public void setUp() {
30-
om = ObjectMapper.builder()
31-
.addModule(new JavaTimeModule())
32-
.build();
3334
map = new HashMap<>();
3435
}
3536

datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/TestPeriodKeySerialization.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
import com.fasterxml.jackson.core.type.TypeReference;
88
import com.fasterxml.jackson.databind.ObjectMapper;
9+
import com.fasterxml.jackson.databind.json.JsonMapper;
10+
911
import org.junit.Assert;
1012
import org.junit.Before;
1113
import org.junit.Test;
@@ -24,7 +26,7 @@ public class TestPeriodKeySerialization {
2426

2527
@Before
2628
public void setUp() {
27-
om = ObjectMapper.builder()
29+
om = JsonMapper.builder()
2830
.addModule(new JavaTimeModule())
2931
.build();
3032
map = new HashMap<>();

0 commit comments

Comments
 (0)