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.StackedBarRenderer3D; 52 53 58 public class StackedBarRenderer3DTests extends TestCase { 59 60 65 public static Test suite() { 66 return new TestSuite(StackedBarRenderer3DTests.class); 67 } 68 69 74 public StackedBarRenderer3DTests(String name) { 75 super(name); 76 } 77 78 81 public void testEquals() { 82 StackedBarRenderer3D r1 = new StackedBarRenderer3D(); 83 StackedBarRenderer3D r2 = new StackedBarRenderer3D(); 84 assertEquals(r1, r2); 85 } 86 87 90 public void testHashcode() { 91 StackedBarRenderer3D r1 = new StackedBarRenderer3D(); 92 StackedBarRenderer3D r2 = new StackedBarRenderer3D(); 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 StackedBarRenderer3D r1 = new StackedBarRenderer3D(); 104 StackedBarRenderer3D r2 = null; 105 try { 106 r2 = (StackedBarRenderer3D) r1.clone(); 107 } 108 catch (CloneNotSupportedException e) { 109 System.err.println("StackedBarRendererTests.testCloning: failed to clone."); 110 } 111 assertTrue(r1 != r2); 112 assertTrue(r1.getClass() == r2.getClass()); 113 assertTrue(r1.equals(r2)); 114 } 115 116 119 public void testSerialization() { 120 121 StackedBarRenderer3D r1 = new StackedBarRenderer3D(); 122 StackedBarRenderer3D r2 = null; 123 124 try { 125 ByteArrayOutputStream buffer = new ByteArrayOutputStream (); 126 ObjectOutput out = new ObjectOutputStream (buffer); 127 out.writeObject(r1); 128 out.close(); 129 130 ObjectInput in = new ObjectInputStream (new ByteArrayInputStream (buffer.toByteArray())); 131 r2 = (StackedBarRenderer3D) in.readObject(); 132 in.close(); 133 } 134 catch (Exception e) { 135 System.out.println(e.toString()); 136 } 137 assertEquals(r1, r2); 138 139 } 140 141 } 142 | Popular Tags |