1 42 43 package org.jfree.text.junit; 44 45 import java.io.ByteArrayInputStream ; 46 import java.io.ByteArrayOutputStream ; 47 import java.io.ObjectInput ; 48 import java.io.ObjectInputStream ; 49 import java.io.ObjectOutput ; 50 import java.io.ObjectOutputStream ; 51 52 import junit.framework.Test; 53 import junit.framework.TestCase; 54 import junit.framework.TestSuite; 55 56 import org.jfree.text.TextLine; 57 58 61 public class TextLineTests extends TestCase { 62 63 68 public static Test suite() { 69 return new TestSuite(TextLineTests.class); 70 } 71 72 77 public TextLineTests(final String name) { 78 super(name); 79 } 80 81 84 public void testEquals() { 85 86 final TextLine line1 = new TextLine("Test"); 87 final TextLine line2 = new TextLine("Test"); 88 assertTrue(line1.equals(line2)); 89 assertTrue(line2.equals(line1)); 90 91 } 92 93 96 public void testSerialization() { 97 98 final TextLine line1 = new TextLine("Test"); 99 TextLine line2 = null; 100 101 try { 102 final ByteArrayOutputStream buffer = new ByteArrayOutputStream (); 103 final ObjectOutput out = new ObjectOutputStream (buffer); 104 out.writeObject(line1); 105 out.close(); 106 107 final ObjectInput in = new ObjectInputStream (new ByteArrayInputStream (buffer.toByteArray())); 108 line2 = (TextLine) in.readObject(); 109 in.close(); 110 } 111 catch (Exception e) { 112 System.out.println(e.toString()); 113 } 114 assertEquals(line1, line2); 115 116 } 117 118 } 119 | Popular Tags |