1 42 43 package org.jfree.chart.renderer.xy.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.xy.XYBubbleRenderer; 57 58 61 public class XYBubbleRendererTests extends TestCase { 62 63 68 public static Test suite() { 69 return new TestSuite(XYBubbleRendererTests.class); 70 } 71 72 77 public XYBubbleRendererTests(String name) { 78 super(name); 79 } 80 81 84 public void testEquals() { 85 XYBubbleRenderer r1 = new XYBubbleRenderer(); 86 XYBubbleRenderer r2 = new XYBubbleRenderer(); 87 assertEquals(r1, r2); 88 } 89 90 93 public void testHashcode() { 94 XYBubbleRenderer r1 = new XYBubbleRenderer(); 95 XYBubbleRenderer r2 = new XYBubbleRenderer(); 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 XYBubbleRenderer r1 = new XYBubbleRenderer(); 107 XYBubbleRenderer r2 = null; 108 try { 109 r2 = (XYBubbleRenderer) 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 XYBubbleRenderer r1 = new XYBubbleRenderer(); 125 XYBubbleRenderer 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 = (XYBubbleRenderer) 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 |