Example usage for org.jfree.data.time TimeSeries equals

List of usage examples for org.jfree.data.time TimeSeries equals

Introduction

In this page you can find the example usage for org.jfree.data.time TimeSeries equals.

Prototype

@Override
public boolean equals(Object obj) 

Source Link

Document

Tests the series for equality with an arbitrary object.

Usage

From source file:org.jfree.data.time.junit.TimeSeriesTest.java

/**
 * Another test of the clone() method./*  w w  w . j ava 2 s. c o m*/
 */
public void testClone2() {
    TimeSeries s1 = new TimeSeries("S1");
    s1.add(new Year(2007), 100.0);
    s1.add(new Year(2008), null);
    s1.add(new Year(2009), 200.0);
    TimeSeries s2 = null;
    try {
        s2 = (TimeSeries) s1.clone();
    } catch (CloneNotSupportedException e) {
        e.printStackTrace();
    }
    assertTrue(s1.equals(s2));

    // check independence
    s2.addOrUpdate(new Year(2009), 300.0);
    assertFalse(s1.equals(s2));
    s1.addOrUpdate(new Year(2009), 300.0);
    assertTrue(s1.equals(s2));
}

From source file:org.jfree.data.time.TimeSeriesTest.java

/**
 * Serialize an instance, restore it, and check for equality.
 *///from   w  w w.  ja  v  a  2s. c  o  m
@Test
public void testSerialization() {
    TimeSeries s1 = new TimeSeries("A test");
    s1.add(new Year(2000), 13.75);
    s1.add(new Year(2001), 11.90);
    s1.add(new Year(2002), null);
    s1.add(new Year(2005), 19.32);
    s1.add(new Year(2007), 16.89);
    TimeSeries s2 = (TimeSeries) TestUtilities.serialised(s1);
    assertTrue(s1.equals(s2));
}

From source file:org.jfree.data.time.junit.TimeSeriesTest.java

/**
 * Serialize an instance, restore it, and check for equality.
 */// www.ja v a 2s.c  o  m
public void testSerialization() {
    TimeSeries s1 = new TimeSeries("A test");
    s1.add(new Year(2000), 13.75);
    s1.add(new Year(2001), 11.90);
    s1.add(new Year(2002), null);
    s1.add(new Year(2005), 19.32);
    s1.add(new Year(2007), 16.89);
    TimeSeries s2 = null;
    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(s1);
        out.close();
        ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
        s2 = (TimeSeries) in.readObject();
        in.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
    assertTrue(s1.equals(s2));
}