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.VerticalAlignment; 57 58 61 public class VerticalAlignmentTests extends TestCase { 62 63 68 public static Test suite() { 69 return new TestSuite(VerticalAlignmentTests.class); 70 } 71 72 77 public VerticalAlignmentTests(final String name) { 78 super(name); 79 } 80 81 84 public void testEquals() { 85 assertTrue(VerticalAlignment.TOP.equals(VerticalAlignment.TOP)); 86 assertTrue(VerticalAlignment.BOTTOM.equals(VerticalAlignment.BOTTOM)); 87 assertTrue(VerticalAlignment.CENTER.equals(VerticalAlignment.CENTER)); 88 } 89 90 93 public void testSerialization() { 94 95 final VerticalAlignment a1 = VerticalAlignment.CENTER; 96 VerticalAlignment 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 (new ByteArrayInputStream (buffer.toByteArray())); 105 a2 = (VerticalAlignment) in.readObject(); 106 in.close(); 107 } 108 catch (Exception e) { 109 System.out.println(e.toString()); 110 } 111 assertTrue(a1 == a2); 112 113 } 114 115 } 116 | Popular Tags |