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.CategoryAxis3D; 56 57 60 public class CategoryAxis3DTests extends TestCase { 61 62 67 public static Test suite() { 68 return new TestSuite(CategoryAxis3DTests.class); 69 } 70 71 76 public CategoryAxis3DTests(String name) { 77 super(name); 78 } 79 80 83 public void testCloning() { 84 CategoryAxis3D a1 = new CategoryAxis3D("Test"); 85 CategoryAxis3D a2 = null; 86 try { 87 a2 = (CategoryAxis3D) a1.clone(); 88 } 89 catch (CloneNotSupportedException e) { 90 System.err.println("Failed to clone."); 91 } 92 assertTrue(a1 != a2); 93 assertTrue(a1.getClass() == a2.getClass()); 94 assertTrue(a1.equals(a2)); 95 } 96 97 100 public void testSerialization() { 101 102 CategoryAxis3D a1 = new CategoryAxis3D("Test Axis"); 103 CategoryAxis3D a2 = null; 104 105 try { 106 ByteArrayOutputStream buffer = new ByteArrayOutputStream (); 107 ObjectOutput out = new ObjectOutputStream (buffer); 108 out.writeObject(a1); 109 out.close(); 110 111 ObjectInput in = new ObjectInputStream ( 112 new ByteArrayInputStream (buffer.toByteArray()) 113 ); 114 a2 = (CategoryAxis3D) in.readObject(); 115 in.close(); 116 } 117 catch (Exception e) { 118 System.out.println(e.toString()); 119 } 120 assertEquals(a1, a2); 121 122 } 123 124 } 125 | Popular Tags |