001: /* ===========================================================
002: * JFreeChart : a free chart library for the Java(tm) platform
003: * ===========================================================
004: *
005: * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
006: *
007: * Project Info: http://www.jfree.org/jfreechart/index.html
008: *
009: * This library is free software; you can redistribute it and/or modify it
010: * under the terms of the GNU Lesser General Public License as published by
011: * the Free Software Foundation; either version 2.1 of the License, or
012: * (at your option) any later version.
013: *
014: * This library is distributed in the hope that it will be useful, but
015: * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
016: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
017: * License for more details.
018: *
019: * You should have received a copy of the GNU Lesser General Public
020: * License along with this library; if not, write to the Free Software
021: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
022: * USA.
023: *
024: * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
025: * in the United States and other countries.]
026: *
027: * ---------------------
028: * MeterNeedleTests.java
029: * ---------------------
030: * (C) Copyright 2005, by Object Refinery Limited and Contributors.
031: *
032: * Original Author: David Gilbert (for Object Refinery Limited);
033: * Contributor(s): -;
034: *
035: * $Id: MeterNeedleTests.java,v 1.1.2.1 2006/10/03 15:41:47 mungady Exp $
036: *
037: * Changes
038: * -------
039: * 08-Jun-2005 : Version 1 (DG);
040: *
041: */
042:
043: package org.jfree.chart.needle.junit;
044:
045: import java.awt.BasicStroke;
046: import java.awt.Color;
047: import java.awt.GradientPaint;
048: import java.awt.Stroke;
049:
050: import junit.framework.Test;
051: import junit.framework.TestCase;
052: import junit.framework.TestSuite;
053:
054: import org.jfree.chart.needle.LineNeedle;
055: import org.jfree.chart.needle.MeterNeedle;
056:
057: /**
058: * Tests for the {@link MeterNeedle} class.
059: */
060: public class MeterNeedleTests extends TestCase {
061: /**
062: * Returns the tests as a test suite.
063: *
064: * @return The test suite.
065: */
066: public static Test suite() {
067: return new TestSuite(MeterNeedleTests.class);
068: }
069:
070: /**
071: * Constructs a new set of tests.
072: *
073: * @param name the name of the tests.
074: */
075: public MeterNeedleTests(String name) {
076: super (name);
077: }
078:
079: /**
080: * Check that the equals() method can distinguish all fields.
081: */
082: public void testEquals() {
083: MeterNeedle n1 = new LineNeedle();
084: MeterNeedle n2 = new LineNeedle();
085: assertTrue(n1.equals(n2));
086:
087: n1.setFillPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f,
088: 4.0f, Color.blue));
089: assertFalse(n1.equals(n2));
090: n2.setFillPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f,
091: 4.0f, Color.blue));
092: assertTrue(n1.equals(n2));
093:
094: n1.setOutlinePaint(new GradientPaint(5.0f, 6.0f, Color.red,
095: 7.0f, 8.0f, Color.blue));
096: assertFalse(n1.equals(n2));
097: n2.setOutlinePaint(new GradientPaint(5.0f, 6.0f, Color.red,
098: 7.0f, 8.0f, Color.blue));
099: assertTrue(n1.equals(n2));
100:
101: n1.setHighlightPaint(new GradientPaint(9.0f, 0.0f, Color.red,
102: 1.0f, 2.0f, Color.blue));
103: assertFalse(n1.equals(n2));
104: n2.setHighlightPaint(new GradientPaint(9.0f, 0.0f, Color.red,
105: 1.0f, 2.0f, Color.blue));
106: assertTrue(n1.equals(n2));
107:
108: Stroke s = new BasicStroke(1.23f);
109: n1.setOutlineStroke(s);
110: assertFalse(n1.equals(n2));
111: n2.setOutlineStroke(s);
112: assertTrue(n1.equals(n2));
113:
114: n1.setRotateX(1.23);
115: assertFalse(n1.equals(n2));
116: n2.setRotateX(1.23);
117: assertTrue(n1.equals(n2));
118:
119: n1.setRotateY(4.56);
120: assertFalse(n1.equals(n2));
121: n2.setRotateY(4.56);
122: assertTrue(n1.equals(n2));
123:
124: n1.setSize(11);
125: assertFalse(n1.equals(n2));
126: n2.setSize(11);
127: assertTrue(n1.equals(n2));
128: }
129:
130: }
|