1 41 42 package org.jfree.chart.axis.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.axis.SymbolicAxis; 56 57 60 public class SymbolicAxisTests extends TestCase { 61 62 67 public static Test suite() { 68 return new TestSuite(SymbolicAxisTests.class); 69 } 70 71 76 public SymbolicAxisTests(String name) { 77 super(name); 78 } 79 80 83 public void testSerialization() { 84 85 String [] tickLabels = new String [] {"One", "Two", "Three"}; 86 SymbolicAxis a1 = new SymbolicAxis("Test Axis", tickLabels); 87 SymbolicAxis a2 = null; 88 89 try { 90 ByteArrayOutputStream buffer = new ByteArrayOutputStream (); 91 ObjectOutput out = new ObjectOutputStream (buffer); 92 out.writeObject(a1); 93 out.close(); 94 95 ObjectInput in = new ObjectInputStream ( 96 new ByteArrayInputStream (buffer.toByteArray()) 97 ); 98 a2 = (SymbolicAxis) in.readObject(); 99 in.close(); 100 } 101 catch (Exception e) { 102 System.out.println(e.toString()); 103 } 104 assertEquals(a1, a2); 105 106 } 107 108 } 109 | Popular Tags |