1 | public class ItemLabelPositionTests extends TestCase {↵ | | 1 | public class StandardXYURLGeneratorTests extends TestCase {↵
|
|
2 | /**↵ | | 2 | /**↵
|
3 | * Returns the tests as a test suite.↵ | | 3 | * Returns the tests as a test suite.↵
|
4 | *↵ | | 4 | *↵
|
5 | * @return The test suite.↵ | | 5 | * @return The test suite.↵
|
6 | */↵ | | 6 | */↵
|
7 | public static Test suite() {↵ | | 7 | public static Test suite() {↵
|
8 | return new TestSuite(ItemLabelPositionTests.class);↵ | | 8 | return new TestSuite(StandardXYURLGeneratorTests.class);↵
|
9 | }↵ | | 9 | }↵
|
|
10 | /**↵ | | 10 | /**↵
|
11 | * Constructs a new set of tests.↵ | | 11 | * Constructs a new set of tests.↵
|
12 | *↵ | | 12 | *↵
|
13 | * @param name the name of the tests.↵ | | 13 | * @param name the name of the tests.↵
|
14 | */↵ | | 14 | */↵
|
15 | public ItemLabelPositionTests(String name) {↵ | | 15 | public StandardXYURLGeneratorTests(String name) {↵
|
16 | super(name);↵ | | 16 | super(name);↵
|
17 | }↵ | | 17 | }↵
|
|
18 | /**↵ | | |
|
19 | * Check that the equals() method distinguishes all fields.↵ | | |
|
20 | */↵ | | |
|
21 | public void testEquals() {↵ | | |
|
22 | ItemLabelPosition p1 = new ItemLabelPosition();↵ | | |
|
23 | ItemLabelPosition p2 = new ItemLabelPosition();↵ | | |
|
24 | assertEquals(p1, p2);↵ | | |
|
25 | }↵ | | |
|
|
26 | /**↵ | | 18 | /**↵
|
27 | * Serialize an instance, restore it, and check for equality.↵ | | 19 | * Serialize an instance, restore it, and check for equality.↵
|
28 | */↵ | | 20 | */↵
|
29 | public void testSerialization() {↵ | | 21 | public void testSerialization() {↵
|
|
30 | ItemLabelPosition p1 = new ItemLabelPosition();↵ | | 22 | ↵
|
31 | ItemLabelPosition p↵ | | 23 | StandardXYURLGenerator g1 = new StandardXYURLGenerator("index.html?");↵
|
32 | 2 = null;↵ | | 24 | StandardXYURLGenerator g2 = null;↵
|
|
33 | try {↵ | | 25 | try {↵
|
34 | ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵ | | 26 | ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵
|
35 | ObjectOutput out = new ObjectOutputStream(buffer);↵ | | 27 | ObjectOutput out = new ObjectOutputStream(buffer);↵
|
36 | out.writeObject(p1);↵ | | 28 | out.writeObject(g1);↵
|
37 | out.close();↵ | | 29 | out.close();↵
|
|
38 | ObjectInput in = new ObjectInputStream(↵ | | 30 | ObjectInput in = new ObjectInputStream(↵
|
39 | new ByteArrayInputStream(↵ | | 31 | new ByteArrayInputStream(↵
|
40 | buffer.toByteArray()));↵ | | 32 | buffer.toByteArray()));↵
|
41 | p2 = (ItemLabelPosition) in.readObject();↵ | | 33 | g2 = (StandardXYURLGenerator) in.readObject();↵
|
42 | in.close();↵ | | 34 | in.close();↵
|
43 | }↵ | | 35 | }↵
|
44 | catch (Exception e) {↵ | | 36 | catch (Exception e) {↵
|
45 | e.printStackTrace();↵ | | 37 | e.printStackTrace();↵
|
46 | }↵ | | 38 | }↵
|
47 | assertEquals(p1, p2↵ | | 39 | assertEquals(g1, g2);↵
|
|
| | | 40 | }↵
|
|
| | | 41 | /**↵
|
| | | 42 | * Checks that the class does not implement PublicCloneable (the generator↵
|
| | | 43 | * is immutable).↵
|
| | | 44 | */↵
|
| | | 45 | public void testPublicCloneable() {↵
|
| | | 46 | StandardXYURLGenerator g1 = new StandardXYURLGenerator("index.html?");↵
|
48 | ) | | 47 | assertFalse(g1 instanceof PublicCloneable)
|