/* ===========================================================
 * JFreeChart : a free chart library for the Java(tm) platform
 * ===========================================================
 *
 * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors.
 *
 * Project Info:  http://www.jfree.org/jfreechart/index.html
 *
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
 * License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
 * USA.
 *
 * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. 
 * Other names may be trademarks of their respective owners.]
 *
 * --------------------------
 * CrosshairOverlayTests.java
 * --------------------------
 * (C) Copyright 2009, by Object Refinery Limited and Contributors.
 *
 * Original Author:  David Gilbert (for Object Refinery Limited);
 * Contributor(s):   -;
 *
 * Changes
 * -------
 * 10-Apr-2009 : Version 1 (DG);
 *
 */

package org.jfree.chart.panel;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.GradientPaint;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

import org.jfree.chart.panel.CrosshairOverlay;
import org.jfree.chart.plot.Crosshair;

/**
 * Tests for the {@link CrosshairOverlay} class.
 */
public class CrosshairOverlayTest extends TestCase {

    /**
     * Returns the tests as a test suite.
     *
     * @return The test suite.
     */
    public static Test suite() {
        return new TestSuite(CrosshairOverlayTest.class);
    }

    /**
     * Constructs a new set of tests.
     *
     * @param name  the name of the tests.
     */
    public CrosshairOverlayTest(String name) {
        super(name);
    }

    /**
     * Confirm that the equals method can distinguish all the required fields.
     */
    public void testEquals() {
        CrosshairOverlay o1 = new CrosshairOverlay();
        CrosshairOverlay o2 = new CrosshairOverlay();
        assertEquals(o1, o2);
    }

    /**
     * Serialize an instance, restore it, and check for equality.
     */
    public void testSerialization() throws IOException, ClassNotFoundException {
        CrosshairOverlay o1 = new CrosshairOverlay();
        o1.addDomainCrosshair(new Crosshair(99.9));
        o1.addRangeCrosshair(new Crosshair(1.23, new GradientPaint(1.0f, 2.0f,
                Color.red, 3.0f, 4.0f, Color.blue), new BasicStroke(1.1f)));
        CrosshairOverlay o2;
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(o1);
        out.close();
        ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(
                buffer.toByteArray()));
        o2 = (CrosshairOverlay) in.readObject();
            in.close();
        assertTrue(o1.equals(o2));
    }

    /**
     * Basic checks for cloning.
     */
    public void testCloning() throws CloneNotSupportedException {
        CrosshairOverlay o1 = new CrosshairOverlay();
        o1.addDomainCrosshair(new Crosshair(99.9));
        o1.addRangeCrosshair(new Crosshair(1.23, new GradientPaint(1.0f, 2.0f,
                Color.red, 3.0f, 4.0f, Color.blue), new BasicStroke(1.1f)));
        CrosshairOverlay o2 = (CrosshairOverlay) o1.clone();
        assertTrue(o1 != o2);
        assertTrue(o1.getClass() == o2.getClass());
        assertTrue(o1.equals(o2));

        o1.addDomainCrosshair(new Crosshair(3.21));
        o1.addRangeCrosshair(new Crosshair(4.32));
        assertFalse(o1.equals(o2));
    }

}

@@ -1241,25 +1241,24 @@
 ------------
--
 %0A * Crosshai
@@ -1269,17 +1269,16 @@
 rlayTest
-s
 .java%0A *
@@ -1299,25 +1299,24 @@
 ------------
--
 %0A * (C) Copy
@@ -1325,16 +1325,21 @@
 ght 2009
+-2013
 , by Obj
@@ -1654,237 +1654,8 @@
 int;
-%0Aimport java.io.ByteArrayInputStream;%0Aimport java.io.ByteArrayOutputStream;%0Aimport java.io.IOException;%0Aimport java.io.ObjectInput;%0Aimport java.io.ObjectInputStream;%0Aimport java.io.ObjectOutput;%0Aimport java.io.ObjectOutputStream;
 %0A%0Aim
@@ -1748,17 +1748,16 @@
 tSuite;%0A
-%0A
 import o
@@ -1775,31 +1775,23 @@
 art.
-panel.CrosshairOverlay;
+TestUtilities;%0A
 %0Aimp
@@ -2703,51 +2703,8 @@
 on()
- throws IOException, ClassNotFoundException
  %7B%0A 
@@ -2995,370 +2995,57 @@
 y o2
-;%0A        ByteArrayOutputStream buffer = new ByteArrayOutputStream();%0A        ObjectOutput out = new ObjectOutputStream(buffer);%0A        out.writeObject(o1);%0A        out.close();%0A        ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(%0A                buffer.toByteArray()));%0A        o2 = (CrosshairOverlay) in.readObject();%0A            in.close(
+ = (CrosshairOverlay) TestUtilities.serialised(o1
 );%0A 
@@ -3057,34 +3057,29 @@
   assert
-True(o1.e
+E
 quals(o
+1, o
 2
-)
 );%0A    %7D

Simplify code with TestUtilities.serialized() method.