Search in sources :

Example 1 with UserKey

use of com.github.sviperll.adt4j.examples.UserKey in project adt4j by sviperll.

the class MainTest method testSerialization.

@Test
public void testSerialization() throws IOException, ClassNotFoundException {
    UserKey userKey1 = UserKey.valueOf(1);
    ByteArrayOutputStream byteArray = new ByteArrayOutputStream();
    ObjectOutputStream outputStream = new ObjectOutputStream(byteArray);
    outputStream.writeObject(userKey1);
    ObjectInputStream inputStream = new ObjectInputStream(new ByteArrayInputStream(byteArray.toByteArray()));
    UserKey userKey2 = (UserKey) inputStream.readObject();
    assertTrue("userKey1.equals(userKey2)", userKey1.equals(userKey2));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) UserKey(com.github.sviperll.adt4j.examples.UserKey) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) ObjectInputStream(java.io.ObjectInputStream) Test(org.junit.Test)

Aggregations

UserKey (com.github.sviperll.adt4j.examples.UserKey)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ObjectInputStream (java.io.ObjectInputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 Test (org.junit.Test)1