1 37 38 package org.jfree.chart.labels.junit; 39 40 import java.io.ByteArrayInputStream ; 41 import java.io.ByteArrayOutputStream ; 42 import java.io.ObjectInput ; 43 import java.io.ObjectInputStream ; 44 import java.io.ObjectOutput ; 45 import java.io.ObjectOutputStream ; 46 47 import junit.framework.Test; 48 import junit.framework.TestCase; 49 import junit.framework.TestSuite; 50 51 import org.jfree.chart.labels.SymbolicXYToolTipGenerator; 52 53 58 public class SymbolicXYToolTipGeneratorTests extends TestCase { 59 60 65 public static Test suite() { 66 return new TestSuite(SymbolicXYToolTipGeneratorTests.class); 67 } 68 69 74 public SymbolicXYToolTipGeneratorTests(String name) { 75 super(name); 76 } 77 78 81 public void testCloning() { 82 SymbolicXYToolTipGenerator g1 = new SymbolicXYToolTipGenerator(); 83 SymbolicXYToolTipGenerator g2 = null; 84 try { 85 g2 = (SymbolicXYToolTipGenerator) g1.clone(); 86 } 87 catch (CloneNotSupportedException e) { 88 System.err.println("SymbolicXYToolTipGenerator.testCloning: failed to clone."); 89 } 90 assertTrue(g1 != g2); 91 assertTrue(g1.getClass() == g2.getClass()); 92 assertTrue(g1.equals(g2)); 93 } 94 95 98 public void testSerialization() { 99 100 SymbolicXYToolTipGenerator g1 = new SymbolicXYToolTipGenerator(); 101 SymbolicXYToolTipGenerator g2 = null; 102 103 try { 104 ByteArrayOutputStream buffer = new ByteArrayOutputStream (); 105 ObjectOutput out = new ObjectOutputStream (buffer); 106 out.writeObject(g1); 107 out.close(); 108 109 ObjectInput in = new ObjectInputStream (new ByteArrayInputStream (buffer.toByteArray())); 110 g2 = (SymbolicXYToolTipGenerator) in.readObject(); 111 in.close(); 112 } 113 catch (Exception e) { 114 System.out.println(e.toString()); 115 } 116 assertEquals(g1, g2); 117 118 } 119 120 } 121 | Popular Tags |