1 /*
2 * Copyright �, Aegeus Technology Limited. All rights reserved.
3 */
4 package jsdsi;
5
6 import java.io.ByteArrayInputStream;
7 import java.io.ByteArrayOutputStream;
8 import java.io.ObjectInputStream;
9 import java.io.ObjectOutputStream;
10
11 import junit.framework.Test;
12 import junit.framework.TestCase;
13 import junit.framework.TestSuite;
14
15 /***
16 * @author Sean Radford
17 * @version $Revision: 1.1.2.1 $ $Date: 2004/12/19 11:49:06 $
18 */
19 public class SerializationTest extends TestCase {
20
21 private Object obj;
22
23 private static Object[] toTest = new Object[] { new Auth(new StringTag("test"), false),
24 new Auth(Tag.NULL_TAG, false), new Auth(Tag.ALL_TAG, false) };
25
26 /***
27 * @param arg0
28 */
29 public SerializationTest(Object obj) {
30 super("testRun");
31 this.obj = obj;
32 }
33
34 /***
35 * @see TestCase#setUp()
36 */
37 protected void setUp() throws Exception {
38 super.setUp();
39 }
40
41 /***
42 * @see TestCase#tearDown()
43 */
44 protected void tearDown() throws Exception {
45 super.tearDown();
46 }
47
48 public static Test suite() {
49 TestSuite ts = new TestSuite();
50
51 for (int index = 0; index < toTest.length; index++) {
52 ts.addTest(new SerializationTest(toTest[index]));
53 }
54
55 return ts;
56
57 }
58
59 public void testRun() throws Exception {
60 System.out.println("testRun...");
61 ByteArrayOutputStream baos = new ByteArrayOutputStream();
62 ObjectOutputStream oos = new ObjectOutputStream(baos);
63 oos.writeObject(this.obj);
64 oos.close();
65 byte[] bytes = baos.toByteArray();
66
67 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
68 ObjectInputStream ois = new ObjectInputStream(bais);
69 Object out = ois.readObject();
70 assertEquals(this.obj.getClass().getName(), this.obj, out);
71 }
72
73 }
This page was automatically generated by Maven