diff --git a/afterburner/src/test/java/module-info.java b/afterburner/src/test/java/module-info.java index 6d815570..05cc77fd 100644 --- a/afterburner/src/test/java/module-info.java +++ b/afterburner/src/test/java/module-info.java @@ -40,5 +40,6 @@ opens tools.jackson.module.afterburner.ser; opens tools.jackson.module.afterburner.ser.filter; opens tools.jackson.module.afterburner.testutil; + opens tools.jackson.module.afterburner.testutil.failure; opens tools.jackson.module.afterburner.util; } diff --git a/afterburner/src/test/java/tools/jackson/module/afterburner/deser/jdk/AfterburnerModuleJDKSerializability97Test.java b/afterburner/src/test/java/tools/jackson/module/afterburner/deser/jdk/AfterburnerModuleJDKSerializability97Test.java new file mode 100644 index 00000000..0c236f25 --- /dev/null +++ b/afterburner/src/test/java/tools/jackson/module/afterburner/deser/jdk/AfterburnerModuleJDKSerializability97Test.java @@ -0,0 +1,74 @@ +package tools.jackson.module.afterburner.deser.jdk; + +import java.io.*; + +import org.junit.jupiter.api.Test; + +import tools.jackson.databind.ObjectMapper; +import tools.jackson.module.afterburner.AfterburnerTestBase; + +import static org.junit.jupiter.api.Assertions.*; + +public class AfterburnerModuleJDKSerializability97Test extends AfterburnerTestBase +{ + static class Point { + public int x, y; + } + + // 19-Jan-2025, tatu: Fails on 2.x, works on 3.0+ + // But also test that after light use, ser/deser works + @Test + public void testMapperAfterUse() throws Exception + { + ObjectMapper mapper = newAfterburnerMapper(); + + // force use of mapper first + _serDeserPointWith(mapper); + + // then freeze/thaw + byte[] ser = jdkSerialize(mapper); + ObjectMapper m3 = jdkDeserialize(ser); + assertNotNull(m3); + + _serDeserPointWith(m3); + } + + /* + /********************************************************** + /* Helper methods + /********************************************************** + */ + + private void _serDeserPointWith(ObjectMapper mapper) throws Exception + { + final Point input = new Point(); + byte[] rawPoint = mapper.writeValueAsBytes(input); + Point result = mapper.readValue(rawPoint, Point.class); + assertNotNull(result); + assertEquals(input.x, result.x); + assertEquals(input.y, result.y); + } + + protected byte[] jdkSerialize(Object o) throws IOException + { + ByteArrayOutputStream bytes = new ByteArrayOutputStream(1000); + ObjectOutputStream obOut = new ObjectOutputStream(bytes); + obOut.writeObject(o); + obOut.close(); + return bytes.toByteArray(); + } + + @SuppressWarnings("unchecked") + protected T jdkDeserialize(byte[] raw) throws IOException + { + ObjectInputStream objIn = new ObjectInputStream(new ByteArrayInputStream(raw)); + try { + return (T) objIn.readObject(); + } catch (ClassNotFoundException e) { + fail("Missing class: "+e.getMessage()); + return null; + } finally { + objIn.close(); + } + } +} diff --git a/android-record/src/test/java/module-info.java b/android-record/src/test/java/module-info.java index 9a0644c6..d0a97e32 100644 --- a/android-record/src/test/java/module-info.java +++ b/android-record/src/test/java/module-info.java @@ -16,5 +16,6 @@ // Further, need to open up some packages for JUnit et al opens tools.jackson.module.androidrecord; - opens tools.jackson.module.androidrecord.failing; + opens tools.jackson.module.androidrecord.testutil.failure; + opens tools.jackson.module.androidrecord.tofix; } diff --git a/android-record/src/test/java/tools/jackson/module/androidrecord/failing/RecordBasicsFailingTest.java b/android-record/src/test/java/tools/jackson/module/androidrecord/tofix/RecordBasicsFailingTest.java similarity index 91% rename from android-record/src/test/java/tools/jackson/module/androidrecord/failing/RecordBasicsFailingTest.java rename to android-record/src/test/java/tools/jackson/module/androidrecord/tofix/RecordBasicsFailingTest.java index 5b61741a..75719e42 100644 --- a/android-record/src/test/java/tools/jackson/module/androidrecord/failing/RecordBasicsFailingTest.java +++ b/android-record/src/test/java/tools/jackson/module/androidrecord/tofix/RecordBasicsFailingTest.java @@ -1,4 +1,4 @@ -package tools.jackson.module.androidrecord.failing; +package tools.jackson.module.androidrecord.tofix; import org.junit.jupiter.api.Test; @@ -10,6 +10,7 @@ import tools.jackson.module.androidrecord.BaseMapTest; import tools.jackson.module.androidrecord.RecordBasicsTest; +import tools.jackson.module.androidrecord.testutil.failure.JacksonTestFailureExpected; import static org.junit.jupiter.api.Assertions.fail; @@ -48,6 +49,7 @@ public String name() { * * @see RecordBasicsTest#testDeserializeConstructorInjectRecord() */ + @JacksonTestFailureExpected @Test public void testDeserializeHeaderInjectRecord_WillFail() throws Exception { ObjectReader r = MAPPER.readerFor(RecordWithHeaderInject.class) diff --git a/android-record/src/test/java/tools/jackson/module/androidrecord/failing/RecordCreatorsFailingTest.java b/android-record/src/test/java/tools/jackson/module/androidrecord/tofix/RecordCreatorsFailingTest.java similarity index 92% rename from android-record/src/test/java/tools/jackson/module/androidrecord/failing/RecordCreatorsFailingTest.java rename to android-record/src/test/java/tools/jackson/module/androidrecord/tofix/RecordCreatorsFailingTest.java index a6b6a422..037e5571 100644 --- a/android-record/src/test/java/tools/jackson/module/androidrecord/failing/RecordCreatorsFailingTest.java +++ b/android-record/src/test/java/tools/jackson/module/androidrecord/tofix/RecordCreatorsFailingTest.java @@ -1,4 +1,4 @@ -package tools.jackson.module.androidrecord.failing; +package tools.jackson.module.androidrecord.tofix; import org.junit.jupiter.api.Test; @@ -10,6 +10,7 @@ import tools.jackson.databind.ObjectMapper; import tools.jackson.databind.exc.UnrecognizedPropertyException; import tools.jackson.module.androidrecord.BaseMapTest; +import tools.jackson.module.androidrecord.testutil.failure.JacksonTestFailureExpected; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.fail; @@ -49,6 +50,7 @@ public RecordWithAltCtor(@JsonProperty("id") int id) { */ // Fails: Implicit canonical constructor still works too + @JacksonTestFailureExpected @Test public void testDeserializeWithAltCtor() throws Exception { RecordWithAltCtor value = MAPPER.readValue("{\"id\":2812}", diff --git a/blackbird/src/test/java/module-info.java b/blackbird/src/test/java/module-info.java index d8b931ed..f7cc0c7f 100644 --- a/blackbird/src/test/java/module-info.java +++ b/blackbird/src/test/java/module-info.java @@ -30,12 +30,13 @@ opens tools.jackson.module.blackbird.deser.jdk; opens tools.jackson.module.blackbird.deser.merge; opens tools.jackson.module.blackbird.deser.struct; - opens tools.jackson.module.blackbird.failing; opens tools.jackson.module.blackbird.format; opens tools.jackson.module.blackbird.misc; opens tools.jackson.module.blackbird.objectid; opens tools.jackson.module.blackbird.roundtrip; opens tools.jackson.module.blackbird.ser; opens tools.jackson.module.blackbird.ser.filter; + opens tools.jackson.module.blackbird.tofix; opens tools.jackson.module.blackbird.testutil; + opens tools.jackson.module.blackbird.testutil.failure; } diff --git a/blackbird/src/test/java/tools/jackson/module/blackbird/util/failure/JacksonTestFailureExpected.java b/blackbird/src/test/java/tools/jackson/module/blackbird/testutil/failure/JacksonTestFailureExpected.java similarity index 94% rename from blackbird/src/test/java/tools/jackson/module/blackbird/util/failure/JacksonTestFailureExpected.java rename to blackbird/src/test/java/tools/jackson/module/blackbird/testutil/failure/JacksonTestFailureExpected.java index 622f617a..eac668c1 100644 --- a/blackbird/src/test/java/tools/jackson/module/blackbird/util/failure/JacksonTestFailureExpected.java +++ b/blackbird/src/test/java/tools/jackson/module/blackbird/testutil/failure/JacksonTestFailureExpected.java @@ -1,4 +1,4 @@ -package tools.jackson.module.blackbird.util.failure; +package tools.jackson.module.blackbird.testutil.failure; import java.lang.annotation.*; diff --git a/blackbird/src/test/java/tools/jackson/module/blackbird/util/failure/JacksonTestFailureExpectedInterceptor.java b/blackbird/src/test/java/tools/jackson/module/blackbird/testutil/failure/JacksonTestFailureExpectedInterceptor.java similarity index 96% rename from blackbird/src/test/java/tools/jackson/module/blackbird/util/failure/JacksonTestFailureExpectedInterceptor.java rename to blackbird/src/test/java/tools/jackson/module/blackbird/testutil/failure/JacksonTestFailureExpectedInterceptor.java index b27f5f46..07bfe0f8 100644 --- a/blackbird/src/test/java/tools/jackson/module/blackbird/util/failure/JacksonTestFailureExpectedInterceptor.java +++ b/blackbird/src/test/java/tools/jackson/module/blackbird/testutil/failure/JacksonTestFailureExpectedInterceptor.java @@ -1,4 +1,4 @@ -package tools.jackson.module.blackbird.util.failure; +package tools.jackson.module.blackbird.testutil.failure; import java.lang.reflect.Method; diff --git a/blackbird/src/test/java/tools/jackson/module/blackbird/util/failure/JacksonTestShouldFailException.java b/blackbird/src/test/java/tools/jackson/module/blackbird/testutil/failure/JacksonTestShouldFailException.java similarity index 87% rename from blackbird/src/test/java/tools/jackson/module/blackbird/util/failure/JacksonTestShouldFailException.java rename to blackbird/src/test/java/tools/jackson/module/blackbird/testutil/failure/JacksonTestShouldFailException.java index b06d19db..b76895af 100644 --- a/blackbird/src/test/java/tools/jackson/module/blackbird/util/failure/JacksonTestShouldFailException.java +++ b/blackbird/src/test/java/tools/jackson/module/blackbird/testutil/failure/JacksonTestShouldFailException.java @@ -1,4 +1,4 @@ -package tools.jackson.module.blackbird.util.failure; +package tools.jackson.module.blackbird.testutil.failure; /** * Exception used to alert that a test is passing, but should be failing. diff --git a/blackbird/src/test/java/tools/jackson/module/blackbird/failing/TestBBClassloaders.java b/blackbird/src/test/java/tools/jackson/module/blackbird/tofix/TestBBClassloaders.java similarity index 79% rename from blackbird/src/test/java/tools/jackson/module/blackbird/failing/TestBBClassloaders.java rename to blackbird/src/test/java/tools/jackson/module/blackbird/tofix/TestBBClassloaders.java index e84a9782..296e9a4a 100644 --- a/blackbird/src/test/java/tools/jackson/module/blackbird/failing/TestBBClassloaders.java +++ b/blackbird/src/test/java/tools/jackson/module/blackbird/tofix/TestBBClassloaders.java @@ -1,4 +1,4 @@ -package tools.jackson.module.blackbird.failing; +package tools.jackson.module.blackbird.tofix; import java.io.ByteArrayOutputStream; import java.io.InputStream; @@ -8,6 +8,7 @@ import tools.jackson.databind.ObjectMapper; import tools.jackson.module.blackbird.BlackbirdTestBase; +import tools.jackson.module.blackbird.testutil.failure.JacksonTestFailureExpected; import static org.junit.jupiter.api.Assertions.*; @@ -17,10 +18,19 @@ public class TestBBClassloaders extends BlackbirdTestBase (TestBBClassloaders.class.getName() + "$Data") .replace('.', '/').concat(".class"); - // Note: this test always passes in Java 8, even if the issue is not fixed, - // so it is duplicated in jackson-jdk11-compat-test for now + // Note: looks this test: passes on JDKs OTHER than 11 for Jackson 2.x, + // but fails for JDK 17+ for Jackson 3.x. @Test - public void testLoadInChildClassloader() throws Exception { + @JacksonTestFailureExpected + public void testLoadInChildClassloader() throws Exception + { + // 19-Jan-2025, tatu: only fails on JDK 11 specifically, not on JDK 17 or later + // + // So just skip on that + if (System.getProperty("java.version").startsWith("11.")) { + System.out.println("Skipping `testLoadInChildClassloader()` on JDK 11"); + return; + } TestLoader loader = new TestLoader(getClass().getClassLoader()); Class clazz = Class.forName(Data.class.getName(), true, loader); ObjectMapper mapper = newObjectMapper(); diff --git a/jakarta-xmlbind/src/test/java/module-info.java b/jakarta-xmlbind/src/test/java/module-info.java index e826a18c..f91552b8 100644 --- a/jakarta-xmlbind/src/test/java/module-info.java +++ b/jakarta-xmlbind/src/test/java/module-info.java @@ -19,10 +19,11 @@ // Further, need to open up some packages for JUnit et al opens tools.jackson.module.jakarta.xmlbind; opens tools.jackson.module.jakarta.xmlbind.adapters; - opens tools.jackson.module.jakarta.xmlbind.failing; opens tools.jackson.module.jakarta.xmlbind.id; opens tools.jackson.module.jakarta.xmlbind.introspect; opens tools.jackson.module.jakarta.xmlbind.misc; opens tools.jackson.module.jakarta.xmlbind.ser; + opens tools.jackson.module.jakarta.xmlbind.testutil.failure; + opens tools.jackson.module.jakarta.xmlbind.tofix; opens tools.jackson.module.jakarta.xmlbind.types; } diff --git a/jakarta-xmlbind/src/test/java/tools/jackson/module/jakarta/xmlbind/failing/TestUnwrapping.java b/jakarta-xmlbind/src/test/java/tools/jackson/module/jakarta/xmlbind/tofix/TestUnwrapping.java similarity index 92% rename from jakarta-xmlbind/src/test/java/tools/jackson/module/jakarta/xmlbind/failing/TestUnwrapping.java rename to jakarta-xmlbind/src/test/java/tools/jackson/module/jakarta/xmlbind/tofix/TestUnwrapping.java index 0c7e24b1..7e1ce76e 100644 --- a/jakarta-xmlbind/src/test/java/tools/jackson/module/jakarta/xmlbind/failing/TestUnwrapping.java +++ b/jakarta-xmlbind/src/test/java/tools/jackson/module/jakarta/xmlbind/tofix/TestUnwrapping.java @@ -1,4 +1,4 @@ -package tools.jackson.module.jakarta.xmlbind.failing; +package tools.jackson.module.jakarta.xmlbind.tofix; import org.junit.jupiter.api.Test; @@ -12,6 +12,7 @@ import tools.jackson.module.jakarta.xmlbind.JakartaXmlBindAnnotationIntrospector; import tools.jackson.module.jakarta.xmlbind.ModuleTestBase; +import tools.jackson.module.jakarta.xmlbind.testutil.failure.JacksonTestFailureExpected; import static org.junit.jupiter.api.Assertions.*; @@ -57,6 +58,7 @@ public B(String type) { */ // not asserting anything + @JacksonTestFailureExpected @Test public void testXmlElementAndXmlElementRefs() throws Exception { diff --git a/jakarta-xmlbind/src/test/java/tools/jackson/module/jakarta/xmlbind/failing/TestXmlID3.java b/jakarta-xmlbind/src/test/java/tools/jackson/module/jakarta/xmlbind/tofix/TestXmlID3.java similarity index 91% rename from jakarta-xmlbind/src/test/java/tools/jackson/module/jakarta/xmlbind/failing/TestXmlID3.java rename to jakarta-xmlbind/src/test/java/tools/jackson/module/jakarta/xmlbind/tofix/TestXmlID3.java index 28acbab6..1d679d27 100644 --- a/jakarta-xmlbind/src/test/java/tools/jackson/module/jakarta/xmlbind/failing/TestXmlID3.java +++ b/jakarta-xmlbind/src/test/java/tools/jackson/module/jakarta/xmlbind/tofix/TestXmlID3.java @@ -1,4 +1,4 @@ -package tools.jackson.module.jakarta.xmlbind.failing; +package tools.jackson.module.jakarta.xmlbind.tofix; import java.util.Arrays; import java.util.List; @@ -10,6 +10,7 @@ import tools.jackson.databind.ObjectMapper; import tools.jackson.module.jakarta.xmlbind.ModuleTestBase; +import tools.jackson.module.jakarta.xmlbind.testutil.failure.JacksonTestFailureExpected; import static org.junit.jupiter.api.Assertions.*; @@ -49,6 +50,7 @@ static class HasIDList public HasID getParent() { return parent; } } + @JacksonTestFailureExpected @Test public void testIssue46() throws Exception { diff --git a/jaxb/src/test/java/module-info.java b/jaxb/src/test/java/module-info.java index 6c911baf..d748bd4c 100644 --- a/jaxb/src/test/java/module-info.java +++ b/jaxb/src/test/java/module-info.java @@ -21,10 +21,11 @@ opens tools.jackson.module.jaxb; opens tools.jackson.module.jaxb.adapters; - opens tools.jackson.module.jaxb.failing; opens tools.jackson.module.jaxb.id; opens tools.jackson.module.jaxb.introspect; opens tools.jackson.module.jaxb.misc; opens tools.jackson.module.jaxb.ser; + opens tools.jackson.module.jaxb.testutil.failure; + opens tools.jackson.module.jaxb.tofix; opens tools.jackson.module.jaxb.types; } diff --git a/jaxb/src/test/java/tools/jackson/module/jaxb/failing/TestEnums256.java b/jaxb/src/test/java/tools/jackson/module/jaxb/tofix/TestEnums256.java similarity index 89% rename from jaxb/src/test/java/tools/jackson/module/jaxb/failing/TestEnums256.java rename to jaxb/src/test/java/tools/jackson/module/jaxb/tofix/TestEnums256.java index 11396574..f114ee44 100644 --- a/jaxb/src/test/java/tools/jackson/module/jaxb/failing/TestEnums256.java +++ b/jaxb/src/test/java/tools/jackson/module/jaxb/tofix/TestEnums256.java @@ -1,4 +1,4 @@ -package tools.jackson.module.jaxb.failing; +package tools.jackson.module.jaxb.tofix; import javax.xml.bind.annotation.*; import javax.xml.bind.annotation.adapters.*; @@ -7,6 +7,7 @@ import tools.jackson.databind.ObjectMapper; import tools.jackson.module.jaxb.BaseJaxbTest; +import tools.jackson.module.jaxb.testutil.failure.JacksonTestFailureExpected; import static org.junit.jupiter.api.Assertions.*; @@ -44,6 +45,7 @@ public enum Code { private final ObjectMapper MAPPER = getJaxbMapper(); // [modules-base#256] + @JacksonTestFailureExpected @Test public void testEnumSerialize256() throws Exception { diff --git a/jaxb/src/test/java/tools/jackson/module/jaxb/failing/TestUnwrapping.java b/jaxb/src/test/java/tools/jackson/module/jaxb/tofix/TestUnwrapping.java similarity index 93% rename from jaxb/src/test/java/tools/jackson/module/jaxb/failing/TestUnwrapping.java rename to jaxb/src/test/java/tools/jackson/module/jaxb/tofix/TestUnwrapping.java index d27f02d3..791f524a 100644 --- a/jaxb/src/test/java/tools/jackson/module/jaxb/failing/TestUnwrapping.java +++ b/jaxb/src/test/java/tools/jackson/module/jaxb/tofix/TestUnwrapping.java @@ -1,4 +1,4 @@ -package tools.jackson.module.jaxb.failing; +package tools.jackson.module.jaxb.tofix; import javax.xml.bind.annotation.*; @@ -12,6 +12,7 @@ import tools.jackson.module.jaxb.BaseJaxbTest; import tools.jackson.module.jaxb.JaxbAnnotationIntrospector; +import tools.jackson.module.jaxb.testutil.failure.JacksonTestFailureExpected; import static org.junit.jupiter.api.Assertions.*; @@ -57,6 +58,7 @@ public B(String type) { */ // not asserting anything + @JacksonTestFailureExpected @Test public void testXmlElementAndXmlElementRefs() throws Exception { diff --git a/jaxb/src/test/java/tools/jackson/module/jaxb/failing/TestXmlID3.java b/jaxb/src/test/java/tools/jackson/module/jaxb/tofix/TestXmlID3.java similarity index 92% rename from jaxb/src/test/java/tools/jackson/module/jaxb/failing/TestXmlID3.java rename to jaxb/src/test/java/tools/jackson/module/jaxb/tofix/TestXmlID3.java index b8641037..1b30aff0 100644 --- a/jaxb/src/test/java/tools/jackson/module/jaxb/failing/TestXmlID3.java +++ b/jaxb/src/test/java/tools/jackson/module/jaxb/tofix/TestXmlID3.java @@ -1,4 +1,4 @@ -package tools.jackson.module.jaxb.failing; +package tools.jackson.module.jaxb.tofix; import java.util.Arrays; import java.util.List; @@ -10,6 +10,7 @@ import tools.jackson.databind.ObjectMapper; import tools.jackson.module.jaxb.BaseJaxbTest; +import tools.jackson.module.jaxb.testutil.failure.JacksonTestFailureExpected; import static org.junit.jupiter.api.Assertions.*; @@ -49,6 +50,7 @@ static class HasIDList public HasID getParent() { return parent; } } + @JacksonTestFailureExpected @Test public void testIssue46() throws Exception { diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index 039b4741..c6a3e53d 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -23,6 +23,11 @@ Active maintainers: === Releases === ------------------------------------------------------------------------ +2.19.0 (not yet released) + +#268: Unify testing structure/tools [JSTEP-10] + (contributed by Joo-Hyuk K) + 2.18.2 (27-Nov-2024) 2.18.1 (28-Oct-2024)