1 42 43 package org.jfree.chart.axis.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.axis.CategoryLabelWidthType; 57 58 61 public class CategoryLabelWidthTypeTests extends TestCase { 62 63 68 public static Test suite() { 69 return new TestSuite(CategoryLabelWidthTypeTests.class); 70 } 71 72 77 public CategoryLabelWidthTypeTests(String name) { 78 super(name); 79 } 80 81 84 public void testEquals() { 85 assertEquals( 86 CategoryLabelWidthType.CATEGORY, CategoryLabelWidthType.CATEGORY 87 ); 88 assertEquals( 89 CategoryLabelWidthType.RANGE, CategoryLabelWidthType.RANGE 90 ); 91 } 92 93 96 public void testHashCode() { 97 CategoryLabelWidthType a1 = CategoryLabelWidthType.CATEGORY; 98 CategoryLabelWidthType a2 = CategoryLabelWidthType.CATEGORY; 99 assertTrue(a1.equals(a2)); 100 int h1 = a1.hashCode(); 101 int h2 = a2.hashCode(); 102 assertEquals(h1, h2); 103 } 104 105 108 public void testSerialization() { 109 CategoryLabelWidthType w1 = CategoryLabelWidthType.RANGE; 110 CategoryLabelWidthType w2 = null; 111 112 try { 113 ByteArrayOutputStream buffer = new ByteArrayOutputStream (); 114 ObjectOutput out = new ObjectOutputStream (buffer); 115 out.writeObject(w1); 116 out.close(); 117 118 ObjectInput in = new ObjectInputStream ( 119 new ByteArrayInputStream (buffer.toByteArray()) 120 ); 121 w2 = (CategoryLabelWidthType) in.readObject(); 122 in.close(); 123 } 124 catch (Exception e) { 125 System.out.println(e.toString()); 126 } 127 assertEquals(w1, w2); 128 assertTrue(w1 == w2); 129 } 130 131 } 132 | Popular Tags |