Skip to content

Commit 491066d

Browse files
committed
fix a minor test fail wrt 3.0 changes
1 parent 909aa47 commit 491066d

File tree

2 files changed

+14
-31
lines changed

2 files changed

+14
-31
lines changed

datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/JavaTimeModule.java

-2
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@
9999
* @author Zoltan Kiss
100100
*
101101
* @since 2.6
102-
*
103-
* @see com.fasterxml.jackson.datatype.jsr310.ser.key.Jsr310NullKeySerializer
104102
*/
105103
public final class JavaTimeModule
106104
extends Module

datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/DurationDeserTest.java

+14-29
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ public void testDeserializationAsInt01() throws Exception
193193
{
194194
Duration value = READER.with(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS)
195195
.readValue("60");
196-
assertNotNull("The value should not be null.", value);
197196
assertEquals("The value is not correct.", Duration.ofSeconds(60L, 0), value);
198197
}
199198

@@ -202,8 +201,6 @@ public void testDeserializationAsInt02() throws Exception
202201
{
203202
Duration value = READER.without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS)
204203
.readValue("60000");
205-
206-
assertNotNull("The value should not be null.", value);
207204
assertEquals("The value is not correct.", Duration.ofSeconds(60L, 0), value);
208205
}
209206

@@ -212,8 +209,6 @@ public void testDeserializationAsInt03() throws Exception
212209
{
213210
Duration value = READER.with(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS)
214211
.readValue("13498");
215-
216-
assertNotNull("The value should not be null.", value);
217212
assertEquals("The value is not correct.", Duration.ofSeconds(13498L, 0), value);
218213
}
219214

@@ -222,8 +217,6 @@ public void testDeserializationAsInt04() throws Exception
222217
{
223218
Duration value = READER.without(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS)
224219
.readValue("13498000");
225-
226-
assertNotNull("The value should not be null.", value);
227220
assertEquals("The value is not correct.", Duration.ofSeconds(13498L, 0), value);
228221
}
229222

@@ -232,8 +225,6 @@ public void testDeserializationAsString01() throws Exception
232225
{
233226
Duration exp = Duration.ofSeconds(60L, 0);
234227
Duration value = READER.readValue('"' + exp.toString() + '"');
235-
236-
assertNotNull("The value should not be null.", value);
237228
assertEquals("The value is not correct.", exp, value);
238229
}
239230

@@ -242,16 +233,13 @@ public void testDeserializationAsString02() throws Exception
242233
{
243234
Duration exp = Duration.ofSeconds(13498L, 8374);
244235
Duration value = READER.readValue('"' + exp.toString() + '"');
245-
246-
assertNotNull("The value should not be null.", value);
247236
assertEquals("The value is not correct.", exp, value);
248237
}
249238

250239
@Test
251240
public void testDeserializationAsString03() throws Exception
252241
{
253-
Duration value = READER.readValue("\" \"");
254-
assertNull("The value should be null.", value);
242+
assertNull("The value should be null.", READER.readValue("\" \""));
255243
}
256244

257245
@Test
@@ -336,11 +324,11 @@ public void testDeserializationAsEmptyArrayDisabled() throws Throwable
336324
READER.readValue("[]");
337325
fail("expected MismatchedInputException");
338326
} catch (MismatchedInputException e) {
339-
verifyException(e, "Cannot deserialize instance of `java.time.Duration` out of START_ARRAY");
327+
// 17-Aug-2019, tatu: Message differs between 2.10 and 3.0...
328+
verifyException(e, "Cannot deserialize value of type `java.time.Duration` out of START_ARRAY");
340329
}
341330
try {
342-
newMapper().readerFor(Duration.class)
343-
.with(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS)
331+
READER.with(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS)
344332
.readValue(aposToQuotes("[]"));
345333
fail("expected MismatchedInputException");
346334
} catch (MismatchedInputException e) {
@@ -350,23 +338,20 @@ public void testDeserializationAsEmptyArrayDisabled() throws Throwable
350338

351339
@Test
352340
public void testDeserializationAsArrayEnabled() throws Exception {
353-
Duration exp = Duration.ofSeconds(13498L, 8374);
354-
Duration value = newMapper().readerFor(Duration.class)
355-
.with(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS)
356-
.readValue("[\"" + exp.toString() + "\"]");
357-
358-
assertNotNull("The value should not be null.", value);
359-
assertEquals("The value is not correct.", exp, value);
341+
Duration exp = Duration.ofSeconds(13498L, 8374);
342+
Duration value = newMapper().readerFor(Duration.class)
343+
.with(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS)
344+
.readValue("[\"" + exp.toString() + "\"]");
345+
assertEquals("The value is not correct.", exp, value);
360346
}
361347

362348
@Test
363349
public void testDeserializationAsEmptyArrayEnabled() throws Throwable
364350
{
365-
String json="[]";
366-
Duration value= newMapper().readerFor(Duration.class)
367-
.with(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS,
368-
DeserializationFeature.ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT)
369-
.readValue(aposToQuotes(json));
370-
assertNull(value);
351+
Duration value= newMapper().readerFor(Duration.class)
352+
.with(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS,
353+
DeserializationFeature.ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT)
354+
.readValue("[]");
355+
assertNull(value);
371356
}
372357
}

0 commit comments

Comments
 (0)