parent
e0ca514118
commit
98528e849e
|
@ -9,8 +9,7 @@ import java.io.Serializable;
|
|||
|
||||
public class SerializationUtils {
|
||||
|
||||
public static <T extends Serializable> byte[] serialize(T obj)
|
||||
throws IOException {
|
||||
public static <T extends Serializable> byte[] serialize(T obj) throws IOException {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
ObjectOutputStream oos = new ObjectOutputStream(baos);
|
||||
oos.writeObject(obj);
|
||||
|
@ -30,4 +29,3 @@ public class SerializationUtils {
|
|||
return it.isPrimitive() || it.isInterface() || Serializable.class.isAssignableFrom(it);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,8 @@ public class SerializationUnitTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void whenSerializingAndDeserializingUsingCustomSerializationUtils_ThenObjectIsTheSame() throws IOException, ClassNotFoundException {
|
||||
public void whenSerializingAndDeserializingUsingCustomSerializationUtils_ThenObjectIsTheSame()
|
||||
throws IOException, ClassNotFoundException {
|
||||
Person p = new Person();
|
||||
p.setAge(20);
|
||||
p.setName("Joe");
|
||||
|
|
Loading…
Reference in New Issue