1 37 38 package org.jfree.chart.renderer.junit; 39 40 import java.io.ByteArrayInputStream ; 41 import java.io.ByteArrayOutputStream ; 42 import java.io.ObjectInput ; 43 import java.io.ObjectInputStream ; 44 import java.io.ObjectOutput ; 45 import java.io.ObjectOutputStream ; 46 47 import junit.framework.Test; 48 import junit.framework.TestCase; 49 import junit.framework.TestSuite; 50 51 import org.jfree.chart.renderer.StackedAreaXYRenderer; 52 53 58 public class StackedAreaXYRendererTests extends TestCase { 59 60 65 public static Test suite() { 66 return new TestSuite(StackedAreaXYRendererTests.class); 67 } 68 69 74 public StackedAreaXYRendererTests(String name) { 75 super(name); 76 } 77 78 81 public void testEquals() { 82 StackedAreaXYRenderer r1 = new StackedAreaXYRenderer(); 83 StackedAreaXYRenderer r2 = new StackedAreaXYRenderer(); 84 assertEquals(r1, r2); 85 } 86 87 90 public void testHashcode() { 91 StackedAreaXYRenderer r1 = new StackedAreaXYRenderer(); 92 StackedAreaXYRenderer r2 = new StackedAreaXYRenderer(); 93 assertTrue(r1.equals(r2)); 94 int h1 = r1.hashCode(); 95 int h2 = r2.hashCode(); 96 assertEquals(h1, h2); 97 } 98 99 102 public void testCloning() { 103 StackedAreaXYRenderer r1 = new StackedAreaXYRenderer(); 104 StackedAreaXYRenderer r2 = null; 105 try { 106 r2 = (StackedAreaXYRenderer) r1.clone(); 107 } 108 catch (CloneNotSupportedException e) { 109 System.err.println("StackedAreaXYRendererTests.testCloning: failed to clone."); 110 } 111 assertTrue(r1 != r2); 112 assertTrue(r1.getClass() == r2.getClass()); 113 assertTrue(r1.equals(r2)); 114 115 } 116 117 120 public void testSerialization() { 121 122 StackedAreaXYRenderer r1 = new StackedAreaXYRenderer(); 123 StackedAreaXYRenderer r2 = null; 124 125 try { 126 ByteArrayOutputStream buffer = new ByteArrayOutputStream (); 127 ObjectOutput out = new ObjectOutputStream (buffer); 128 out.writeObject(r1); 129 out.close(); 130 131 ObjectInput in = new ObjectInputStream (new ByteArrayInputStream (buffer.toByteArray())); 132 r2 = (StackedAreaXYRenderer) in.readObject(); 133 in.close(); 134 } 135 catch (Exception e) { 136 System.out.println(e.toString()); 137 } 138 assertEquals(r1, r2); 139 140 } 141 142 } 143 | Popular Tags |