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 import org.jfree.data.xy.YWithXInterval; 56 57 60 public class YWithXIntervalTests extends TestCase { 61 62 67 public static Test suite() { 68 return new TestSuite(YWithXIntervalTests.class); 69 } 70 71 76 public YWithXIntervalTests(String name) { 77 super(name); 78 } 79 80 83 public void testEquals() { 84 YWithXInterval i1 = new YWithXInterval(1.0, 0.5, 1.5); 85 YWithXInterval i2 = new YWithXInterval(1.0, 0.5, 1.5); 86 assertEquals(i1, i2); 87 88 i1 = new YWithXInterval(1.1, 0.5, 1.5); 89 assertFalse(i1.equals(i2)); 90 i2 = new YWithXInterval(1.1, 0.5, 1.5); 91 assertTrue(i1.equals(i2)); 92 93 i1 = new YWithXInterval(1.1, 0.55, 1.5); 94 assertFalse(i1.equals(i2)); 95 i2 = new YWithXInterval(1.1, 0.55, 1.5); 96 assertTrue(i1.equals(i2)); 97 98 i1 = new YWithXInterval(1.1, 0.55, 1.55); 99 assertFalse(i1.equals(i2)); 100 i2 = new YWithXInterval(1.1, 0.55, 1.55); 101 assertTrue(i1.equals(i2)); 102 } 103 104 107 public void testCloning() { 108 YWithXInterval i1 = new YWithXInterval(1.0, 0.5, 1.5); 109 assertFalse(i1 instanceof Cloneable ); 110 } 111 112 115 public void testSerialization() { 116 YWithXInterval i1 = new YWithXInterval(1.0, 0.5, 1.5); 117 YWithXInterval i2 = null; 118 119 try { 120 ByteArrayOutputStream buffer = new ByteArrayOutputStream (); 121 ObjectOutput out = new ObjectOutputStream (buffer); 122 out.writeObject(i1); 123 out.close(); 124 125 ObjectInput in = new ObjectInputStream ( 126 new ByteArrayInputStream (buffer.toByteArray())); 127 i2 = (YWithXInterval) in.readObject(); 128 in.close(); 129 } 130 catch (Exception e) { 131 e.printStackTrace(); 132 } 133 assertEquals(i1, i2); 134 } 135 136 } 137 | Popular Tags |