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