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 import org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset; 59 60 63 public class DefaultBoxAndWhiskerCategoryDatasetTests extends TestCase { 64 65 70 public static Test suite() { 71 return new TestSuite(DefaultBoxAndWhiskerCategoryDatasetTests.class); 72 } 73 74 79 public DefaultBoxAndWhiskerCategoryDatasetTests(String name) { 80 super(name); 81 } 82 83 86 public void testEquals() { 87 88 DefaultBoxAndWhiskerCategoryDataset d1 89 = new DefaultBoxAndWhiskerCategoryDataset(); 90 d1.add( 91 new BoxAndWhiskerItem( 92 new Double (1.0), new Double (2.0), new Double (3.0), 93 new Double (4.0), 94 new Double (5.0), new Double (6.0), new Double (7.0), 95 new Double (8.0), 96 new ArrayList () 97 ), "ROW1", "COLUMN1" 98 ); 99 DefaultBoxAndWhiskerCategoryDataset d2 100 = new DefaultBoxAndWhiskerCategoryDataset(); 101 d2.add( 102 new BoxAndWhiskerItem( 103 new Double (1.0), new Double (2.0), new Double (3.0), 104 new Double (4.0), 105 new Double (5.0), new Double (6.0), new Double (7.0), 106 new Double (8.0), 107 new ArrayList () 108 ), "ROW1", "COLUMN1" 109 ); 110 assertTrue(d1.equals(d2)); 111 assertTrue(d2.equals(d1)); 112 113 } 114 115 118 public void testSerialization() { 119 120 DefaultBoxAndWhiskerCategoryDataset d1 121 = new DefaultBoxAndWhiskerCategoryDataset(); 122 d1.add( 123 new BoxAndWhiskerItem( 124 new Double (1.0), new Double (2.0), new Double (3.0), 125 new Double (4.0), 126 new Double (5.0), new Double (6.0), new Double (7.0), 127 new Double (8.0), 128 new ArrayList () 129 ), "ROW1", "COLUMN1" 130 ); 131 DefaultBoxAndWhiskerCategoryDataset d2 = null; 132 133 try { 134 ByteArrayOutputStream buffer = new ByteArrayOutputStream (); 135 ObjectOutput out = new ObjectOutputStream (buffer); 136 out.writeObject(d1); 137 out.close(); 138 139 ObjectInput in = new ObjectInputStream ( 140 new ByteArrayInputStream (buffer.toByteArray()) 141 ); 142 d2 = (DefaultBoxAndWhiskerCategoryDataset) in.readObject(); 143 in.close(); 144 } 145 catch (Exception e) { 146 System.out.println(e.toString()); 147 } 148 assertEquals(d1, d2); 149 150 } 151 152 } 153 | Popular Tags |