1. /* ===========================================================
  2. * JFreeChart : a free chart library for the Java(tm) platform
  3. * ===========================================================
  4. *
  5. * (C) Copyright 2000-2004, 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 under the terms
  10. * of the GNU Lesser General Public License as published by the Free Software Foundation;
  11. * either version 2.1 of the License, or (at your option) any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  14. * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  15. * See the GNU Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public License along with this
  18. * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  19. * Boston, MA 02111-1307, USA.
  20. *
  21. * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
  22. * in the United States and other countries.]
  23. *
  24. * --------------------------------
  25. * AbstractXYItemRendererTests.java
  26. * --------------------------------
  27. * (C) Copyright 2004, by Object Refinery Limited and Contributors.
  28. *
  29. * Original Author: David Gilbert (for Object Refinery Limited);
  30. * Contributor(s): -;
  31. *
  32. * $Id: AbstractXYItemRendererTests.java,v 1.3 2004/11/27 17:15:45 mungady Exp $
  33. *
  34. * Changes
  35. * -------
  36. * 06-Oct-2004 : Version 1 (DG);
  37. *
  38. */
  39. package org.jfree.chart.renderer.xy.junit;
  40. import junit.framework.Test;
  41. import junit.framework.TestCase;
  42. import junit.framework.TestSuite;
  43. import org.jfree.chart.renderer.xy.AbstractXYItemRenderer;
  44. import org.jfree.chart.renderer.xy.StandardXYItemRenderer;
  45. import org.jfree.data.Range;
  46. import org.jfree.data.xy.XYDataset;
  47. import org.jfree.data.xy.XYSeries;
  48. import org.jfree.data.xy.XYSeriesCollection;
  49. /**
  50. * Tests for the {@link AbstractXYItemRenderer} class.
  51. */
  52. public class AbstractXYItemRendererTests extends TestCase {
  53. /**
  54. * Returns the tests as a test suite.
  55. *
  56. * @return The test suite.
  57. */
  58. public static Test suite() {
  59. return new TestSuite(AbstractXYItemRendererTests.class);
  60. }
  61. /**
  62. * Constructs a new set of tests.
  63. *
  64. * @param name the name of the tests.
  65. */
  66. public AbstractXYItemRendererTests(String name) {
  67. super(name);
  68. }
  69. /**
  70. * Creates a test dataset.
  71. *
  72. * @return A test dataset.
  73. */
  74. private XYDataset createDataset1() {
  75. XYSeries series = new XYSeries("Series");
  76. series.add(1.0, 1.0);
  77. series.add(2.0, 2.0);
  78. series.add(3.0, 3.0);
  79. XYSeriesCollection dataset = new XYSeriesCollection();
  80. dataset.addSeries(series);
  81. return dataset;
  82. }
  83. private static final double EPSILON = 0.0000000001;
  84. /**
  85. * Some checks for the findDomainBounds() method.
  86. */
  87. public void testFindDomainBounds() {
  88. AbstractXYItemRenderer renderer = new StandardXYItemRenderer();
  89. // check the bounds of a simple dataset
  90. XYDataset dataset = createDataset1();
  91. Range r = renderer.findDomainBounds(dataset);
  92. assertEquals(1.0, r.getLowerBound(), EPSILON);
  93. assertEquals(3.0, r.getUpperBound(), EPSILON);
  94. // check that a null dataset returns null bounds
  95. assertTrue(renderer.findDomainBounds(null) == null);
  96. }
  97. /**
  98. * Some checks for the findRangeBounds() method.
  99. */
  100. public void testFindRangeBounds() {
  101. AbstractXYItemRenderer renderer = new StandardXYItemRenderer();
  102. // check that a null dataset returns null bounds
  103. assertTrue(renderer.findRangeBounds(null) == null);
  104. }
  105. }