1 42 43 package org.jfree.data.statistics.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 import java.util.ArrayList ; 52 53 import junit.framework.Test; 54 import junit.framework.TestCase; 55 import junit.framework.TestSuite; 56 57 import org.jfree.data.statistics.BoxAndWhiskerItem; 58 59 62 public class BoxAndWhiskerItemTests extends TestCase { 63 64 69 public static Test suite() { 70 return new TestSuite(BoxAndWhiskerItemTests.class); 71 } 72 73 78 public BoxAndWhiskerItemTests(String name) { 79 super(name); 80 } 81 82 85 public void testEquals() { 86 87 BoxAndWhiskerItem i1 = new BoxAndWhiskerItem( 88 new Double (1.0), new Double (2.0), new Double (3.0), new Double (4.0), 89 new Double (5.0), new Double (6.0), new Double (7.0), new Double (8.0), 90 new ArrayList () 91 ); 92 BoxAndWhiskerItem i2 = new BoxAndWhiskerItem( 93 new Double (1.0), new Double (2.0), new Double (3.0), new Double (4.0), 94 new Double (5.0), new Double (6.0), new Double (7.0), new Double (8.0), 95 new ArrayList () 96 ); 97 assertTrue(i1.equals(i2)); 98 assertTrue(i2.equals(i1)); 99 100 } 101 102 105 public void testSerialization() { 106 107 BoxAndWhiskerItem i1 = new BoxAndWhiskerItem( 108 new Double (1.0), new Double (2.0), new Double (3.0), new Double (4.0), 109 new Double (5.0), new Double (6.0), new Double (7.0), new Double (8.0), 110 new ArrayList () 111 ); 112 BoxAndWhiskerItem i2 = null; 113 114 try { 115 ByteArrayOutputStream buffer = new ByteArrayOutputStream (); 116 ObjectOutput out = new ObjectOutputStream (buffer); 117 out.writeObject(i1); 118 out.close(); 119 120 ObjectInput in = new ObjectInputStream ( 121 new ByteArrayInputStream (buffer.toByteArray()) 122 ); 123 i2 = (BoxAndWhiskerItem) in.readObject(); 124 in.close(); 125 } 126 catch (Exception e) { 127 System.out.println(e.toString()); 128 } 129 assertEquals(i1, i2); 130 131 } 132 133 } 134 | Popular Tags |