Skip to content

Commit c3d435e

Browse files
committed
Merge branch '2.19'
2 parents 736f69b + e5ba92a commit c3d435e

27 files changed

+307
-108
lines changed

pom.xml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,20 @@ Joda (https://www.joda.org/joda-time/) data types.
7575

7676
<!-- And obviously also depends on Joda lib -->
7777
<dependency>
78-
<groupId>joda-time</groupId>
79-
<artifactId>joda-time</artifactId>
80-
<version>${version.joda}</version>
78+
<groupId>joda-time</groupId>
79+
<artifactId>joda-time</artifactId>
80+
<version>${version.joda}</version>
8181
</dependency>
8282

83-
<!-- 20-Apr-2024, tatu: JUnit4 no longer from jackson-base, so: -->
83+
<!-- Test dependencies -->
8484
<dependency>
85-
<groupId>junit</groupId>
86-
<artifactId>junit</artifactId>
85+
<groupId>org.junit.jupiter</groupId>
86+
<artifactId>junit-jupiter</artifactId>
87+
<scope>test</scope>
88+
</dependency>
89+
<dependency>
90+
<groupId>org.junit.jupiter</groupId>
91+
<artifactId>junit-jupiter-api</artifactId>
8792
<scope>test</scope>
8893
</dependency>
8994
</dependencies>

src/test/java/module-info.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
requires org.joda.time;
1111

1212
// Additional test lib/framework dependencies
13-
requires junit; // JUnit 4
13+
requires org.junit.jupiter.api; // JUnit 5
1414

1515
// Further, need to open up test packages for JUnit et al
1616
opens tools.jackson.datatype.joda;

src/test/java/tools/jackson/datatype/joda/AnnotationTest.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
package tools.jackson.datatype.joda;
22

3+
import org.junit.jupiter.api.Test;
4+
5+
import org.joda.time.DateTime;
6+
import org.joda.time.DateTimeZone;
7+
38
import tools.jackson.databind.ObjectMapper;
49
import tools.jackson.databind.annotation.JsonDeserialize;
510
import tools.jackson.databind.annotation.JsonSerialize;
611
import tools.jackson.datatype.joda.deser.DateTimeDeserializer;
712
import tools.jackson.datatype.joda.ser.DateTimeSerializer;
813

9-
import org.joda.time.DateTime;
10-
import org.joda.time.DateTimeZone;
14+
import static org.junit.jupiter.api.Assertions.assertEquals;
1115

1216
public class AnnotationTest extends DateTimeTest
1317
{
@@ -25,6 +29,7 @@ public void setCreatedOn(DateTime createdOn) {
2529
}
2630
}
2731

32+
@Test
2833
public void testDateTimeViaAnnotation() throws Exception {
2934
ObjectMapper objectMapper = new ObjectMapper();
3035
AClass initialObject = new AClass();

src/test/java/tools/jackson/datatype/joda/DateTimeTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import org.joda.time.DateTime;
66
import org.joda.time.DateTimeZone;
77

8+
import org.junit.jupiter.api.Test;
9+
810
import com.fasterxml.jackson.annotation.JsonCreator;
911
import com.fasterxml.jackson.annotation.JsonFormat;
1012
import com.fasterxml.jackson.annotation.JsonProperty;
@@ -15,6 +17,8 @@
1517
import tools.jackson.databind.ObjectMapper;
1618
import tools.jackson.databind.SerializationFeature;
1719

20+
import static org.junit.jupiter.api.Assertions.*;
21+
1822
public class DateTimeTest extends JodaTestBase
1923
{
2024
static class DateAsText {
@@ -93,13 +97,15 @@ private static interface TypeInfoMixIn {
9397
* First: let's ensure that serialization does not fail
9498
* with an error (see [JACKSON-157]).
9599
*/
100+
@Test
96101
public void testSerializationDefaultAsTimestamp() throws IOException
97102
{
98103
// let's use epoch time (Jan 1, 1970, UTC)
99104
// by default, dates use timestamp, so:
100105
assertEquals("0", MAPPER.writeValueAsString(DATE_JAN_1_1970_UTC));
101106
}
102107

108+
@Test
103109
public void testSerializationFeatureNoTimestamp() throws IOException
104110
{
105111
String json = MAPPER.writer()
@@ -108,6 +114,7 @@ public void testSerializationFeatureNoTimestamp() throws IOException
108114
assertEquals(quote("1970-01-01T00:00:00.000Z"), json);
109115
}
110116

117+
@Test
111118
public void testAnnotationAsText() throws IOException
112119
{
113120
ObjectMapper m = mapperWithModuleBuilder()
@@ -119,12 +126,14 @@ public void testAnnotationAsText() throws IOException
119126
}
120127

121128
// for [datatype-joda#70]
129+
@Test
122130
public void testAsTextNoMilliseconds() throws Exception
123131
{
124132
DateTime value = MAPPER.readValue(quote("2015-07-27T08:11:07-07:00"), DateTime.class);
125133
assertNotNull(value);
126134
}
127135

136+
@Test
128137
public void testCustomPatternStyle() throws IOException
129138
{
130139
// or, using annotations
@@ -143,6 +152,7 @@ public void testCustomPatternStyle() throws IOException
143152
assertEquals(aposToQuotes("{'date':'1/1/70 12:00 AM'}"), json);
144153
}
145154

155+
@Test
146156
public void testSerializationWithTypeInfo() throws IOException
147157
{
148158
// let's use epoch time (Jan 1, 1970, UTC)
@@ -159,6 +169,7 @@ public void testSerializationWithTypeInfo() throws IOException
159169
m.writeValueAsString(dt));
160170
}
161171

172+
@Test
162173
public void testIso8601ThroughJoda() throws Exception {
163174
ObjectMapper mapper = mapperWithModuleBuilder()
164175
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
@@ -185,6 +196,7 @@ public void testIso8601ThroughJoda() throws Exception {
185196
// assertEquals(expectedBean.jodaDateTime, actualBean.jodaDateTime);
186197
}
187198

199+
@Test
188200
public void testCustomFormat() throws Exception
189201
{
190202
String STR = "2015-06-19T19:05Z";
@@ -203,6 +215,7 @@ public void testCustomFormat() throws Exception
203215
assertEquals(inputDate.getMillis(), output.date.getMillis());
204216
}
205217

218+
@Test
206219
public void testWithTimeZoneOverride() throws Exception
207220
{
208221
DateTime date = MAPPER.readValue(quote("2014-01-20T08:59:01.000-0500"),
@@ -227,6 +240,7 @@ public void testWithTimeZoneOverride() throws Exception
227240
}
228241

229242
// since 2.8
243+
@Test
230244
public void testConfigOverrides() throws Exception
231245
{
232246
ObjectMapper mapper = mapperWithModuleBuilder()
@@ -249,6 +263,7 @@ public void testConfigOverrides() throws Exception
249263
}
250264

251265
// [datatype-joda#113] (NPE)
266+
@Test
252267
public void testWithoutLeniency() throws Exception
253268
{
254269
ObjectMapper mapper = mapperWithModuleBuilder()

src/test/java/tools/jackson/datatype/joda/JDKSerializabilityTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@
22

33
import java.io.*;
44

5+
import org.junit.jupiter.api.Test;
6+
57
import org.joda.time.DateTime;
68
import org.joda.time.DateTimeZone;
79

810
import tools.jackson.databind.*;
911

12+
import static org.junit.jupiter.api.Assertions.assertEquals;
13+
1014
public class JDKSerializabilityTest extends JodaTestBase
1115
{
16+
@Test
1217
public void testMapperWithModule() throws Exception {
1318
final DateTime input = new DateTime(0L, DateTimeZone.UTC);
1419
ObjectMapper mapper = mapperWithModule();

src/test/java/tools/jackson/datatype/joda/JodaTestBase.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
import java.util.Arrays;
55
import java.util.TimeZone;
66

7-
import junit.framework.TestCase;
7+
import org.joda.time.Instant;
8+
import org.joda.time.YearMonth;
9+
import org.joda.time.MonthDay;
810

911
import com.fasterxml.jackson.annotation.JsonFormat;
1012
import com.fasterxml.jackson.annotation.JsonTypeInfo;
@@ -13,13 +15,9 @@
1315
import tools.jackson.databind.cfg.CoercionInputShape;
1416
import tools.jackson.databind.json.JsonMapper;
1517

16-
import org.joda.time.Instant;
17-
import org.joda.time.YearMonth;
18-
import org.joda.time.MonthDay;
19-
20-
import static org.junit.Assert.*;
18+
import static org.junit.jupiter.api.Assertions.*;
2119

22-
public abstract class JodaTestBase extends TestCase
20+
public abstract class JodaTestBase
2321
{
2422
protected static class FormattedInstant {
2523
@JsonFormat(pattern = "dd/MM/yyyy HH_mm_ss_SSS")
@@ -98,10 +96,7 @@ protected static JsonMapper mapperWithFailFromEmptyString() {
9896
/**********************************************************************
9997
*/
10098

101-
protected void assertEquals(int[] exp, int[] act) {
102-
assertArrayEquals(exp, act);
103-
}
104-
99+
105100
/*
106101
/**********************************************************************
107102
/* Helper methods

src/test/java/tools/jackson/datatype/joda/MixedListTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,21 @@
22

33
import java.util.*;
44

5+
import org.junit.jupiter.api.Test;
6+
57
import org.joda.time.DateTime;
68
import org.joda.time.DateTimeZone;
79

810
import tools.jackson.core.type.TypeReference;
911
import tools.jackson.databind.ObjectMapper;
1012

13+
import static org.junit.jupiter.api.Assertions.*;
14+
1115
public class MixedListTest extends JodaTestBase
1216
{
1317
private final ObjectMapper MAPPER = mapperWithModule();
1418

19+
@Test
1520
public void testMixedList() throws Exception
1621
{
1722
final Map<String, Object> map = new HashMap<String, Object>();

src/test/java/tools/jackson/datatype/joda/TestVersions.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,19 @@
22

33
import java.io.*;
44

5+
import org.junit.jupiter.api.Test;
6+
57
import tools.jackson.core.Versioned;
68

9+
import static org.junit.jupiter.api.Assertions.*;
10+
711
/**
812
* Simple verification that version access works.
913
*/
1014
public class TestVersions extends JodaTestBase
1115
{
12-
public void testVersions() throws IOException
16+
@Test
17+
public void testVersions() throws Exception
1318
{
1419
JodaModule m = new JodaModule();
1520
assertVersion(m);

src/test/java/tools/jackson/datatype/joda/TimeZoneTest.java

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package tools.jackson.datatype.joda;
22

3+
import org.junit.jupiter.api.Test;
4+
35
import org.joda.time.DateTime;
46
import org.joda.time.DateTimeZone;
57

@@ -9,6 +11,8 @@
911

1012
import tools.jackson.databind.*;
1113

14+
import static org.junit.jupiter.api.Assertions.*;
15+
1216
// for [datatype-joda#44]
1317
public class TimeZoneTest extends JodaTestBase
1418
{
@@ -44,6 +48,7 @@ private static interface TypeInfoMixIn {
4448
.disable(JsonWriteFeature.ESCAPE_FORWARD_SLASHES)
4549
.build();
4650

51+
@Test
4752
public void testSimple() throws Exception
4853
{
4954
// First, no zone id included
@@ -78,6 +83,7 @@ public void testSimple() throws Exception
7883
*
7984
* https://github.com/FasterXML/jackson-datatype-joda/issues/73
8085
*/
86+
@Test
8187
public void testWriteDatesWithZoneIdAndConsistentZoneOffset() throws Exception
8288
{
8389
ObjectWriter w = MAPPER.writer();
@@ -89,6 +95,7 @@ public void testWriteDatesWithZoneIdAndConsistentZoneOffset() throws Exception
8995
.writeValueAsString(DATE_JAN_1_1970_UTC_IN_AMERICA_LA));
9096
}
9197

98+
@Test
9299
public void testRoundTrip() throws Exception
93100
{
94101
ObjectWriter w = MAPPER.writer()
@@ -105,14 +112,14 @@ public void testRoundTrip() throws Exception
105112
.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE)
106113
.build();
107114
result = mapper.readValue(json, DateTime.class);
108-
assertEquals("Actual timepoints differ", input.getMillis(), result.getMillis());
109-
assertEquals("TimeZones differ", input, result);
115+
assertEquals(input.getMillis(), result.getMillis(), "Actual timepoints differ");
116+
assertEquals(input, result, "TimeZones differ");
110117

111118
// Then timestamp: will not currently (2.6) write out timezone id
112119
json = w.with(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
113120
.writeValueAsString(input);
114121
result = mapper.readValue(json, DateTime.class);
115-
assertEquals("Actual timepoints differ", input.getMillis(), result.getMillis());
122+
assertEquals(input.getMillis(), result.getMillis(), "Actual timepoints differ");
116123

117124
// .. meaning we can not test this:
118125
// assertEquals("TimeZones differ", input, result);
@@ -122,6 +129,7 @@ public void testRoundTrip() throws Exception
122129
* Test that de/serializing an ambiguous time (e.g. a 'fall back' DST transition) works and preserves the proper
123130
* instants in time and time zones.
124131
*/
132+
@Test
125133
public void testFallBackTransition() throws Exception
126134
{
127135
DateTime firstOneAmUtc = new DateTime(FALL_BACK_YEAR, FALL_BACK_MONTH, FALL_BACK_DAY, FIRST_FALL_BACK_HOUR, 0, 0,
@@ -146,13 +154,14 @@ public void testFallBackTransition() throws Exception
146154
DateTime firstRoundTrip = mapper.readValue(firstOneAmStr, DateTime.class);
147155
DateTime secondRoundTrip = mapper.readValue(secondOneAmStr, DateTime.class);
148156

149-
assertEquals("Actual timepoints differ", firstOneAm.getMillis(), firstRoundTrip.getMillis());
150-
assertEquals("TimeZones differ", firstOneAm, firstRoundTrip);
157+
assertEquals(firstOneAm.getMillis(), firstRoundTrip.getMillis(), "Actual timepoints differ");
158+
assertEquals(firstOneAm, firstRoundTrip, "TimeZones differ");
151159

152-
assertEquals("Actual timepoints differ", secondOneAm.getMillis(), secondRoundTrip.getMillis());
153-
assertEquals("TimeZones differ", secondOneAm, secondRoundTrip);
160+
assertEquals(secondOneAm.getMillis(), secondRoundTrip.getMillis(), "Actual timepoints differ");
161+
assertEquals(secondOneAm, secondRoundTrip, "TimeZones differ");
154162
}
155163

164+
@Test
156165
public void testSerializationWithTypeInfo() throws Exception
157166
{
158167
// but if re-configured to include the time zone

0 commit comments

Comments
 (0)