1 42 43 package org.jfree.ui.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.ui.RectangleEdge; 57 58 61 public class RectangleEdgeTests extends TestCase { 62 63 68 public static Test suite() { 69 return new TestSuite(RectangleEdgeTests.class); 70 } 71 72 77 public RectangleEdgeTests(final String name) { 78 super(name); 79 } 80 81 84 public void testEquals() { 85 assertTrue(RectangleEdge.TOP.equals(RectangleEdge.TOP)); 86 assertTrue(RectangleEdge.BOTTOM.equals(RectangleEdge.BOTTOM)); 87 assertTrue(RectangleEdge.LEFT.equals(RectangleEdge.LEFT)); 88 assertTrue(RectangleEdge.RIGHT.equals(RectangleEdge.RIGHT)); 89 } 90 91 94 public void testSerialization() { 95 96 final RectangleEdge e1 = RectangleEdge.RIGHT; 97 RectangleEdge e2 = null; 98 99 try { 100 final ByteArrayOutputStream buffer = new ByteArrayOutputStream (); 101 final ObjectOutput out = new ObjectOutputStream (buffer); 102 out.writeObject(e1); 103 out.close(); 104 105 final ObjectInput in = new ObjectInputStream (new ByteArrayInputStream (buffer.toByteArray())); 106 e2 = (RectangleEdge) in.readObject(); 107 in.close(); 108 } 109 catch (Exception e) { 110 System.out.println(e.toString()); 111 } 112 assertTrue(e1 == e2); 113 114 } 115 116 } 117 | Popular Tags |