1 42 43 package org.jfree.chart.block.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.chart.block.FlowArrangement; 57 import org.jfree.ui.HorizontalAlignment; 58 import org.jfree.ui.VerticalAlignment; 59 60 63 public class FlowArrangementTests extends TestCase { 64 65 70 public static Test suite() { 71 return new TestSuite(FlowArrangementTests.class); 72 } 73 74 79 public FlowArrangementTests(String name) { 80 super(name); 81 } 82 83 86 public void testEquals() { 87 FlowArrangement f1 = new FlowArrangement( 88 HorizontalAlignment.LEFT, VerticalAlignment.TOP, 1.0, 2.0 89 ); 90 FlowArrangement f2 = new FlowArrangement( 91 HorizontalAlignment.LEFT, VerticalAlignment.TOP, 1.0, 2.0 92 ); 93 assertTrue(f1.equals(f2)); 94 assertTrue(f2.equals(f1)); 95 96 f1 = new FlowArrangement( 97 HorizontalAlignment.RIGHT, VerticalAlignment.TOP, 1.0, 2.0 98 ); 99 assertFalse(f1.equals(f2)); 100 f2 = new FlowArrangement( 101 HorizontalAlignment.RIGHT, VerticalAlignment.TOP, 1.0, 2.0 102 ); 103 assertTrue(f1.equals(f2)); 104 105 f1 = new FlowArrangement( 106 HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, 1.0, 2.0 107 ); 108 assertFalse(f1.equals(f2)); 109 f2 = new FlowArrangement( 110 HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, 1.0, 2.0 111 ); 112 assertTrue(f1.equals(f2)); 113 114 f1 = new FlowArrangement( 115 HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, 1.1, 2.0 116 ); 117 assertFalse(f1.equals(f2)); 118 f2 = new FlowArrangement( 119 HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, 1.1, 2.0 120 ); 121 assertTrue(f1.equals(f2)); 122 123 f1 = new FlowArrangement( 124 HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, 1.1, 2.2 125 ); 126 assertFalse(f1.equals(f2)); 127 f2 = new FlowArrangement( 128 HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, 1.1, 2.2 129 ); 130 assertTrue(f1.equals(f2)); 131 132 } 133 134 137 public void testCloning() { 138 FlowArrangement f1 = new FlowArrangement(); 139 assertFalse(f1 instanceof Cloneable ); 140 } 141 142 145 public void testSerialization() { 146 FlowArrangement f1 = new FlowArrangement( 147 HorizontalAlignment.LEFT, VerticalAlignment.TOP, 1.0, 2.0 148 ); 149 FlowArrangement f2 = null; 150 try { 151 ByteArrayOutputStream buffer = new ByteArrayOutputStream (); 152 ObjectOutput out = new ObjectOutputStream (buffer); 153 out.writeObject(f1); 154 out.close(); 155 156 ObjectInput in = new ObjectInputStream ( 157 new ByteArrayInputStream (buffer.toByteArray()) 158 ); 159 f2 = (FlowArrangement) in.readObject(); 160 in.close(); 161 } 162 catch (Exception e) { 163 System.out.println(e.toString()); 164 } 165 assertEquals(f1, f2); 166 } 167 168 } 169 | Popular Tags |