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