TimeSeriesDataItemTest.java 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /* ===========================================================
  2. * JFreeChart : a free chart library for the Java(tm) platform
  3. * ===========================================================
  4. *
  5. * (C) Copyright 2000-2013, 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. * [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
  25. * Other names may be trademarks of their respective owners.]
  26. *
  27. * ---------------------------
  28. * TimeSeriesDataItemTest.java
  29. * ---------------------------
  30. * (C) Copyright 2003-2013, by Object Refinery Limited.
  31. *
  32. * Original Author: David Gilbert (for Object Refinery Limited);
  33. * Contributor(s): -;
  34. *
  35. * Changes
  36. * -------
  37. * 13-Mar-2003 : Version 1 (DG);
  38. *
  39. */
  40. package org.jfree.data.time;
  41. import static org.junit.Assert.assertTrue;
  42. import static org.junit.Assert.assertEquals;
  43. import static org.junit.Assert.assertFalse;
  44. import org.jfree.chart.TestUtilities;
  45. import org.junit.Test;
  46. /**
  47. * Tests for the {@link TimeSeriesDataItem} class.
  48. */
  49. public class TimeSeriesDataItemTest {
  50. /**
  51. * Test that an instance is equal to itself.
  52. *
  53. * SourceForge Bug ID: 558850.
  54. */
  55. @Test
  56. public void testEqualsSelf() {
  57. TimeSeriesDataItem item = new TimeSeriesDataItem(new Day(23, 9, 2001),
  58. 99.7);
  59. assertTrue(item.equals(item));
  60. }
  61. /**
  62. * Test the equals() method.
  63. */
  64. @Test
  65. public void testEquals() {
  66. TimeSeriesDataItem item1 = new TimeSeriesDataItem(new Day(23, 9, 2001),
  67. 99.7);
  68. TimeSeriesDataItem item2 = new TimeSeriesDataItem(new Day(23, 9, 2001),
  69. 99.7);
  70. assertTrue(item1.equals(item2));
  71. assertTrue(item2.equals(item1));
  72. item1.setValue(new Integer(5));
  73. assertFalse(item1.equals(item2));
  74. item2.setValue(new Integer(5));
  75. assertTrue(item1.equals(item2));
  76. }
  77. /**
  78. * Serialize an instance, restore it, and check for equality.
  79. */
  80. @Test
  81. public void testSerialization() {
  82. TimeSeriesDataItem item1 = new TimeSeriesDataItem(new Day(23, 9, 2001),
  83. 99.7);
  84. TimeSeriesDataItem item2 = (TimeSeriesDataItem)
  85. TestUtilities.serialised(item1);
  86. assertEquals(item1, item2);
  87. }
  88. }