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 51 import junit.framework.Test; 52 import junit.framework.TestCase; 53 import junit.framework.TestSuite; 54 55 import org.jfree.chart.urls.StandardCategoryURLGenerator; 56 57 60 public class StandardCategoryURLGeneratorTests extends TestCase { 61 62 67 public static Test suite() { 68 return new TestSuite(StandardCategoryURLGeneratorTests.class); 69 } 70 71 76 public StandardCategoryURLGeneratorTests(String name) { 77 super(name); 78 } 79 80 83 public void testSerialization() { 84 85 StandardCategoryURLGenerator g1 = new StandardCategoryURLGenerator( 86 "index.html?" 87 ); 88 StandardCategoryURLGenerator g2 = null; 89 90 try { 91 ByteArrayOutputStream buffer = new ByteArrayOutputStream (); 92 ObjectOutput out = new ObjectOutputStream (buffer); 93 out.writeObject(g1); 94 out.close(); 95 96 ObjectInput in = new ObjectInputStream (new ByteArrayInputStream ( 97 buffer.toByteArray()) 98 ); 99 g2 = (StandardCategoryURLGenerator) in.readObject(); 100 in.close(); 101 } 102 catch (Exception e) { 103 System.out.println(e.toString()); 104 } 105 assertEquals(g1, g2); 106 107 } 108 109 } 110 | Popular Tags |