1 | public class ColumnArrangementTests extends TestCase {↵ | | 1 | public class FlowArrangementTests extends TestCase {↵
|
2 | ↵ | | 2 | ↵
|
3 | /**↵ | | 3 | /**↵
|
4 | * Returns the tests as a test suite.↵ | | 4 | * Returns the tests as a test suite.↵
|
5 | *↵ | | 5 | *↵
|
6 | * @return The test suite.↵ | | 6 | * @return The test suite.↵
|
7 | */↵ | | 7 | */↵
|
8 | public static Test suite() {↵ | | 8 | public static Test suite() {↵
|
9 | return new TestSuite(ColumnArrangementTests.class);↵ | | 9 | return new TestSuite(FlowArrangementTests.class);↵
|
10 | }↵ | | 10 | }↵
|
|
11 | /**↵ | | 11 | /**↵
|
12 | * Constructs a new set of tests.↵ | | 12 | * Constructs a new set of tests.↵
|
13 | *↵ | | 13 | *↵
|
14 | * @param name the name of the tests.↵ | | 14 | * @param name the name of the tests.↵
|
15 | */↵ | | 15 | */↵
|
16 | public ColumnArrangementTests(String name) {↵ | | 16 | public FlowArrangementTests(String name) {↵
|
17 | super(name);↵ | | 17 | super(name);↵
|
18 | }↵ | | 18 | }↵
|
19 | ↵ | | 19 | ↵
|
20 | /**↵ | | 20 | /**↵
|
21 | * Confirm that the equals() method can distinguish all the required fields.↵ | | 21 | * Confirm that the equals() method can distinguish all the required fields.↵
|
22 | */↵ | | 22 | */↵
|
23 | public void testEquals() {↵ | | 23 | public void testEquals() {↵
|
24 | ColumnArrangement c1 = new ColumnArrangement(↵ | | 24 | FlowArrangement f1 = new FlowArrangement(↵
|
25 | HorizontalAlignment.LEFT, VerticalAlignment.TOP, 1.0, 2.0↵ | | 25 | HorizontalAlignment.LEFT, VerticalAlignment.TOP, 1.0, 2.0↵
|
26 | );↵ | | 26 | );↵
|
27 | ColumnArrangement c2 = new ColumnArrangement(↵ | | 27 | FlowArrangement f2 = new FlowArrangement(↵
|
28 | HorizontalAlignment.LEFT, VerticalAlignment.TOP, 1.0, 2.0↵ | | 28 | HorizontalAlignment.LEFT, VerticalAlignment.TOP, 1.0, 2.0↵
|
29 | );↵ | | 29 | );↵
|
30 | assertTrue(c1.equals(c2));↵ | | 30 | assertTrue(f1.equals(f2));↵
|
31 | assertTrue(c2.equals(c1));↵ | | 31 | assertTrue(f2.equals(f1));↵
|
|
32 | c1 = new ColumnArrangement(↵ | | 32 | f1 = new FlowArrangement(↵
|
33 | HorizontalAlignment.RIGHT, VerticalAlignment.TOP, 1.0, 2.0↵ | | 33 | HorizontalAlignment.RIGHT, VerticalAlignment.TOP, 1.0, 2.0↵
|
34 | );↵ | | 34 | );↵
|
35 | assertFalse(c1.equals(c2));↵ | | 35 | assertFalse(f1.equals(f2));↵
|
36 | c2 = new ColumnArrangement(↵ | | 36 | f2 = new FlowArrangement(↵
|
37 | HorizontalAlignment.RIGHT, VerticalAlignment.TOP, 1.0, 2.0↵ | | 37 | HorizontalAlignment.RIGHT, VerticalAlignment.TOP, 1.0, 2.0↵
|
38 | );↵ | | 38 | );↵
|
39 | assertTrue(c1.equals(c2));↵ | | 39 | assertTrue(f1.equals(f2));↵
|
|
40 | c1 = new ColumnArrangement(↵ | | 40 | f1 = new FlowArrangement(↵
|
41 | HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, 1.0, 2.0↵ | | 41 | HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, 1.0, 2.0↵
|
42 | );↵ | | 42 | );↵
|
43 | assertFalse(c1.equals(c2));↵ | | 43 | assertFalse(f1.equals(f2));↵
|
44 | c2 = new ColumnArrangement(↵ | | 44 | f2 = new FlowArrangement(↵
|
45 | HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, 1.0, 2.0↵ | | 45 | HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, 1.0, 2.0↵
|
46 | );↵ | | 46 | );↵
|
47 | assertTrue(c1.equals(c2));↵ | | 47 | assertTrue(f1.equals(f2));↵
|
48 | ↵ | | 48 | ↵
|
49 | c1 = new ColumnArrangement(↵ | | 49 | f1 = new FlowArrangement(↵
|
50 | HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, 1.1, 2.0↵ | | 50 | HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, 1.1, 2.0↵
|
51 | );↵ | | 51 | );↵
|
52 | assertFalse(c1.equals(c2));↵ | | 52 | assertFalse(f1.equals(f2));↵
|
53 | c2 = new ColumnArrangement(↵ | | 53 | f2 = new FlowArrangement(↵
|
54 | HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, 1.1, 2.0↵ | | 54 | HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, 1.1, 2.0↵
|
55 | );↵ | | 55 | );↵
|
56 | assertTrue(c1.equals(c2));↵ | | 56 | assertTrue(f1.equals(f2));↵
|
57 | ↵ | | 57 | ↵
|
58 | c1 = new ColumnArrangement(↵ | | 58 | f1 = new FlowArrangement(↵
|
59 | HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, 1.1, 2.2↵ | | 59 | HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, 1.1, 2.2↵
|
60 | );↵ | | 60 | );↵
|
61 | assertFalse(c1.equals(c2));↵ | | 61 | assertFalse(f1.equals(f2));↵
|
62 | c2 = new ColumnArrangement(↵ | | 62 | f2 = new FlowArrangement(↵
|
63 | HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, 1.1, 2.2↵ | | 63 | HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, 1.1, 2.2↵
|
64 | );↵ | | 64 | );↵
|
65 | assertTrue(c1.equals(c2));↵ | | 65 | assertTrue(f1.equals(f2));↵
|
66 | ↵ | | 66 | ↵
|
67 | }↵ | | 67 | }↵
|
|
68 | /**↵ | | 68 | /**↵
|
69 | * Immutable - cloning is not necessary.↵ | | 69 | * Immutable - cloning is not necessary.↵
|
70 | */↵ | | 70 | */↵
|
71 | public void testCloning() {↵ | | 71 | public void testCloning() {↵
|
72 | FlowArrangement f1 = new FlowArrangement();↵ | | 72 | FlowArrangement f1 = new FlowArrangement();↵
|
73 | assertFalse(f1 instanceof Cloneable);↵ | | 73 | assertFalse(f1 instanceof Cloneable);↵
|
74 | }↵ | | 74 | }↵
|
|
75 | /**↵ | | 75 | /**↵
|
76 | * Serialize an instance, restore it, and check for equality.↵ | | 76 | * Serialize an instance, restore it, and check for equality.↵
|
77 | */↵ | | 77 | */↵
|
78 | public void testSerialization() {↵ | | 78 | public void testSerialization() {↵
|
79 | FlowArrangement f1 = new FlowArrangement(↵ | | 79 | FlowArrangement f1 = new FlowArrangement(↵
|
80 | HorizontalAlignment.LEFT, VerticalAlignment.TOP, 1.0, 2.0↵ | | 80 | HorizontalAlignment.LEFT, VerticalAlignment.TOP, 1.0, 2.0↵
|
81 | );↵ | | 81 | );↵
|
82 | FlowArrangement f2 = null;↵ | | 82 | FlowArrangement f2 = null;↵
|
83 | try {↵ | | 83 | try {↵
|
84 | ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵ | | 84 | ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵
|
85 | ObjectOutput out = new ObjectOutputStream(buffer);↵ | | 85 | ObjectOutput out = new ObjectOutputStream(buffer);↵
|
86 | out.writeObject(f1);↵ | | 86 | out.writeObject(f1);↵
|
87 | out.close();↵ | | 87 | out.close();↵
|
|
88 | ObjectInput in = new ObjectInputStream(↵ | | 88 | ObjectInput in = new ObjectInputStream(↵
|
89 | new ByteArrayInputStream(buffer.toByteArray())↵ | | 89 | new ByteArrayInputStream(buffer.toByteArray())↵
|
90 | );↵ | | 90 | );↵
|
91 | f2 = (FlowArrangement) in.readObject();↵ | | 91 | f2 = (FlowArrangement) in.readObject();↵
|
92 | in.close();↵ | | 92 | in.close();↵
|
93 | }↵ | | 93 | }↵
|
94 | catch (Exception e) {↵ | | 94 | catch (Exception e) {↵
|
95 | System.out.println(e.toString());↵ | | 95 | System.out.println(e.toString());↵
|
96 | }↵ | | 96 | }↵
|
97 | assertEquals(f1, f2) | | 97 | assertEquals(f1, f2)
|