1 38 39 package org.jfree.chart.renderer.junit; 40 41 import java.io.ByteArrayInputStream ; 42 import java.io.ByteArrayOutputStream ; 43 import java.io.ObjectInput ; 44 import java.io.ObjectInputStream ; 45 import java.io.ObjectOutput ; 46 import java.io.ObjectOutputStream ; 47 48 import junit.framework.Test; 49 import junit.framework.TestCase; 50 import junit.framework.TestSuite; 51 52 import org.jfree.chart.renderer.BarRenderer3D; 53 54 59 public class BarRenderer3DTests extends TestCase { 60 61 66 public static Test suite() { 67 return new TestSuite(BarRenderer3DTests.class); 68 } 69 70 75 public BarRenderer3DTests(String name) { 76 super(name); 77 } 78 79 82 public void testEquals() { 83 BarRenderer3D r1 = new BarRenderer3D(); 84 BarRenderer3D r2 = new BarRenderer3D(); 85 assertEquals(r1, r2); 86 } 87 88 91 public void testHashcode() { 92 BarRenderer3D r1 = new BarRenderer3D(); 93 BarRenderer3D r2 = new BarRenderer3D(); 94 assertTrue(r1.equals(r2)); 95 int h1 = r1.hashCode(); 96 int h2 = r2.hashCode(); 97 assertEquals(h1, h2); 98 } 99 100 103 public void testCloning() { 104 BarRenderer3D r1 = new BarRenderer3D(); 105 BarRenderer3D r2 = null; 106 try { 107 r2 = (BarRenderer3D) r1.clone(); 108 } 109 catch (CloneNotSupportedException e) { 110 System.err.println("BarRenderer3DTests.testCloning: failed to clone."); 111 } 112 assertTrue(r1 != r2); 113 assertTrue(r1.getClass() == r2.getClass()); 114 assertTrue(r1.equals(r2)); 115 } 116 117 120 public void testSerialization() { 121 122 BarRenderer3D r1 = new BarRenderer3D(); 123 BarRenderer3D 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 = (BarRenderer3D) 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 |