1 4 package com.tc.io.serializer.impl; 5 6 import com.tc.io.serializer.TCObjectInputStream; 7 import com.tc.io.serializer.TCObjectOutputStream; 8 import com.tc.io.serializer.api.StringIndex; 9 import com.tc.objectserver.persistence.impl.NullStringIndexPersistor; 10 import com.tc.objectserver.persistence.impl.StringIndexImpl; 11 12 import java.io.ByteArrayInputStream ; 13 import java.io.ByteArrayOutputStream ; 14 15 import junit.framework.TestCase; 16 17 public class StringSerializerTest extends TestCase { 18 public void test() throws Exception { 19 StringIndex stringIndex = new StringIndexImpl(new NullStringIndexPersistor()); 20 StringSerializer ss = new StringSerializer(stringIndex); 21 22 ByteArrayOutputStream baout = new ByteArrayOutputStream (); 23 for (int i=0; i<100; i++) { 24 String test = "This is a nice test string: " + i; 25 TCObjectOutputStream out = new TCObjectOutputStream(baout); 26 ss.serializeTo(test, out); 27 out.flush(); 28 29 ByteArrayInputStream bain = new ByteArrayInputStream (baout.toByteArray()); 30 assertEquals(test, ss.deserializeFrom(new TCObjectInputStream(bain))); 31 baout.reset(); 32 } 33 } 34 } 35 | Popular Tags |