1 42 43 package org.jfree.chart.plot.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.chart.plot.PlotOrientation; 57 58 62 public class PlotOrientationTests extends TestCase { 63 64 69 public static Test suite() { 70 return new TestSuite(PlotOrientationTests.class); 71 } 72 73 78 public PlotOrientationTests(String name) { 79 super(name); 80 } 81 82 85 public void testEquals() { 86 assertEquals(PlotOrientation.HORIZONTAL, PlotOrientation.HORIZONTAL); 87 assertEquals(PlotOrientation.VERTICAL, PlotOrientation.VERTICAL); 88 assertFalse( 89 PlotOrientation.HORIZONTAL.equals(PlotOrientation.VERTICAL) 90 ); 91 assertFalse( 92 PlotOrientation.VERTICAL.equals(PlotOrientation.HORIZONTAL) 93 ); 94 } 95 96 99 public void testSerialization() { 100 101 PlotOrientation orientation1 = PlotOrientation.HORIZONTAL; 102 PlotOrientation orientation2 = null; 103 104 try { 105 ByteArrayOutputStream buffer = new ByteArrayOutputStream (); 106 ObjectOutput out = new ObjectOutputStream (buffer); 107 out.writeObject(orientation1); 108 out.close(); 109 110 ObjectInput in = new ObjectInputStream ( 111 new ByteArrayInputStream (buffer.toByteArray()) 112 ); 113 orientation2 = (PlotOrientation) in.readObject(); 114 in.close(); 115 } 116 catch (Exception e) { 117 System.out.println(e.toString()); 118 } 119 assertEquals(orientation1, orientation2); 120 boolean same = orientation1 == orientation2; 121 assertEquals(true, same); 122 } 123 124 } 125 | Popular Tags |