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