diff --git a/pom.xml b/pom.xml
index 29283442..dcd32b17 100644
--- a/pom.xml
+++ b/pom.xml
@@ -113,6 +113,15 @@
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+
+ com/fasterxml/jackson/**/failing/*.java
+
+
+
diff --git a/src/test/java/com/fasterxml/jackson/datatype/joda/JodaTestBase.java b/src/test/java/com/fasterxml/jackson/datatype/joda/JodaTestBase.java
index 26fd065b..2765dd1d 100644
--- a/src/test/java/com/fasterxml/jackson/datatype/joda/JodaTestBase.java
+++ b/src/test/java/com/fasterxml/jackson/datatype/joda/JodaTestBase.java
@@ -1,5 +1,9 @@
package com.fasterxml.jackson.datatype.joda;
+import java.util.Arrays;
+
+import junit.framework.TestCase;
+
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -8,11 +12,6 @@
import com.fasterxml.jackson.databind.cfg.MapperBuilder;
import com.fasterxml.jackson.databind.json.JsonMapper;
-import junit.framework.TestCase;
-
-import java.io.IOException;
-import java.util.Arrays;
-
import org.joda.time.Instant;
import org.joda.time.YearMonth;
import org.joda.time.MonthDay;
@@ -102,17 +101,21 @@ protected void verifyException(Throwable e, String... matches)
fail("Expected an exception with one of substrings ("+Arrays.asList(matches)+"): got one with message \""+msg+"\"");
}
- public String quote(String str) {
+ public String q(String str) {
return '"'+str+'"';
}
- protected String aposToQuotes(String json) {
+ // @Deprecated
+ public String quote(String str) {
+ return q(str);
+ }
+
+ protected String a2q(String json) {
return json.replace("'", "\"");
}
- protected T readAndMapFromString(ObjectMapper m, String input, Class cls)
- throws IOException
- {
- return (T) m.readValue("\""+input+"\"", cls);
+ // @Deprecated
+ protected String aposToQuotes(String json) {
+ return a2q(json);
}
}
diff --git a/src/test/java/com/fasterxml/jackson/datatype/joda/failing/DateTimeSerializationWithOffsets146Test.java b/src/test/java/com/fasterxml/jackson/datatype/joda/failing/DateTimeSerializationWithOffsets146Test.java
new file mode 100644
index 00000000..d1c129c7
--- /dev/null
+++ b/src/test/java/com/fasterxml/jackson/datatype/joda/failing/DateTimeSerializationWithOffsets146Test.java
@@ -0,0 +1,31 @@
+package com.fasterxml.jackson.datatype.joda.failing;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+
+import com.fasterxml.jackson.datatype.joda.JodaTestBase;
+
+import org.joda.time.*;
+
+// [datatype-joda#146]: disable overwriting of timezone
+public class DateTimeSerializationWithOffsets146Test extends JodaTestBase
+{
+ private final ObjectMapper MAPPER = jodaMapper();
+ {
+ MAPPER.enable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
+ MAPPER.enable(SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS);
+ }
+
+ // [datatype-joda#146]
+ public void testLocalDateSer() throws Exception
+ {
+ final ObjectMapper MAPPER = mapperWithModuleBuilder()
+ .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
+ .disable(SerializationFeature.WRITE_DATES_WITH_CONTEXT_TIME_ZONE)
+ .build();
+ final String inputStr = "2024-12-01T00:00:00+02:00";
+
+ DateTime dateTime = DateTime.parse(inputStr);
+ assertEquals(q(inputStr), MAPPER.writeValueAsString(dateTime));
+ }
+}
diff --git a/src/test/java/com/fasterxml/jackson/datatype/joda/ser/JodaSerializationTest.java b/src/test/java/com/fasterxml/jackson/datatype/joda/ser/JodaSerializationTest.java
index 727af193..a508a97c 100644
--- a/src/test/java/com/fasterxml/jackson/datatype/joda/ser/JodaSerializationTest.java
+++ b/src/test/java/com/fasterxml/jackson/datatype/joda/ser/JodaSerializationTest.java
@@ -53,7 +53,7 @@ public void testLocalDateSer() throws IOException
// but we can force it to be a String as well (note: here we assume this is
// dynamically changeable)
- assertEquals(quote("2001-05-25"),
+ assertEquals(q("2001-05-25"),
WRITER.without(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).writeValueAsString(date));
// We can also configure beans to not include empty values. In this case,
@@ -96,7 +96,7 @@ public void testLocalTimeSer() throws IOException
// dynamically changeable)
ObjectMapper mapper = jodaMapper();
mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
- assertEquals(quote("13:20:54.000"), mapper.writeValueAsString(date));
+ assertEquals(q("13:20:54.000"), mapper.writeValueAsString(date));
}
@@ -113,9 +113,9 @@ public void testLocalTimeSerWithFormatOverride() throws IOException
.addModule(testModule)
.build();
- assertEquals(quote("13:20"), mapper.writeValueAsString(date));
+ assertEquals(q("13:20"), mapper.writeValueAsString(date));
- assertEquals(aposToQuotes("{'contents':'13:20'}"), mapper.writeValueAsString(new Container<>(date)));
+ assertEquals(a2q("{'contents':'13:20'}"), mapper.writeValueAsString(new Container<>(date)));
}
@@ -132,7 +132,6 @@ public void testLocalTimeSerWithTypeInfo() throws IOException
mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
assertEquals("[\"org.joda.time.LocalTime\",\"13:20:54.000\"]",
mapper.writeValueAsString(date));
-
}
/*
@@ -151,7 +150,7 @@ public void testLocalDateTimeSer() throws IOException
// dynamically changeable)
ObjectMapper mapper = jodaMapper();
mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
- assertEquals(quote("2001-05-25T10:15:30.037"), mapper.writeValueAsString(date));
+ assertEquals(q("2001-05-25T10:15:30.037"), mapper.writeValueAsString(date));
}
public void testLocalDateTimeSerWithTypeInfo() throws IOException
@@ -177,7 +176,7 @@ public void testLocalDateTimeSerWithTypeInfo() throws IOException
public void testPeriodSer() throws IOException
{
Period in = new Period(1, 2, 3, 4);
- assertEquals(quote("PT1H2M3.004S"), MAPPER.writeValueAsString(in));
+ assertEquals(q("PT1H2M3.004S"), MAPPER.writeValueAsString(in));
}
public void testPeriodSerWithTypeInfo() throws IOException
@@ -200,7 +199,7 @@ public void testDurationSer() throws IOException
String json = MAPPER.writeValueAsString(d);
assertEquals("3123422", json);
- assertEquals(quote("PT3123.422S"), MAPPER.writer()
+ assertEquals(q("PT3123.422S"), MAPPER.writer()
.without(SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS)
.writeValueAsString(d));
}
@@ -220,7 +219,7 @@ public void testMonthDaySer() throws Exception
MonthDay monthDay = new MonthDay(7, 23);
ObjectMapper mapper = jodaMapper();
String json = mapper.writeValueAsString(monthDay);
- assertEquals(quote("--07-23"), json);
+ assertEquals(q("--07-23"), json);
}
public void testCustomMonthDaySer() throws Exception
@@ -228,7 +227,7 @@ public void testCustomMonthDaySer() throws Exception
MonthDay monthDay = new MonthDay(7, 23);
ObjectMapper mapper = jodaMapper();
String json = mapper.writeValueAsString(new FormattedMonthDay(monthDay));
- assertEquals(aposToQuotes("{'value':'07:23'}"), json);
+ assertEquals(a2q("{'value':'07:23'}"), json);
}
public void testYearMonthSer() throws Exception
@@ -236,7 +235,7 @@ public void testYearMonthSer() throws Exception
YearMonth yearMonth = new YearMonth(2013, 8);
ObjectMapper mapper = jodaMapper();
String json = mapper.writeValueAsString(yearMonth);
- assertEquals(quote("2013-08"), json);
+ assertEquals(q("2013-08"), json);
}
public void testCustomYearMonthSer() throws Exception
@@ -244,6 +243,6 @@ public void testCustomYearMonthSer() throws Exception
YearMonth yearMonth = new YearMonth(2013, 8);
ObjectMapper mapper = jodaMapper();
String json = mapper.writeValueAsString(new FormattedYearMonth(yearMonth));
- assertEquals(aposToQuotes("{'value':'2013/08'}"), json);
+ assertEquals(a2q("{'value':'2013/08'}"), json);
}
}