-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
126 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
...tools/jackson/module/afterburner/deser/jdk/AfterburnerModuleJDKSerializability97Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...l/failure/JacksonTestFailureExpected.java → ...l/failure/JacksonTestFailureExpected.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...acksonTestFailureExpectedInterceptor.java → ...acksonTestFailureExpectedInterceptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ilure/JacksonTestShouldFailException.java → ...ilure/JacksonTestShouldFailException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters