Skip to content

Commit 11ecd87

Browse files
committed
Fix 3.0 tests wrt new escape-by-default slashes
1 parent 9bd9741 commit 11ecd87

7 files changed

+28
-10
lines changed

src/test/java/tools/jackson/datatype/joda/DateTimeTest.java

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import com.fasterxml.jackson.annotation.JsonFormat;
1010
import com.fasterxml.jackson.annotation.JsonProperty;
1111
import com.fasterxml.jackson.annotation.JsonTypeInfo;
12+
13+
import tools.jackson.core.json.JsonWriteFeature;
1214
import tools.jackson.databind.ObjectMapper;
1315
import tools.jackson.databind.SerializationFeature;
1416

@@ -79,6 +81,7 @@ private static interface TypeInfoMixIn {
7981
private final ObjectMapper MAPPER = mapperWithModule();
8082

8183
private final static ObjectMapper STRING_MAPPER = mapperWithModuleBuilder()
84+
.disable(JsonWriteFeature.ESCAPE_FORWARD_SLASHES)
8285
.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)
8386
.build();
8487

src/test/java/tools/jackson/datatype/joda/JodaTestBase.java

+7-8
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import tools.jackson.databind.ObjectMapper;
1212
import tools.jackson.databind.cfg.CoercionAction;
1313
import tools.jackson.databind.cfg.CoercionInputShape;
14-
import tools.jackson.databind.cfg.MapperBuilder;
1514
import tools.jackson.databind.json.JsonMapper;
1615

1716
import junit.framework.TestCase;
@@ -59,36 +58,36 @@ protected static interface MixinForPolymorphism {
5958
/**********************************************************************
6059
*/
6160

62-
protected static MapperBuilder<?,?> mapperWithModuleBuilder() {
61+
protected static JsonMapper.Builder mapperWithModuleBuilder() {
6362
return JsonMapper.builder()
6463
.addModule(new JodaModule());
6564
}
6665

67-
protected static MapperBuilder<?,?> jodaMapperBuilder(DateFormat df) {
66+
protected static JsonMapper.Builder jodaMapperBuilder(DateFormat df) {
6867
return mapperWithModuleBuilder()
6968
.defaultDateFormat(df);
7069
}
7170

72-
protected static MapperBuilder<?,?> jodaMapperBuilder(TimeZone tz) {
71+
protected static JsonMapper.Builder jodaMapperBuilder(TimeZone tz) {
7372
return mapperWithModuleBuilder()
7473
.defaultTimeZone(tz);
7574
}
7675

77-
protected static ObjectMapper mapperWithModule() {
76+
protected static JsonMapper mapperWithModule() {
7877
return mapperWithModuleBuilder().build();
7978
}
8079

81-
protected static ObjectMapper mapperWithModule(DateFormat df) {
80+
protected static JsonMapper mapperWithModule(DateFormat df) {
8281
return jodaMapperBuilder(df)
8382
.build();
8483
}
8584

86-
protected static ObjectMapper mapperWithModule(TimeZone tz) {
85+
protected static JsonMapper mapperWithModule(TimeZone tz) {
8786
return jodaMapperBuilder(tz)
8887
.build();
8988
}
9089

91-
protected static ObjectMapper mapperWithFailFromEmptyString() {
90+
protected static JsonMapper mapperWithFailFromEmptyString() {
9291
return mapperWithModuleBuilder()
9392
.withCoercionConfigDefaults(cfg ->
9493
cfg.setCoercion(CoercionInputShape.EmptyString, CoercionAction.Fail)

src/test/java/tools/jackson/datatype/joda/TimeZoneTest.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
import org.joda.time.DateTimeZone;
55

66
import com.fasterxml.jackson.annotation.JsonTypeInfo;
7+
8+
import tools.jackson.core.json.JsonWriteFeature;
9+
710
import tools.jackson.databind.*;
811

912
// for [datatype-joda#44]
@@ -37,7 +40,9 @@ private static interface TypeInfoMixIn {
3740
/**********************************************************
3841
*/
3942

40-
private final ObjectMapper MAPPER = mapperWithModule();
43+
private final ObjectMapper MAPPER = mapperWithModuleBuilder()
44+
.disable(JsonWriteFeature.ESCAPE_FORWARD_SLASHES)
45+
.build();
4146

4247
public void testSimple() throws Exception
4348
{

src/test/java/tools/jackson/datatype/joda/ser/InstantSerializationTest.java

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import org.joda.time.DateTime;
66
import org.joda.time.Instant;
77

8+
import tools.jackson.core.json.JsonWriteFeature;
89
import tools.jackson.databind.ObjectMapper;
910
import tools.jackson.databind.SerializationFeature;
1011
import tools.jackson.datatype.joda.JodaTestBase;
@@ -32,6 +33,7 @@ public void testCustomFormatInstantSer() throws Exception
3233
{
3334
final String json = MAPPER.writer()
3435
.without(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
36+
.without(JsonWriteFeature.ESCAPE_FORWARD_SLASHES)
3537
.writeValueAsString(new FormattedInstant(new Instant(0L)));
3638
assertEquals(aposToQuotes(
3739
"{'value':'01/01/1970 00_00_00_000'}"), json);

src/test/java/tools/jackson/datatype/joda/ser/IntervalSerializationTest.java

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
import com.fasterxml.jackson.annotation.JsonFormat;
99
import com.fasterxml.jackson.annotation.JsonTypeInfo;
10+
11+
import tools.jackson.core.json.JsonWriteFeature;
1012
import tools.jackson.databind.*;
1113
import tools.jackson.datatype.joda.JodaTestBase;
1214

@@ -31,6 +33,7 @@ static class FormattedInterval
3133
private final ObjectMapper MAPPER = mapperWithModuleBuilder()
3234
.enable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS,
3335
SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS)
36+
.disable(JsonWriteFeature.ESCAPE_FORWARD_SLASHES)
3437
.build();
3538

3639
private final ObjectWriter WRITER = MAPPER.writer();

src/test/java/tools/jackson/datatype/joda/ser/JodaSerializationTest.java

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.fasterxml.jackson.annotation.JsonInclude;
44
import com.fasterxml.jackson.annotation.JsonTypeInfo;
55

6+
import tools.jackson.core.json.JsonWriteFeature;
67
import tools.jackson.databind.ObjectMapper;
78
import tools.jackson.databind.ObjectWriter;
89
import tools.jackson.databind.SerializationFeature;
@@ -37,6 +38,7 @@ public T getContents() {
3738
private final ObjectMapper MAPPER = mapperWithModuleBuilder()
3839
.enable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS,
3940
SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS)
41+
.disable(JsonWriteFeature.ESCAPE_FORWARD_SLASHES)
4042
.build();
4143

4244
private final ObjectWriter WRITER = MAPPER.writer();

src/test/java/tools/jackson/datatype/joda/ser/WriteZoneIdTest.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import org.joda.time.DateTimeZone;
55

66
import com.fasterxml.jackson.annotation.JsonFormat;
7+
8+
import tools.jackson.core.json.JsonWriteFeature;
79
import tools.jackson.databind.ObjectMapper;
810
import tools.jackson.datatype.joda.JodaTestBase;
911

@@ -24,7 +26,9 @@ public DummyClassWithDate(DateTime date) {
2426

2527
public void testJacksonAnnotatedPOJOWithDateWithTimezoneToJson() throws Exception
2628
{
27-
ObjectMapper mapper = mapperWithModule();
29+
ObjectMapper mapper = mapperWithModuleBuilder()
30+
.disable(JsonWriteFeature.ESCAPE_FORWARD_SLASHES)
31+
.build();
2832
String ZONE_ID = "Asia/Krasnoyarsk";
2933

3034
DummyClassWithDate input = new DummyClassWithDate(new DateTime(2015, 11, 23, 22, 06, 39,

0 commit comments

Comments
 (0)