1 42 43 package org.jfree.chart.renderer.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.renderer.AreaRendererEndType; 57 58 61 public class AreaRendererEndTypeTests extends TestCase { 62 63 68 public static Test suite() { 69 return new TestSuite(AreaRendererEndTypeTests.class); 70 } 71 72 77 public AreaRendererEndTypeTests(String name) { 78 super(name); 79 } 80 81 84 public void testEquals() { 85 assertEquals(AreaRendererEndType.LEVEL, AreaRendererEndType.LEVEL); 86 assertEquals(AreaRendererEndType.TAPER, AreaRendererEndType.TAPER); 87 assertEquals( 88 AreaRendererEndType.TRUNCATE, AreaRendererEndType.TRUNCATE 89 ); 90 } 91 92 95 public void testSerialization() { 96 97 AreaRendererEndType t1 = AreaRendererEndType.TAPER; 98 AreaRendererEndType t2 = null; 99 100 try { 101 ByteArrayOutputStream buffer = new ByteArrayOutputStream (); 102 ObjectOutput out = new ObjectOutputStream (buffer); 103 out.writeObject(t1); 104 out.close(); 105 106 ObjectInput in = new ObjectInputStream ( 107 new ByteArrayInputStream (buffer.toByteArray()) 108 ); 109 t2 = (AreaRendererEndType) in.readObject(); 110 in.close(); 111 } 112 catch (Exception e) { 113 System.out.println(e.toString()); 114 } 115 assertEquals(t1, t2); 116 boolean same = t1 == t2; 117 assertEquals(true, same); 118 } 119 120 } 121 | Popular Tags |