1 42 43 package org.jfree.data.xy.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.data.xy.XYInterval; 57 58 61 public class XYIntervalTests extends TestCase { 62 63 68 public static Test suite() { 69 return new TestSuite(XYIntervalTests.class); 70 } 71 72 77 public XYIntervalTests(String name) { 78 super(name); 79 } 80 81 84 public void testEquals() { 85 XYInterval i1 = new XYInterval(1.0, 2.0, 3.0, 2.5, 3.5); 86 XYInterval i2 = new XYInterval(1.0, 2.0, 3.0, 2.5, 3.5); 87 assertEquals(i1, i2); 88 89 i1 = new XYInterval(1.1, 2.0, 3.0, 2.5, 3.5); 90 assertFalse(i1.equals(i2)); 91 i2 = new XYInterval(1.1, 2.0, 3.0, 2.5, 3.5); 92 assertTrue(i1.equals(i2)); 93 94 i1 = new XYInterval(1.1, 2.2, 3.0, 2.5, 3.5); 95 assertFalse(i1.equals(i2)); 96 i2 = new XYInterval(1.1, 2.2, 3.0, 2.5, 3.5); 97 assertTrue(i1.equals(i2)); 98 99 i1 = new XYInterval(1.1, 2.2, 3.3, 2.5, 3.5); 100 assertFalse(i1.equals(i2)); 101 i2 = new XYInterval(1.1, 2.2, 3.3, 2.5, 3.5); 102 assertTrue(i1.equals(i2)); 103 104 i1 = new XYInterval(1.1, 2.2, 3.3, 2.6, 3.5); 105 assertFalse(i1.equals(i2)); 106 i2 = new XYInterval(1.1, 2.2, 3.3, 2.6, 3.5); 107 assertTrue(i1.equals(i2)); 108 109 i1 = new XYInterval(1.1, 2.2, 3.3, 2.6, 3.6); 110 assertFalse(i1.equals(i2)); 111 i2 = new XYInterval(1.1, 2.2, 3.3, 2.6, 3.6); 112 assertTrue(i1.equals(i2)); 113 } 114 115 118 public void testCloning() { 119 XYInterval i1 = new XYInterval(1.0, 2.0, 3.0, 2.5, 3.5); 120 assertFalse(i1 instanceof Cloneable ); 121 } 122 123 126 public void testSerialization() { 127 XYInterval i1 = new XYInterval(1.0, 2.0, 3.0, 2.5, 3.5); 128 XYInterval i2 = null; 129 130 try { 131 ByteArrayOutputStream buffer = new ByteArrayOutputStream (); 132 ObjectOutput out = new ObjectOutputStream (buffer); 133 out.writeObject(i1); 134 out.close(); 135 136 ObjectInput in = new ObjectInputStream ( 137 new ByteArrayInputStream (buffer.toByteArray())); 138 i2 = (XYInterval) in.readObject(); 139 in.close(); 140 } 141 catch (Exception e) { 142 e.printStackTrace(); 143 } 144 assertEquals(i1, i2); 145 } 146 147 } 148 | Popular Tags |