Skip to content

Commit

Permalink
Add test for #889, passes with 2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Aug 7, 2015
1 parent 4312a24 commit 2e364ba
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/test/java/com/fasterxml/jackson/databind/ser/TestConfig.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.fasterxml.jackson.databind.ser;

import java.io.StringWriter;
import java.text.SimpleDateFormat;
import java.util.*;

import com.fasterxml.jackson.annotation.*;
Expand Down Expand Up @@ -190,6 +191,32 @@ public void testNoAccessOverrides() throws Exception
m.disable(MapperFeature.CAN_OVERRIDE_ACCESS_MODIFIERS);
assertEquals("{\"x\":1}", m.writeValueAsString(new SimpleBean()));
}

public void testDateFormatConfig() throws Exception
{
ObjectMapper mapper = new ObjectMapper();
TimeZone tz1 = TimeZone.getTimeZone("America/Los_Angeles");
TimeZone tz2 = TimeZone.getTimeZone("Central Standard Time");

// sanity checks
assertEquals(tz1, tz1);
assertEquals(tz2, tz2);
if (tz1.equals(tz2)) {
fail();
}

mapper.setTimeZone(tz1);
assertEquals(tz1, mapper.getSerializationConfig().getTimeZone());
assertEquals(tz1, mapper.getDeserializationConfig().getTimeZone());

SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
f.setTimeZone(tz2);
mapper.setDateFormat(f);

// should not change the timezone tho
assertEquals(tz1, mapper.getSerializationConfig().getTimeZone());
assertEquals(tz1, mapper.getDeserializationConfig().getTimeZone());
}

private final static String getLF() {
return System.getProperty("line.separator");
Expand Down

0 comments on commit 2e364ba

Please sign in to comment.