1 | public class BoxAndWhiskerToolTipGeneratorTests extends TestCase {↵ | | 1 | public class IntervalCategoryLabelGeneratorTests 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(BoxAndWhiskerToolTipGeneratorTests.class);↵ | | 8 | return new TestSuite(IntervalCategoryLabelGeneratorTests.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 BoxAndWhiskerToolTipGeneratorTests(String name) {↵ | | 15 | public IntervalCategoryLabelGeneratorTests(String name) {↵
|
16 | super(name);↵ | | 16 | super(name);↵
|
17 | }↵ | | 17 | }↵
|
|
18 | /**↵ | | 18 | /**↵
|
19 | * A series of tests for the equals() method.↵ | | 19 | * Tests the equals() method.↵
|
20 | */↵ | | 20 | */↵
|
21 | public void testEquals() {↵ | | 21 | public void testEquals() {↵
|
|
22 | // standard test↵ | | 22 | ↵
|
23 | BoxAndWhiskerToolTipGenerator g1 = new BoxAndWhiskerToolTipGenerator();↵ | | |
|
24 | BoxAndWhiskerToolTipGenerator g2 = new BoxAndWhiskerToolTip↵ | | 23 | IntervalCategoryItemLabelGenerator g1↵
|
| | | 24 | = new IntervalCategoryItemLabelGenerator();↵
|
| | | 25 | IntervalCategoryItemLabelGenerator g2↵
|
25 | Generator();↵ | | 26 | = new IntervalCategoryItemLabelGenerator();↵
|
26 | assertTrue(g1.equals(g2));↵ | | 27 | assertTrue(g1.equals(g2));↵
|
27 | assertTrue(g2.equals(g1));↵ | | 28 | assertTrue(g2.equals(g1));↵
|
|
28 | // tooltip format↵ | | 29 | ↵
|
29 | g1 = new BoxAndWhiskerToolTipGenerator("{0} --> {1} {2}",↵ | | |
|
30 | new DecimalFormat("0.0"));↵ | | |
|
31 | g2 = new BoxAndWhiskerToolTipGenerator("{1} {2}",↵ | | 30 | g1 = new IntervalCategoryItemLabelGenerator("{3} - {4}",↵
|
32 | new DecimalFormat("0.0"));↵ | | 31 | new DecimalFormat("0.000"));↵
|
33 | assertFalse(g1.equals(g2));↵ | | 32 | assertFalse(g1.equals(g2));↵
|
34 | g2 = new BoxAndWhiskerToolTipGenerator("{0} --> {1} {2}",↵ | | 33 | g2 = new IntervalCategoryItemLabelGenerator("{3} - {4}",↵
|
35 | new DecimalFormat("0.0"));↵ | | 34 | new DecimalFormat("0.000"));↵
|
36 | assertTrue(g1.equals(g2));↵ | | 35 | assertTrue(g1.equals(g2));↵
|
|
37 | // Y format↵ | | 36 | ↵
|
38 | g1 = new BoxAndWhiskerToolTipGenerator("{0} --> {1} {2}",↵ | | 37 | g1 = new IntervalCategoryItemLabelGenerator("{3} - {4}",↵
|
39 | new DecimalFormat("0.0"));↵ | | 38 | new ↵
|
40 | g2 = new BoxAndWhiskerToolTip↵ | | 39 | SimpleDateFormat("d-MMM"));↵
|
| | | 40 | assertFalse(g1.equals(g2));↵
|
41 | Generator("{0} --> {1} {2}",↵ | | 41 | g2 = new IntervalCategoryItemLabelGenerator("{3} - {4}",↵
|
42 | new DecimalFormat("0.00"));↵ | | 42 | new SimpleDateFormat("d-MMM"));↵
|
43 | assertFalse(g1.equals(g2));↵ | | 43 | assertTrue(g1.equals(g2));↵
|
|
44 | }↵ | | 44 | }↵
|
|
45 | /**↵ | | 45 | /**↵
|
46 | * Simple check that hashCode is implemented.↵ | | 46 | * Simple check that hashCode is implemented.↵
|
47 | */↵ | | 47 | */↵
|
48 | public void testHashCode() {↵ | | 48 | public void testHashCode() {↵
|
49 | BoxAndWhiskerToolTipGenerator g1 = new BoxAndWhiskerToolTipGenerator();↵ | | 49 | ↵
|
50 | BoxAndWhiskerToolTipGenerator g2 = new BoxAndWhiskerToolTip↵ | | 50 | IntervalCategoryItemLabelGenerator g1↵
|
| | | 51 | = new IntervalCategoryItemLabelGenerator();↵
|
| | | 52 | IntervalCategoryItemLabelGenerator g2↵
|
51 | Generator();↵ | | 53 | = new IntervalCategoryItemLabelGenerator();↵
|
52 | assertTrue(g1.equals(g2));↵ | | 54 | assertTrue(g1.equals(g2));↵
|
53 | assertTrue(g1.hashCode() == g2.hashCode());↵ | | 55 | assertTrue(g1.hashCode() == g2.hashCode());↵
|
54 | }↵ | | 56 | }↵
|
|
55 | /**↵ | | 57 | /**↵
|
56 | * Confirm that cloning works.↵ | | 58 | * Confirm that cloning works.↵
|
57 | */↵ | | 59 | */↵
|
58 | public void testCloning() {↵ | | 60 | public void testCloning() {↵
|
59 | BoxAndWhiskerToolTipGenerator g1 = new BoxAndWhiskerToolTipGenerator();↵ | | 61 | ↵
|
60 | BoxAndWhiskerToolTip↵ | | 62 | IntervalCategoryItemLabelGenerator g1↵
|
| | | 63 | = new IntervalCategoryItemLabelGenerator();↵
|
61 | Generator g2 = null;↵ | | 64 | IntervalCategoryItemLabelGenerator g2 = null;↵
|
62 | try {↵ | | 65 | try {↵
|
63 | g2 = (BoxAndWhiskerToolTipGenerator) g1.clone();↵ | | 66 | g2 = (IntervalCategoryItemLabelGenerator) g1.clone();↵
|
64 | }↵ | | 67 | }↵
|
65 | catch (CloneNotSupportedException e) {↵ | | 68 | catch (CloneNotSupportedException e) {↵
|
66 | e.printStackTrace();↵ | | 69 | e.printStackTrace();↵
|
67 | }↵ | | 70 | }↵
|
68 | assertTrue(g1 != g2);↵ | | 71 | assertTrue(g1 != g2);↵
|
69 | assertTrue(g1.getClass() == g2.getClass());↵ | | 72 | assertTrue(g1.getClass() == g2.getClass());↵
|
70 | assertTrue(g1.equals(g2));↵ | | 73 | assertTrue(g1.equals(g2));↵
|
71 | }↵ | | 74 | }↵
|
|
72 | /**↵ | | 75 | /**↵
|
73 | * Check to ensure that this class implements PublicCloneable.↵ | | 76 | * Check to ensure that this class implements PublicCloneable.↵
|
74 | */↵ | | 77 | */↵
|
75 | public void testPublicCloneable() {↵ | | 78 | public void testPublicCloneable() {↵
|
76 | BoxAndWhiskerToolTipGenerator g1 = new BoxAndWhiskerToolTip↵ | | 79 | IntervalCategoryItemLabelGenerator g1↵
|
77 | Generator();↵ | | 80 | = new IntervalCategoryItemLabelGenerator();↵
|
78 | assertTrue(g1 instanceof PublicCloneable);↵ | | 81 | assertTrue(g1 instanceof PublicCloneable);↵
|
79 | }↵ | | 82 | }↵
|
|
80 | /**↵ | | 83 | /**↵
|
81 | * Serialize an instance, restore it, and check for equality.↵ | | 84 | * Serialize an instance, restore it, and check for equality.↵
|
82 | */↵ | | 85 | */↵
|
83 | public void testSerialization() {↵ | | 86 | public void testSerialization() {↵
|
|
84 | BoxAndWhiskerToolTipGenerator g1 = new BoxAndWhiskerToolTipGenerator();↵ | | 87 | ↵
|
85 | BoxAndWhiskerToolTip↵ | | 88 | IntervalCategoryItemLabelGenerator g1↵
|
| | | 89 | = new IntervalCategoryItemLabelGenerator("{3} - {4}",↵
|
| | | 90 | DateFormat.getInstance());↵
|
86 | Generator g2 = null;↵ | | 91 | IntervalCategoryItemLabelGenerator g2 = null;↵
|
|
87 | try {↵ | | 92 | try {↵
|
88 | ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵ | | 93 | ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵
|
89 | ObjectOutput out = new ObjectOutputStream(buffer);↵ | | 94 | ObjectOutput out = new ObjectOutputStream(buffer);↵
|
90 | out.writeObject(g1);↵ | | 95 | out.writeObject(g1);↵
|
91 | out.close();↵ | | 96 | out.close();↵
|
|
92 | ObjectInput in = new ObjectInputStream(↵ | | 97 | ObjectInput in = new ObjectInputStream(↵
|
93 | new ByteArrayInputStream(buffer.toByteArray()));↵ | | 98 | new ByteArrayInputStream(buffer.toByteArray()));↵
|
94 | g2 = (BoxAndWhiskerToolTipGenerator) in.readObject();↵ | | 99 | g2 = (IntervalCategoryItemLabelGenerator) in.readObject();↵
|
95 | in.close();↵ | | 100 | in.close();↵
|
96 | }↵ | | 101 | }↵
|
97 | catch (Exception e) {↵ | | 102 | catch (Exception e) {↵
|
98 | e.printStackTrace();↵ | | 103 | e.printStackTrace();↵
|
99 | }↵ | | 104 | }↵
|
100 | assertEquals(g1, g2) | | 105 | assertEquals(g1, g2)
|