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.DateTickMarkPosition; 57 58 61 public class DateTickMarkPositionTests extends TestCase { 62 63 68 public static Test suite() { 69 return new TestSuite(DateTickMarkPositionTests.class); 70 } 71 72 77 public DateTickMarkPositionTests(String name) { 78 super(name); 79 } 80 81 84 public void testEquals() { 85 assertEquals(DateTickMarkPosition.START, DateTickMarkPosition.START); 86 assertEquals(DateTickMarkPosition.MIDDLE, DateTickMarkPosition.MIDDLE); 87 assertEquals(DateTickMarkPosition.END, DateTickMarkPosition.END); 88 assertFalse(DateTickMarkPosition.START.equals(null)); 89 assertFalse( 90 DateTickMarkPosition.START.equals(DateTickMarkPosition.END) 91 ); 92 assertFalse( 93 DateTickMarkPosition.MIDDLE.equals(DateTickMarkPosition.END) 94 ); 95 } 96 97 100 public void testHashCode() { 101 DateTickMarkPosition a1 = DateTickMarkPosition.END; 102 DateTickMarkPosition a2 = DateTickMarkPosition.END; 103 assertTrue(a1.equals(a2)); 104 int h1 = a1.hashCode(); 105 int h2 = a2.hashCode(); 106 assertEquals(h1, h2); 107 } 108 109 112 public void testSerialization() { 113 DateTickMarkPosition p1 = DateTickMarkPosition.MIDDLE; 114 DateTickMarkPosition p2 = null; 115 116 try { 117 ByteArrayOutputStream buffer = new ByteArrayOutputStream (); 118 ObjectOutput out = new ObjectOutputStream (buffer); 119 out.writeObject(p1); 120 out.close(); 121 122 ObjectInput in = new ObjectInputStream ( 123 new ByteArrayInputStream (buffer.toByteArray()) 124 ); 125 p2 = (DateTickMarkPosition) in.readObject(); 126 in.close(); 127 } 128 catch (Exception e) { 129 System.out.println(e.toString()); 130 } 131 assertEquals(p1, p2); 132 assertTrue(p1 == p2); 133 } 134 135 } 136 | Popular Tags |