Skip to content

Commit

Permalink
Test clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Apr 27, 2024
1 parent d4b08c0 commit a359144
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 40 deletions.
Expand Up @@ -9,15 +9,13 @@
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
import com.fasterxml.jackson.core.util.JsonRecyclerPools;

import static com.fasterxml.jackson.core.util.JdkSerializationTestUtils.jdkDeserialize;
import static com.fasterxml.jackson.core.util.JdkSerializationTestUtils.jdkSerialize;
import static org.junit.jupiter.api.Assertions.*;

/**
* Unit tests for [core#31] (https://github.com/FasterXML/jackson-core/issues/31)
*/
class JDKSerializabilityTest
extends JUnit5TestBase
extends JUnit5TestBase
{
/*
/**********************************************************************
Expand Down
30 changes: 30 additions & 0 deletions src/test/java/com/fasterxml/jackson/core/JUnit5TestBase.java
Expand Up @@ -419,6 +419,12 @@ protected int[] calcQuads(byte[] wordBytes) {
return result;
}

/*
/**********************************************************************
/* Content reading, serialization
/**********************************************************************
*/

public static byte[] readResource(String ref)
{
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
Expand All @@ -441,4 +447,28 @@ public static byte[] readResource(String ref)
}
return bytes.toByteArray();
}

public static 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")
public static <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 was deleted.

Expand Up @@ -9,16 +9,14 @@
import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.core.io.SerializedString;

import static com.fasterxml.jackson.core.util.JdkSerializationTestUtils.jdkDeserialize;
import static com.fasterxml.jackson.core.util.JdkSerializationTestUtils.jdkSerialize;
import static org.junit.jupiter.api.Assertions.assertEquals;

/**
* Simple unit tests to try to verify that the default
* {@link SerializableString} implementation works as expected.
*/
class TestSerializedString
extends com.fasterxml.jackson.core.JUnit5TestBase
extends com.fasterxml.jackson.core.JUnit5TestBase
{
private static final String QUOTED = "\\\"quo\\\\ted\\\"";

Expand Down

0 comments on commit a359144

Please sign in to comment.