1 4 package com.tc.object.dna.impl; 5 6 import com.tc.io.TCByteBufferInputStream; 7 import com.tc.io.TCByteBufferOutputStream; 8 9 import java.io.IOException ; 10 11 import junit.framework.TestCase; 12 13 public class ObjectStringSerializerTest extends TestCase { 14 15 public void test() throws IOException { 16 TCByteBufferOutputStream out = new TCByteBufferOutputStream(); 18 ObjectStringSerializer ser = new ObjectStringSerializer(); 19 20 ser.writeFieldName(out, "className.fieldName"); 21 ser.writeString(out, "timmy teck"); 22 ser.writeFieldName(out, "className.fieldName"); 23 ser.writeString(out, "timmy teck"); 24 25 TCByteBufferOutputStream data = new TCByteBufferOutputStream(); 27 ser.serializeTo(data); 28 data.write(out.toArray()); 29 30 TCByteBufferInputStream in = new TCByteBufferInputStream(data.toArray()); 32 ObjectStringSerializer ser2 = new ObjectStringSerializer(); 33 ser2.deserializeFrom(in); 34 35 String fn1 = ser2.readFieldName(in); 36 String s1 = ser2.readString(in); 37 String fn2 = ser2.readFieldName(in); 38 String s2 = ser2.readString(in); 39 40 assertEquals("className.fieldName", fn1); 41 assertEquals("timmy teck", s1); 42 assertEquals("className.fieldName", fn2); 43 assertEquals("timmy teck", s2); 44 } 45 46 } 47 | Popular Tags |