|
1 |
| -package com.fasterxml.jackson.datatype.joda; |
| 1 | +package com.fasterxml.jackson.datatype.joda.deser; |
2 | 2 |
|
3 | 3 | import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
4 | 4 | import com.fasterxml.jackson.core.type.TypeReference;
|
5 | 5 | import com.fasterxml.jackson.databind.DeserializationFeature;
|
6 | 6 | import com.fasterxml.jackson.databind.JsonMappingException;
|
7 | 7 | import com.fasterxml.jackson.databind.ObjectMapper;
|
| 8 | +import com.fasterxml.jackson.datatype.joda.JodaTestBase; |
| 9 | + |
8 | 10 | import org.joda.time.*;
|
9 | 11 |
|
10 | 12 | import java.io.IOException;
|
|
18 | 20 | * Basic support is added for handling {@link DateTime}; more can be
|
19 | 21 | * added over time if and when requested.
|
20 | 22 | */
|
21 |
| -public class JodaDeserializationTest extends JodaTestBase |
| 23 | +public class MiscDeserializationTest extends JodaTestBase |
22 | 24 | {
|
23 | 25 | /*
|
24 | 26 | /**********************************************************
|
@@ -236,6 +238,10 @@ public void testIntervalDeser() throws IOException
|
236 | 238 | Interval interval = MAPPER.readValue(quote("1396439982-1396440001"), Interval.class);
|
237 | 239 | assertEquals(1396439982, interval.getStartMillis());
|
238 | 240 | assertEquals(1396440001, interval.getEndMillis());
|
| 241 | + |
| 242 | + interval = MAPPER.readValue(quote("-100-1396440001"), Interval.class); |
| 243 | + assertEquals(-100, interval.getStartMillis()); |
| 244 | + assertEquals(1396440001, interval.getEndMillis()); |
239 | 245 | }
|
240 | 246 |
|
241 | 247 | public void testIntervalDeserWithTypeInfo() throws IOException
|
@@ -433,6 +439,30 @@ public void testDateTimeKeyDeserialize() throws IOException {
|
433 | 439 | assertTrue(map.containsKey(DateTime.parse("1970-01-01T00:00:00.000Z")));
|
434 | 440 | }
|
435 | 441 |
|
| 442 | + public void testLocalDateKeyDeserialize() throws IOException { |
| 443 | + |
| 444 | + final String json = "{" + quote("2014-05-23") + ":0}"; |
| 445 | + final Map<LocalDate, Long> map = MAPPER.readValue(json, new TypeReference<Map<LocalDate, String>>() { }); |
| 446 | + |
| 447 | + assertNotNull(map); |
| 448 | + assertTrue(map.containsKey(LocalDate.parse("2014-05-23"))); |
| 449 | + } |
| 450 | + |
| 451 | + public void testLocalTimeKeyDeserialize() throws IOException { |
| 452 | + |
| 453 | + final String json = "{" + quote("00:00:00.000") + ":0}"; |
| 454 | + final Map<LocalTime, Long> map = MAPPER.readValue(json, new TypeReference<Map<LocalTime, String>>() { }); |
| 455 | + assertNotNull(map); |
| 456 | + assertTrue(map.containsKey(LocalTime.parse("00:00:00.000"))); |
| 457 | + } |
| 458 | + public void testLocalDateTimeKeyDeserialize() throws IOException { |
| 459 | + |
| 460 | + final String json = "{" + quote("2014-05-23T00:00:00.000") + ":0}"; |
| 461 | + final Map<LocalDateTime, Long> map = MAPPER.readValue(json, new TypeReference<Map<LocalDateTime, String>>() { }); |
| 462 | + assertNotNull(map); |
| 463 | + assertTrue(map.containsKey(LocalDateTime.parse("2014-05-23T00:00:00.000"))); |
| 464 | + } |
| 465 | + |
436 | 466 | public void testDeserMonthDay() throws Exception
|
437 | 467 | {
|
438 | 468 | String monthDayString = new MonthDay(7, 23).toString();
|
|
0 commit comments