KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfree > chart > needle > junit > MeterNeedleTests


1 /* ===========================================================
2  * JFreeChart : a free chart library for the Java(tm) platform
3  * ===========================================================
4  *
5  * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
6  *
7  * Project Info: http://www.jfree.org/jfreechart/index.html
8  *
9  * This library is free software; you can redistribute it and/or modify it
10  * under the terms of the GNU Lesser General Public License as published by
11  * the Free Software Foundation; either version 2.1 of the License, or
12  * (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17  * License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
22  * USA.
23  *
24  * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
25  * in the United States and other countries.]
26  *
27  * ---------------------
28  * MeterNeedleTests.java
29  * ---------------------
30  * (C) Copyright 2005, by Object Refinery Limited and Contributors.
31  *
32  * Original Author: David Gilbert (for Object Refinery Limited);
33  * Contributor(s): -;
34  *
35  * $Id: MeterNeedleTests.java,v 1.1.2.1 2006/10/03 15:41:47 mungady Exp $
36  *
37  * Changes
38  * -------
39  * 08-Jun-2005 : Version 1 (DG);
40  *
41  */

42
43 package org.jfree.chart.needle.junit;
44
45 import java.awt.BasicStroke JavaDoc;
46 import java.awt.Color JavaDoc;
47 import java.awt.GradientPaint JavaDoc;
48 import java.awt.Stroke JavaDoc;
49
50 import junit.framework.Test;
51 import junit.framework.TestCase;
52 import junit.framework.TestSuite;
53
54 import org.jfree.chart.needle.LineNeedle;
55 import org.jfree.chart.needle.MeterNeedle;
56
57 /**
58  * Tests for the {@link MeterNeedle} class.
59  */

60 public class MeterNeedleTests extends TestCase {
61     /**
62      * Returns the tests as a test suite.
63      *
64      * @return The test suite.
65      */

66     public static Test suite() {
67         return new TestSuite(MeterNeedleTests.class);
68     }
69
70     /**
71      * Constructs a new set of tests.
72      *
73      * @param name the name of the tests.
74      */

75     public MeterNeedleTests(String JavaDoc name) {
76         super(name);
77     }
78
79     /**
80      * Check that the equals() method can distinguish all fields.
81      */

82     public void testEquals() {
83         MeterNeedle n1 = new LineNeedle();
84         MeterNeedle n2 = new LineNeedle();
85         assertTrue(n1.equals(n2));
86         
87         n1.setFillPaint(new GradientPaint JavaDoc(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue));
88         assertFalse(n1.equals(n2));
89         n2.setFillPaint(new GradientPaint JavaDoc(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue));
90         assertTrue(n1.equals(n2));
91         
92         n1.setOutlinePaint(new GradientPaint JavaDoc(5.0f, 6.0f, Color.red, 7.0f, 8.0f, Color.blue));
93         assertFalse(n1.equals(n2));
94         n2.setOutlinePaint(new GradientPaint JavaDoc(5.0f, 6.0f, Color.red, 7.0f, 8.0f, Color.blue));
95         assertTrue(n1.equals(n2));
96
97         n1.setHighlightPaint(new GradientPaint JavaDoc(9.0f, 0.0f, Color.red, 1.0f, 2.0f, Color.blue));
98         assertFalse(n1.equals(n2));
99         n2.setHighlightPaint(new GradientPaint JavaDoc(9.0f, 0.0f, Color.red, 1.0f, 2.0f, Color.blue));
100         assertTrue(n1.equals(n2));
101         
102         Stroke JavaDoc s = new BasicStroke JavaDoc(1.23f);
103         n1.setOutlineStroke(s);
104         assertFalse(n1.equals(n2));
105         n2.setOutlineStroke(s);
106         assertTrue(n1.equals(n2));
107         
108         n1.setRotateX(1.23);
109         assertFalse(n1.equals(n2));
110         n2.setRotateX(1.23);
111         assertTrue(n1.equals(n2));
112         
113         n1.setRotateY(4.56);
114         assertFalse(n1.equals(n2));
115         n2.setRotateY(4.56);
116         assertTrue(n1.equals(n2));
117         
118         n1.setSize(11);
119         assertFalse(n1.equals(n2));
120         n2.setSize(11);
121         assertTrue(n1.equals(n2));
122     }
123
124 }
125
Popular Tags