-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
102 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
...st/java/com/fasterxml/jackson/datatype/jsr310/misc/DeductionTypeSerialization296Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package com.fasterxml.jackson.datatype.jsr310.misc; | ||
|
||
import java.time.*; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import com.fasterxml.jackson.annotation.JsonTypeInfo; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.SerializationFeature; | ||
import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; | ||
|
||
// for [modules-java8#296]: problem with `JsonTypeInfo.Id.DEDUCTION` | ||
public class DeductionTypeSerialization296Test extends ModuleTestBase | ||
{ | ||
static class Wrapper { | ||
@JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION) | ||
public Object value; | ||
|
||
public Wrapper(Object value) { | ||
this.value = value; | ||
} | ||
} | ||
|
||
private final ObjectMapper MAPPER = mapperBuilder() | ||
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) | ||
.build(); | ||
|
||
@Test | ||
public void testLocalDate() throws Exception | ||
{ | ||
LocalDate date = LocalDate.of(1986, Month.JANUARY, 17); | ||
Assert.assertEquals(a2q("{'value':'1986-01-17'}"), | ||
MAPPER.writeValueAsString(new Wrapper(date))); | ||
} | ||
|
||
@Test | ||
public void testLocalDateTime() throws Exception | ||
{ | ||
LocalDateTime datetime = LocalDateTime.of(2013, Month.AUGUST, 21, 9, 22, 0, 57); | ||
Assert.assertEquals(a2q("{'value':'2013-08-21T09:22:00.000000057'}"), | ||
MAPPER.writeValueAsString(new Wrapper(datetime))); | ||
} | ||
|
||
@Test | ||
public void testLocalTime() throws Exception | ||
{ | ||
LocalTime time = LocalTime.of(9, 22, 57); | ||
Assert.assertEquals(a2q("{'value':'09:22:57'}"), | ||
MAPPER.writeValueAsString(new Wrapper(time))); | ||
} | ||
|
||
@Test | ||
public void testMonthDate() throws Exception | ||
{ | ||
MonthDay date = MonthDay.of(Month.JANUARY, 17); | ||
Assert.assertEquals(a2q("{'value':'--01-17'}"), | ||
MAPPER.writeValueAsString(new Wrapper(date))); | ||
} | ||
|
||
@Test | ||
public void testOffsetTime() throws Exception | ||
{ | ||
OffsetTime time = OffsetTime.of(15, 43, 0, 0, ZoneOffset.of("+0300")); | ||
Assert.assertEquals(a2q("{'value':'15:43+03:00'}"), | ||
MAPPER.writeValueAsString(new Wrapper(time))); | ||
} | ||
|
||
@Test | ||
public void testYearMonth() throws Exception | ||
{ | ||
YearMonth date = YearMonth.of(1986, Month.JANUARY); | ||
Assert.assertEquals(a2q("{'value':'1986-01'}"), | ||
MAPPER.writeValueAsString(new Wrapper(date))); | ||
} | ||
|
||
@Test | ||
public void testZoneId() throws Exception | ||
{ | ||
ZoneId zone = ZoneId.of("America/Denver"); | ||
Assert.assertEquals(a2q("{'value':'America/Denver'}"), | ||
MAPPER.writeValueAsString(new Wrapper(zone))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters