KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > l2 > state > EnrollmentTest


1 /*
2  * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright
3  * notice. All rights reserved.
4  */

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