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