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 import java.text.DateFormat ; 47 import java.text.NumberFormat ; 48 49 import junit.framework.Test; 50 import junit.framework.TestCase; 51 import junit.framework.TestSuite; 52 53 import org.jfree.chart.labels.TimeSeriesToolTipGenerator; 54 55 60 public class TimeSeriesToolTipGeneratorTests extends TestCase { 61 62 67 public static Test suite() { 68 return new TestSuite(TimeSeriesToolTipGeneratorTests.class); 69 } 70 71 76 public TimeSeriesToolTipGeneratorTests(String name) { 77 super(name); 78 } 79 80 83 public void testCloning() { 84 TimeSeriesToolTipGenerator g1 = new TimeSeriesToolTipGenerator(); 85 TimeSeriesToolTipGenerator g2 = null; 86 try { 87 g2 = (TimeSeriesToolTipGenerator) g1.clone(); 88 } 89 catch (CloneNotSupportedException e) { 90 System.err.println("TimeSeriesToolTipGeneratorTests.testCloning: failed to clone."); 91 } 92 assertTrue(g1 != g2); 93 assertTrue(g1.getClass() == g2.getClass()); 94 assertTrue(g1.equals(g2)); 95 } 96 97 100 public void testSerialization() { 101 102 TimeSeriesToolTipGenerator g1 = new TimeSeriesToolTipGenerator(DateFormat.getInstance(), 103 NumberFormat.getInstance()); 104 TimeSeriesToolTipGenerator g2 = null; 105 106 try { 107 ByteArrayOutputStream buffer = new ByteArrayOutputStream (); 108 ObjectOutput out = new ObjectOutputStream (buffer); 109 out.writeObject(g1); 110 out.close(); 111 112 ObjectInput in = new ObjectInputStream (new ByteArrayInputStream (buffer.toByteArray())); 113 g2 = (TimeSeriesToolTipGenerator) in.readObject(); 114 in.close(); 115 } 116 catch (Exception e) { 117 System.out.println(e.toString()); 118 } 119 assertEquals(g1, g2); 120 121 } 122 123 } 124 | Popular Tags |