1 42 43 package org.jfree.chart.urls.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.urls.StandardXYURLGenerator; 57 58 61 public class StandardXYURLGeneratorTests extends TestCase { 62 63 68 public static Test suite() { 69 return new TestSuite(StandardXYURLGeneratorTests.class); 70 } 71 72 77 public StandardXYURLGeneratorTests(String name) { 78 super(name); 79 } 80 81 84 public void testSerialization() { 85 86 StandardXYURLGenerator g1 = new StandardXYURLGenerator("index.html?"); 87 StandardXYURLGenerator g2 = null; 88 89 try { 90 ByteArrayOutputStream buffer = new ByteArrayOutputStream (); 91 ObjectOutput out = new ObjectOutputStream (buffer); 92 out.writeObject(g1); 93 out.close(); 94 95 ObjectInput in = new ObjectInputStream ( 96 new ByteArrayInputStream (buffer.toByteArray()) 97 ); 98 g2 = (StandardXYURLGenerator) in.readObject(); 99 in.close(); 100 } 101 catch (Exception e) { 102 System.out.println(e.toString()); 103 } 104 assertEquals(g1, g2); 105 106 } 107 108 } 109 | Popular Tags |