org.jfree.chart.TestUtilities Java Examples

The following examples show how to use org.jfree.chart.TestUtilities. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XYPlotTest.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Problem to reproduce a bug in serialization.  The bug (first reported
 * against the {@link org.jfree.chart.plot.CategoryPlot} class) is a null
 * pointer exception that occurs when drawing a plot after deserialization.
 * It is caused by four temporary storage structures (axesAtTop,
 * axesAtBottom, axesAtLeft and axesAtRight - all initialized as empty
 * lists in the constructor) not being initialized by the readObject()
 * method following deserialization.  This test has been written to
 * reproduce the bug (now fixed).
 */
@Test
public void testSerialization3() {

    XYSeriesCollection dataset = new XYSeriesCollection();
    JFreeChart chart = ChartFactory.createXYLineChart("Test Chart",
            "Domain Axis", "Range Axis", dataset);
    JFreeChart chart2 = (JFreeChart) TestUtilities.serialised(chart);
    assertEquals(chart, chart2);
    try {
        chart2.createBufferedImage(300, 200);
    }
    catch (Exception e) {
        fail("No exception should be thrown.");
    }
}
 
Example #2
Source File: DialTextAnnotationTest.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Serialize an instance, restore it, and check for equality.
 */
@Test
public void testSerialization() {
    // test a default instance
    DialTextAnnotation a1 = new DialTextAnnotation("A1");
    DialTextAnnotation a2 = (DialTextAnnotation) TestUtilities.serialised(a1);
    assertEquals(a1, a2);

    // test a custom instance
    a1 = new DialTextAnnotation("A1");
    a1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f,
            Color.blue));

    a2 = (DialTextAnnotation) TestUtilities.serialised(a1);
    assertEquals(a1, a2);
}
 
Example #3
Source File: TaskSeriesCollectionTest.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Serialize an instance, restore it, and check for equality.
 */
@Test
public void testSerialization() {
    TaskSeries s1 = new TaskSeries("S");
    s1.add(new Task("T1", new Date(1), new Date(2)));
    s1.add(new Task("T2", new Date(11), new Date(22)));
    TaskSeries s2 = new TaskSeries("S");
    s2.add(new Task("T1", new Date(1), new Date(2)));
    s2.add(new Task("T2", new Date(11), new Date(22)));
    TaskSeriesCollection c1 = new TaskSeriesCollection();
    c1.add(s1);
    c1.add(s2);
    TaskSeriesCollection c2 = (TaskSeriesCollection) 
            TestUtilities.serialised(c1);
    assertEquals(c1, c2);
}
 
Example #4
Source File: MeterPlotTest.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Serialize an instance, restore it, and check for equality.
 */
@Test
public void testSerialization1() {
    MeterPlot p1 = new MeterPlot(null);
    p1.setDialBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red,
            3.0f, 4.0f, Color.blue));
    p1.setDialOutlinePaint(new GradientPaint(4.0f, 3.0f, Color.red,
            2.0f, 1.0f, Color.blue));
    p1.setNeedlePaint(new GradientPaint(1.0f, 2.0f, Color.red,
            3.0f, 4.0f, Color.blue));
    p1.setTickLabelPaint(new GradientPaint(1.0f, 2.0f, Color.red,
            3.0f, 4.0f, Color.blue));
    p1.setTickPaint(new GradientPaint(1.0f, 2.0f, Color.red,
            3.0f, 4.0f, Color.blue));
    MeterPlot p2 = (MeterPlot) TestUtilities.serialised(p1);
    assertEquals(p1, p2);
}
 
Example #5
Source File: SlidingGanttCategoryDatasetTest.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Serialize an instance, restore it, and check for equality.
 */
@Test
public void testSerialization() {
    TaskSeries s1 = new TaskSeries("Series");
    s1.add(new Task("Task 1", new Date(0L), new Date(1L)));
    TaskSeriesCollection u1 = new TaskSeriesCollection();
    u1.add(s1);
    SlidingGanttCategoryDataset d1 = new SlidingGanttCategoryDataset(
            u1, 0, 5);
    SlidingGanttCategoryDataset d2 = (SlidingGanttCategoryDataset) 
            TestUtilities.serialised(d1);
    assertEquals(d1, d2);

    // basic check for independence
    s1.add(new Task("Task 2", new Date(10L), new Date(11L)));
    assertFalse(d1.equals(d2));
    TaskSeriesCollection u2
            = (TaskSeriesCollection) d2.getUnderlyingDataset();
    TaskSeries s2 = u2.getSeries("Series");
    s2.add(new Task("Task 2", new Date(10L), new Date(11L)));
    assertTrue(d1.equals(d2));
}
 
Example #6
Source File: SlidingCategoryDatasetTest.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Serialize an instance, restore it, and check for equality.
 */
@Test
public void testSerialization() {
    DefaultCategoryDataset u1 = new DefaultCategoryDataset();
    u1.addValue(1.0, "R1", "C1");
    u1.addValue(2.0, "R1", "C2");
    SlidingCategoryDataset d1 = new SlidingCategoryDataset(u1, 0, 5);
    SlidingCategoryDataset d2 = (SlidingCategoryDataset) 
            TestUtilities.serialised(d1);
    assertEquals(d1, d2);

    // basic check for independence
    u1.addValue(3.0, "R1", "C3");
    assertFalse(d1.equals(d2));
    DefaultCategoryDataset u2
            = (DefaultCategoryDataset) d2.getUnderlyingDataset();
    u2.addValue(3.0, "R1", "C3");
    assertTrue(d1.equals(d2));
}
 
Example #7
Source File: MinuteTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Serialize an instance, restore it, and check for equality.
 */
@Test
public void testSerialization() {
    Minute m1 = new Minute();
    Minute m2 = (Minute) TestUtilities.serialised(m1);
    assertEquals(m1, m2);
}
 
Example #8
Source File: ColorBarTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Serialize an instance, restore it, and check for equality.
 */
@Test
public void testSerialization() {
    ColorBar a1 = new ColorBar("Test Axis");
    ColorBar a2 = (ColorBar) TestUtilities.serialised(a1);
    assertEquals(a1, a2);
}
 
Example #9
Source File: MeterIntervalTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Serialize an instance, restore it, and check for equality.
 */
@Test
public void testSerialization() {
    MeterInterval m1 = new MeterInterval("X", new Range(1.0, 2.0));
    MeterInterval m2 = (MeterInterval) TestUtilities.serialised(m1);
    assertEquals(m1, m2);
}
 
Example #10
Source File: MiddlePinNeedleTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Serialize an instance, restore it, and check for equality.
 */
@Test
public void testSerialization() {
    MiddlePinNeedle n1 = new MiddlePinNeedle();
    MiddlePinNeedle n2 = (MiddlePinNeedle) TestUtilities.serialised(n1);
    assertTrue(n1.equals(n2));
}
 
Example #11
Source File: IntervalBarRendererTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Serialize an instance, restore it, and check for equality.
 */
@Test
public void testSerialization() {
    IntervalBarRenderer r1 = new IntervalBarRenderer();
    IntervalBarRenderer r2 = (IntervalBarRenderer) TestUtilities.serialised(r1);
    assertEquals(r1, r2);
}
 
Example #12
Source File: BlockBorderTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Serialize an instance, restore it, and check for equality.
 */
@Test
public void testSerialization() {
    BlockBorder b1 = new BlockBorder(new RectangleInsets(1.0, 2.0, 3.0,
            4.0), new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f,
            Color.yellow));
    BlockBorder b2 = (BlockBorder) TestUtilities.serialised(b1);
    assertEquals(b1, b2);
}
 
Example #13
Source File: WaterfallBarRendererTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Serialize an instance, restore it, and check for equality.
 */
@Test
public void testSerialization() {
    WaterfallBarRenderer r1 = new WaterfallBarRenderer();
    WaterfallBarRenderer r2 = (WaterfallBarRenderer) 
            TestUtilities.serialised(r1);
    assertEquals(r1, r2);
}
 
Example #14
Source File: QuarterDateFormatTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Serialize an instance, restore it, and check for equality.
 */
@Test
public void testSerialization() {
    QuarterDateFormat qf1 = new QuarterDateFormat(TimeZone.getTimeZone(
            "GMT"), new String[] {"1", "2", "3", "4"});
    QuarterDateFormat qf2 = (QuarterDateFormat) TestUtilities.serialised(qf1);
    assertEquals(qf1, qf2);
}
 
Example #15
Source File: StackedBarRenderer3DTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Serialize an instance, restore it, and check for equality.
 */
@Test
public void testSerialization() {
    StackedBarRenderer3D r1 = new StackedBarRenderer3D();
    StackedBarRenderer3D r2 = (StackedBarRenderer3D) 
            TestUtilities.serialised(r1);
    assertEquals(r1, r2);
}
 
Example #16
Source File: XYBoxAnnotationTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {
    XYBoxAnnotation a1 = new XYBoxAnnotation(1.0, 2.0, 3.0, 4.0,
            new BasicStroke(1.2f), Color.red, Color.blue);
    XYBoxAnnotation a2 = (XYBoxAnnotation) TestUtilities.serialised(a1);
    assertEquals(a1, a2);
}
 
Example #17
Source File: VectorSeriesTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Serialize an instance, restore it, and check for equality.
 */
@Test
public void testSerialization() {
    VectorSeries s1 = new VectorSeries("s1");
    s1.add(1.0, 0.5, 1.5, 2.0);
    VectorSeries s2 = (VectorSeries) TestUtilities.serialised(s1);
    assertEquals(s1, s2);
}
 
Example #18
Source File: AbstractBlockTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Serialize an instance, restore it, and check for equality.
 */
@Test
public void testSerialization() {
    EmptyBlock b1 = new EmptyBlock(1.0, 2.0);
    EmptyBlock b2 = (EmptyBlock) TestUtilities.serialised(b1);
    assertEquals(b1, b2);
}
 
Example #19
Source File: LayeredBarRendererTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Serialize an instance, restore it, and check for equality.
 */
@Test
public void testSerialization() {
    LayeredBarRenderer r1 = new LayeredBarRenderer();
    LayeredBarRenderer r2 = (LayeredBarRenderer) TestUtilities.serialised(r1);
    assertEquals(r1, r2);
}
 
Example #20
Source File: CategoryTableXYDatasetTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Serialize an instance, restore it, and check for equality.
 */
@Test
public void testSerialization() {
    CategoryTableXYDataset d1 = new CategoryTableXYDataset();
    d1.add(1.0, 1.1, "Series 1");
    d1.add(2.0, 2.2, "Series 1");
    CategoryTableXYDataset d2 = (CategoryTableXYDataset) 
            TestUtilities.serialised(d1);
    assertEquals(d1, d2);
}
 
Example #21
Source File: ArrowNeedleTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Serialize an instance, restore it, and check for equality.
 */
@Test
public void testSerialization() {
    ArrowNeedle n1 = new ArrowNeedle(false);
    ArrowNeedle n2 = (ArrowNeedle) TestUtilities.serialised(n1);
    assertTrue(n1.equals(n2));
}
 
Example #22
Source File: LineAndShapeRendererTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Serialize an instance, restore it, and check for equality.
 */
@Test
public void testSerialization() {
    LineAndShapeRenderer r1 = new LineAndShapeRenderer();
    LineAndShapeRenderer r2 = (LineAndShapeRenderer) 
            TestUtilities.serialised(r1);
    assertEquals(r1, r2);
}
 
Example #23
Source File: VectorRendererTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Serialize an instance, restore it, and check for equality.
 */
@Test
public void testSerialization() {
    VectorRenderer r1 = new VectorRenderer();
    VectorRenderer r2 = (VectorRenderer) TestUtilities.serialised(r1);
    assertEquals(r1, r2);
}
 
Example #24
Source File: DefaultKeyedValues2DDatasetTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {
    DefaultKeyedValues2DDataset d1 = new DefaultKeyedValues2DDataset();
    d1.addValue(new Double(234.2), "Row1", "Col1");
    d1.addValue(null, "Row1", "Col2");
    d1.addValue(new Double(345.9), "Row2", "Col1");
    d1.addValue(new Double(452.7), "Row2", "Col2");

    DefaultKeyedValues2DDataset d2 = (DefaultKeyedValues2DDataset) 
            TestUtilities.serialised(d1);
    assertEquals(d1, d2);
}
 
Example #25
Source File: XYAreaRenderer2Test.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Serialize an instance, restore it, and check for equality.
 */
@Test
public void testSerialization() {
    XYAreaRenderer2 r1 = new XYAreaRenderer2();
    XYAreaRenderer2 r2 = (XYAreaRenderer2) TestUtilities.serialised(r1);
    assertEquals(r1, r2);
}
 
Example #26
Source File: ComparableObjectSeriesTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Serialize an instance, restore it, and check for equality.
 */
@Test
public void testSerialization() {
    MyComparableObjectSeries s1 = new MyComparableObjectSeries("A");
    s1.add(new Integer(1), "ABC");
    MyComparableObjectSeries s2 = (MyComparableObjectSeries) 
            TestUtilities.serialised(s1);
    assertEquals(s1, s2);
}
 
Example #27
Source File: CategoryAnchorTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Serialize an instance, restore it, and check for equality.
 */
@Test
public void testSerialization() {
    CategoryAnchor a1 = CategoryAnchor.MIDDLE;
    CategoryAnchor a2 = (CategoryAnchor) TestUtilities.serialised(a1);
    assertEquals(a1, a2);
    assertTrue(a1 == a2);
}
 
Example #28
Source File: ContourPlotTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Serialize an instance, restore it, and check for equality.
 */
@Test
public void testSerialization() {
    ContourPlot p1 = new ContourPlot(null, null, null, null);
    ContourPlot p2 = (ContourPlot) TestUtilities.serialised(p1);
    assertEquals(p1, p2);
}
 
Example #29
Source File: XYLineAndShapeRendererTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Serialize an instance, restore it, and check for equality.
 */
@Test
public void testSerialization() {
    XYLineAndShapeRenderer r1 = new XYLineAndShapeRenderer();
    XYLineAndShapeRenderer r2 = (XYLineAndShapeRenderer) 
            TestUtilities.serialised(r1);
    assertEquals(r1, r2);
}
 
Example #30
Source File: YIntervalDataItemTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Serialize an instance, restore it, and check for equality.
 */
@Test
public void testSerialization() {
    YIntervalDataItem item1 = new YIntervalDataItem(1.0, 2.0, 1.5, 2.5);
    YIntervalDataItem item2 = (YIntervalDataItem) 
            TestUtilities.serialised(item1);
    assertEquals(item1, item2);
}