1 42 43 package org.jfree.chart.renderer.category.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.category.StackedBarRenderer3D; 57 58 61 public class StackedBarRenderer3DTests extends TestCase { 62 63 68 public static Test suite() { 69 return new TestSuite(StackedBarRenderer3DTests.class); 70 } 71 72 77 public StackedBarRenderer3DTests(String name) { 78 super(name); 79 } 80 81 84 public void testEquals() { 85 StackedBarRenderer3D r1 = new StackedBarRenderer3D(); 86 StackedBarRenderer3D r2 = new StackedBarRenderer3D(); 87 assertEquals(r1, r2); 88 } 89 90 93 public void testHashcode() { 94 StackedBarRenderer3D r1 = new StackedBarRenderer3D(); 95 StackedBarRenderer3D r2 = new StackedBarRenderer3D(); 96 assertTrue(r1.equals(r2)); 97 int h1 = r1.hashCode(); 98 int h2 = r2.hashCode(); 99 assertEquals(h1, h2); 100 } 101 102 105 public void testCloning() { 106 StackedBarRenderer3D r1 = new StackedBarRenderer3D(); 107 StackedBarRenderer3D r2 = null; 108 try { 109 r2 = (StackedBarRenderer3D) r1.clone(); 110 } 111 catch (CloneNotSupportedException e) { 112 System.err.println("Failed to clone."); 113 } 114 assertTrue(r1 != r2); 115 assertTrue(r1.getClass() == r2.getClass()); 116 assertTrue(r1.equals(r2)); 117 } 118 119 122 public void testSerialization() { 123 124 StackedBarRenderer3D r1 = new StackedBarRenderer3D(); 125 StackedBarRenderer3D r2 = null; 126 127 try { 128 ByteArrayOutputStream buffer = new ByteArrayOutputStream (); 129 ObjectOutput out = new ObjectOutputStream (buffer); 130 out.writeObject(r1); 131 out.close(); 132 133 ObjectInput in = new ObjectInputStream ( 134 new ByteArrayInputStream (buffer.toByteArray()) 135 ); 136 r2 = (StackedBarRenderer3D) in.readObject(); 137 in.close(); 138 } 139 catch (Exception e) { 140 System.out.println(e.toString()); 141 } 142 assertEquals(r1, r2); 143 144 } 145 146 } 147 | Popular Tags |