Skip to content

Commit

Permalink
Added a failing test case for issue FasterXML#51.
Browse files Browse the repository at this point in the history
  • Loading branch information
clamothe committed Jan 12, 2015
1 parent f75ec11 commit 5329b00
Showing 1 changed file with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.fasterxml.jackson.datatype.joda;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonInclude;
import org.joda.time.*;

import com.fasterxml.jackson.annotation.JsonTypeInfo;
Expand Down Expand Up @@ -70,8 +73,14 @@ public void testLocalDateSer() throws IOException
ObjectMapper mapper = jodaMapper();
mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
assertEquals(quote("2001-05-25"), mapper.writeValueAsString(date));

// We can also configure beans to not include empty values. In this case,
// JodaDateSerializerBase#isEmpty is called to check if the value is empty.
mapper = jodaMapper();
mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
assertEquals("{\"contents\":[2001,5,25]}", mapper.writeValueAsString(new Container<LocalDate>(date)));
}

public void testLocalDateSerWithTypeInfo() throws IOException
{
LocalDate date = new LocalDate(2001, 5, 25);
Expand Down Expand Up @@ -229,4 +238,16 @@ public void testYearMonthSer() throws Exception
assertEquals(quote("2013-08"), json);
}

private static class Container<T> {
T contents;

public Container(T contents) {
this.contents = contents;
}

public T getContents() {
return contents;
}
}

}

0 comments on commit 5329b00

Please sign in to comment.