KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfree > chart > renderer > xy > junit > AbstractXYItemRendererTests


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  * AbstractXYItemRendererTests.java
29  * --------------------------------
30  * (C) Copyright 2004, by Object Refinery Limited and Contributors.
31  *
32  * Original Author: David Gilbert (for Object Refinery Limited);
33  * Contributor(s): -;
34  *
35  * $Id: AbstractXYItemRendererTests.java,v 1.1.2.1 2006/10/03 15:41:46 mungady Exp $
36  *
37  * Changes
38  * -------
39  * 06-Oct-2004 : Version 1 (DG);
40  *
41  */

42
43 package org.jfree.chart.renderer.xy.junit;
44
45 import junit.framework.Test;
46 import junit.framework.TestCase;
47 import junit.framework.TestSuite;
48
49 import org.jfree.chart.renderer.xy.AbstractXYItemRenderer;
50 import org.jfree.chart.renderer.xy.StandardXYItemRenderer;
51 import org.jfree.data.Range;
52 import org.jfree.data.xy.XYDataset;
53 import org.jfree.data.xy.XYSeries;
54 import org.jfree.data.xy.XYSeriesCollection;
55
56 /**
57  * Tests for the {@link AbstractXYItemRenderer} class.
58  */

59 public class AbstractXYItemRendererTests extends TestCase {
60
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(AbstractXYItemRendererTests.class);
68     }
69
70     /**
71      * Constructs a new set of tests.
72      *
73      * @param name the name of the tests.
74      */

75     public AbstractXYItemRendererTests(String JavaDoc name) {
76         super(name);
77     }
78
79     /**
80      * Creates a test dataset.
81      *
82      * @return A test dataset.
83      */

84     private XYDataset createDataset1() {
85         XYSeries series = new XYSeries("Series");
86         series.add(1.0, 1.0);
87         series.add(2.0, 2.0);
88         series.add(3.0, 3.0);
89         XYSeriesCollection dataset = new XYSeriesCollection();
90         dataset.addSeries(series);
91         return dataset;
92     }
93     
94     private static final double EPSILON = 0.0000000001;
95     
96     /**
97      * Some checks for the findDomainBounds() method.
98      */

99     public void testFindDomainBounds() {
100         AbstractXYItemRenderer renderer = new StandardXYItemRenderer();
101         
102         // check the bounds of a simple dataset
103
XYDataset dataset = createDataset1();
104         Range r = renderer.findDomainBounds(dataset);
105         assertEquals(1.0, r.getLowerBound(), EPSILON);
106         assertEquals(3.0, r.getUpperBound(), EPSILON);
107         
108         // check that a null dataset returns null bounds
109
assertTrue(renderer.findDomainBounds(null) == null);
110     }
111
112     /**
113      * Some checks for the findRangeBounds() method.
114      */

115     public void testFindRangeBounds() {
116         AbstractXYItemRenderer renderer = new StandardXYItemRenderer();
117         // check that a null dataset returns null bounds
118
assertTrue(renderer.findRangeBounds(null) == null);
119     }
120
121 }
122
Popular Tags