1 23 24 package com.rift.coad.lib.common; 25 26 import com.rift.coad.lib.common.*; 27 import junit.framework.*; 28 import java.io.ByteArrayInputStream ; 29 import java.io.ByteArrayOutputStream ; 30 import java.io.ObjectInputStream ; 31 import java.io.ObjectOutputStream ; 32 33 37 public class ObjectSerializerTest extends TestCase { 38 39 public static class TestObject implements java.io.Serializable { 40 public String key = null; 41 public String value = null; 42 43 public TestObject() { 44 45 } 46 47 public TestObject(String key, String value) { 48 this.key = key; 49 this.value = value; 50 } 51 } 52 53 public ObjectSerializerTest(String testName) { 54 super(testName); 55 } 56 57 protected void setUp() throws Exception { 58 } 59 60 protected void tearDown() throws Exception { 61 } 62 63 public static Test suite() { 64 TestSuite suite = new TestSuite(ObjectSerializerTest.class); 65 66 return suite; 67 } 68 69 72 public void testSerializer() throws Exception { 73 System.out.println("serializer"); 74 75 TestObject startObject = new TestObject("fred","freds value is here"); 76 byte[] result = ObjectSerializer.serialize(startObject); 77 TestObject resultObject = 78 (TestObject)ObjectSerializer.deserialize(result); 79 80 if (!startObject.key.equals(resultObject.key) && 81 startObject.value.equals(resultObject.value)) { 82 fail ("The serialization and deserialization test failed"); 83 } 84 } 85 86 87 88 } 89 | Popular Tags |