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.StackedAreaRenderer; 52 53 58 public class StackedAreaRendererTests extends TestCase { 59 60 65 public static Test suite() { 66 return new TestSuite(StackedAreaRendererTests.class); 67 } 68 69 74 public StackedAreaRendererTests(String name) { 75 super(name); 76 } 77 78 81 public void testEquals() { 82 StackedAreaRenderer r1 = new StackedAreaRenderer(); 83 StackedAreaRenderer r2 = new StackedAreaRenderer(); 84 assertEquals(r1, r2); 85 } 86 87 90 public void testHashcode() { 91 StackedAreaRenderer r1 = new StackedAreaRenderer(); 92 StackedAreaRenderer r2 = new StackedAreaRenderer(); 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 StackedAreaRenderer r1 = new StackedAreaRenderer(); 104 StackedAreaRenderer r2 = null; 105 try { 106 r2 = (StackedAreaRenderer) r1.clone(); 107 } 108 catch (CloneNotSupportedException e) { 109 System.err.println("StackedAreaRendererTests.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 StackedAreaRenderer r1 = new StackedAreaRenderer(); 123 StackedAreaRenderer 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 = (StackedAreaRenderer) 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 |