Skip to content

Commit

Permalink
Merge branch '2.19'
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jan 20, 2025
2 parents 664b987 + 98b2ee7 commit 492789d
Show file tree
Hide file tree
Showing 18 changed files with 126 additions and 18 deletions.
1 change: 1 addition & 0 deletions afterburner/src/test/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
@@ -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> 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();
}
}
}
3 changes: 2 additions & 1 deletion android-record/src/test/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tools.jackson.module.androidrecord.failing;
package tools.jackson.module.androidrecord.tofix;

import org.junit.jupiter.api.Test;

Expand All @@ -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;

Expand Down Expand Up @@ -48,6 +49,7 @@ public String name() {
*
* @see RecordBasicsTest#testDeserializeConstructorInjectRecord()
*/
@JacksonTestFailureExpected
@Test
public void testDeserializeHeaderInjectRecord_WillFail() throws Exception {
ObjectReader r = MAPPER.readerFor(RecordWithHeaderInject.class)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tools.jackson.module.androidrecord.failing;
package tools.jackson.module.androidrecord.tofix;

import org.junit.jupiter.api.Test;

Expand All @@ -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;
Expand Down Expand Up @@ -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}",
Expand Down
3 changes: 2 additions & 1 deletion blackbird/src/test/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tools.jackson.module.blackbird.util.failure;
package tools.jackson.module.blackbird.testutil.failure;

import java.lang.annotation.*;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tools.jackson.module.blackbird.util.failure;
package tools.jackson.module.blackbird.testutil.failure;

import java.lang.reflect.Method;

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tools.jackson.module.blackbird.failing;
package tools.jackson.module.blackbird.tofix;

import java.io.ByteArrayOutputStream;
import java.io.InputStream;
Expand All @@ -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.*;

Expand All @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion jakarta-xmlbind/src/test/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tools.jackson.module.jakarta.xmlbind.failing;
package tools.jackson.module.jakarta.xmlbind.tofix;

import org.junit.jupiter.api.Test;

Expand All @@ -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.*;

Expand Down Expand Up @@ -57,6 +58,7 @@ public B(String type) {
*/

// not asserting anything
@JacksonTestFailureExpected
@Test
public void testXmlElementAndXmlElementRefs() throws Exception
{
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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.*;

Expand Down Expand Up @@ -49,6 +50,7 @@ static class HasIDList
public HasID getParent() { return parent; }
}

@JacksonTestFailureExpected
@Test
public void testIssue46() throws Exception
{
Expand Down
3 changes: 2 additions & 1 deletion jaxb/src/test/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
@@ -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.*;
Expand All @@ -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.*;

Expand Down Expand Up @@ -44,6 +45,7 @@ public enum Code {
private final ObjectMapper MAPPER = getJaxbMapper();

// [modules-base#256]
@JacksonTestFailureExpected
@Test
public void testEnumSerialize256() throws Exception
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tools.jackson.module.jaxb.failing;
package tools.jackson.module.jaxb.tofix;

import javax.xml.bind.annotation.*;

Expand All @@ -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.*;

Expand Down Expand Up @@ -57,6 +58,7 @@ public B(String type) {
*/

// not asserting anything
@JacksonTestFailureExpected
@Test
public void testXmlElementAndXmlElementRefs() throws Exception
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tools.jackson.module.jaxb.failing;
package tools.jackson.module.jaxb.tofix;

import java.util.Arrays;
import java.util.List;
Expand All @@ -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.*;

Expand Down Expand Up @@ -49,6 +50,7 @@ static class HasIDList
public HasID getParent() { return parent; }
}

@JacksonTestFailureExpected
@Test
public void testIssue46() throws Exception
{
Expand Down
5 changes: 5 additions & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 492789d

Please sign in to comment.