1 5 package com.tc.l2.state; 6 7 import com.tc.net.groups.NodeID; 8 9 import java.io.ByteArrayInputStream ; 10 import java.io.ByteArrayOutputStream ; 11 import java.io.ObjectInput ; 12 import java.io.ObjectInputStream ; 13 import java.io.ObjectOutput ; 14 import java.io.ObjectOutputStream ; 15 16 import junit.framework.TestCase; 17 18 public class EnrollmentTest extends TestCase { 19 20 public void testSerialization() throws Exception { 21 Enrollment e = EnrollmentFactory.createEnrollment(new NodeID("30001", new byte[] { 54, -125, 34, -4 }), true); 22 ByteArrayOutputStream bo = new ByteArrayOutputStream (); 23 ObjectOutput oo = new ObjectOutputStream (bo); 24 oo.writeObject(e); 25 System.err.println("Written : " + e); 26 ByteArrayInputStream bi = new ByteArrayInputStream (bo.toByteArray()); 27 ObjectInput oi = new ObjectInputStream (bi); 28 Enrollment e1 = (Enrollment) oi.readObject(); 29 System.err.println("Read : " + e1); 30 31 assertEquals(e, e1); 32 33 } 34 35 } 36 | Popular Tags |