1 package test.crispy.impl.http; 2 3 import java.io.NotSerializableException; 4 5 import junit.framework.TestCase; 6 import net.sf.crispy.impl.http.Serializer; 7 import test.crispy.example.model.Kunde; 8 import test.crispy.example.model.NodeHashCode1; 9 10 public class SerializerTest extends TestCase { 11 12 public void testSerializerWithNoSerializableObject() throws Exception { 13 NodeHashCode1 lvNodeHashCode1 = new NodeHashCode1("Junit-TestNode"); 14 try { 15 byte b[] = Serializer.serialize(lvNodeHashCode1); 16 assertNotNull(b); 17 } catch (NotSerializableException e) { 18 assertTrue(true); 19 } 20 21 } 22 23 public void testSerializerWithSerializableObject() throws Exception { 24 Kunde k = new Kunde(); 25 byte b[] = Serializer.serialize(k); 26 assertNotNull(b); 27 assertTrue(b.length > 200); 28 } 29 30 public void testDeserialize() throws Exception { 31 Kunde k = new Kunde(); 32 k.setName("TestName"); 33 k.setVorname("TestVorname"); 34 byte b[] = Serializer.serialize(k); 35 Object o = Serializer.deserialize(b); 36 assertNotNull(o); 37 assertTrue(o instanceof Kunde); 38 Kunde kAfter = (Kunde) o; 39 assertEquals(kAfter.getName(), "TestName"); 40 assertEquals(kAfter.getVorname(), "TestVorname"); 41 } 42 43 44 45 }