1 41 42 package org.jfree.chart.urls.junit; 43 44 import java.io.ByteArrayInputStream ; 45 import java.io.ByteArrayOutputStream ; 46 import java.io.ObjectInput ; 47 import java.io.ObjectInputStream ; 48 import java.io.ObjectOutput ; 49 import java.io.ObjectOutputStream ; 50 import java.util.List ; 51 52 import junit.framework.Test; 53 import junit.framework.TestCase; 54 import junit.framework.TestSuite; 55 56 import org.jfree.chart.urls.CustomXYURLGenerator; 57 58 61 public class CustomXYURLGeneratorTests extends TestCase { 62 63 68 public static Test suite() { 69 return new TestSuite(CustomXYURLGeneratorTests.class); 70 } 71 72 77 public CustomXYURLGeneratorTests(String name) { 78 super(name); 79 } 80 81 84 public void testSerialization() { 85 86 List u1 = new java.util.ArrayList (); 87 u1.add("URL A1"); 88 u1.add("URL A2"); 89 u1.add("URL A3"); 90 91 List u2 = new java.util.ArrayList (); 92 u2.add("URL B1"); 93 u2.add("URL B2"); 94 u2.add("URL B3"); 95 96 CustomXYURLGenerator g1 = new CustomXYURLGenerator(); 97 CustomXYURLGenerator g2 = null; 98 99 g1.addURLSeries(u1); 100 g1.addURLSeries(u2); 101 102 try { 103 ByteArrayOutputStream buffer = new ByteArrayOutputStream (); 104 ObjectOutput out = new ObjectOutputStream (buffer); 105 out.writeObject(g1); 106 out.close(); 107 108 ObjectInput in = new ObjectInputStream ( 109 new ByteArrayInputStream (buffer.toByteArray()) 110 ); 111 g2 = (CustomXYURLGenerator) in.readObject(); 112 in.close(); 113 } 114 catch (Exception e) { 115 System.out.println(e.toString()); 116 } 117 assertEquals(g1, g2); 118 119 } 120 121 } 122 | Popular Tags |