Use own API for ser/deser roundtrip since the point of the test is not
proper usage of JRE API but whether our classes are properly implemented.
This commit is contained in:
parent
54afd64c79
commit
13eab3b25e
|
@ -23,16 +23,13 @@ import static org.junit.jupiter.api.Assertions.assertNull;
|
|||
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.apache.commons.lang3.SerializationUtils;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
|
@ -164,11 +161,7 @@ public class ImmutablePairTest {
|
|||
@SuppressWarnings("unchecked")
|
||||
public void testSerialization() throws Exception {
|
||||
final ImmutablePair<Integer, String> origPair = ImmutablePair.of(0, "foo");
|
||||
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
final ObjectOutputStream out = new ObjectOutputStream(baos);
|
||||
out.writeObject(origPair);
|
||||
final ImmutablePair<Integer, String> deserializedPair = (ImmutablePair<Integer, String>) new ObjectInputStream(
|
||||
new ByteArrayInputStream(baos.toByteArray())).readObject();
|
||||
final ImmutablePair<Integer, String> deserializedPair = SerializationUtils.roundtrip(origPair);
|
||||
assertEquals(origPair, deserializedPair);
|
||||
assertEquals(origPair.hashCode(), deserializedPair.hashCode());
|
||||
}
|
||||
|
|
|
@ -22,16 +22,13 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
|
|||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.apache.commons.lang3.SerializationUtils;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
|
@ -123,11 +120,7 @@ public class ImmutableTripleTest {
|
|||
@SuppressWarnings("unchecked")
|
||||
public void testSerialization() throws Exception {
|
||||
final ImmutableTriple<Integer, String, Boolean> origTriple = ImmutableTriple.of(0, "foo", Boolean.TRUE);
|
||||
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
final ObjectOutputStream out = new ObjectOutputStream(baos);
|
||||
out.writeObject(origTriple);
|
||||
final ImmutableTriple<Integer, String, Boolean> deserializedTriple = (ImmutableTriple<Integer, String, Boolean>) new ObjectInputStream(
|
||||
new ByteArrayInputStream(baos.toByteArray())).readObject();
|
||||
final ImmutableTriple<Integer, String, Boolean> deserializedTriple = SerializationUtils.roundtrip(origTriple);
|
||||
assertEquals(origTriple, deserializedTriple);
|
||||
assertEquals(origTriple.hashCode(), deserializedTriple.hashCode());
|
||||
}
|
||||
|
|
|
@ -20,13 +20,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
|||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.apache.commons.lang3.SerializationUtils;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
|
@ -132,11 +129,7 @@ public class MutablePairTest {
|
|||
@SuppressWarnings("unchecked")
|
||||
public void testSerialization() throws Exception {
|
||||
final MutablePair<Integer, String> origPair = MutablePair.of(0, "foo");
|
||||
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
final ObjectOutputStream out = new ObjectOutputStream(baos);
|
||||
out.writeObject(origPair);
|
||||
final MutablePair<Integer, String> deserializedPair = (MutablePair<Integer, String>) new ObjectInputStream(
|
||||
new ByteArrayInputStream(baos.toByteArray())).readObject();
|
||||
final MutablePair<Integer, String> deserializedPair = SerializationUtils.roundtrip(origPair);
|
||||
assertEquals(origPair, deserializedPair);
|
||||
assertEquals(origPair.hashCode(), deserializedPair.hashCode());
|
||||
}
|
||||
|
|
|
@ -20,11 +20,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
|||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
|
||||
import org.apache.commons.lang3.SerializationUtils;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
|
@ -97,11 +93,7 @@ public class MutableTripleTest {
|
|||
@SuppressWarnings("unchecked")
|
||||
public void testSerialization() throws Exception {
|
||||
final MutableTriple<Integer, String, Boolean> origTriple = MutableTriple.of(0, "foo", Boolean.TRUE);
|
||||
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
final ObjectOutputStream out = new ObjectOutputStream(baos);
|
||||
out.writeObject(origTriple);
|
||||
final MutableTriple<Integer, String, Boolean> deserializedTriple = (MutableTriple<Integer, String, Boolean>) new ObjectInputStream(
|
||||
new ByteArrayInputStream(baos.toByteArray())).readObject();
|
||||
final MutableTriple<Integer, String, Boolean> deserializedTriple = SerializationUtils.roundtrip(origTriple);
|
||||
assertEquals(origTriple, deserializedTriple);
|
||||
assertEquals(origTriple.hashCode(), deserializedTriple.hashCode());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue