1 /* ====================================== 2 * JFreeChart : a free Java chart library 3 * ====================================== 4 * 5 * Project Info: http://www.jfree.org/jfreechart/index.html 6 * Project Lead: David Gilbert (david.gilbert@object-refinery.com); 7 * 8 * (C) Copyright 2000-2003, by Object Refinery Limited and Contributors. 9 * 10 * This library is free software; you can redistribute it and/or modify it under the terms 11 * of the GNU Lesser General Public License as published by the Free Software Foundation; 12 * either version 2.1 of the License, or (at your option) any later version. 13 * 14 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 15 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 * See the GNU Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public License along with this 19 * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, 20 * Boston, MA 02111-1307, USA. 21 * 22 * ------------------------------------------ 23 * IntervalCategoryToolTipGeneratorTests.java 24 * ------------------------------------------ 25 * (C) Copyright 2003 by Object Refinery Limited and Contributors. 26 * 27 * Original Author: David Gilbert (for Object Refinery Limited); 28 * Contributor(s): -; 29 * 30 * $Id: IntervalCategoryToolTipGeneratorTests.java,v 1.1 2003/07/24 10:33:28 mungady Exp $ 31 * 32 * Changes 33 * ------- 34 * 21-Mar-2003 : Version 1 (DG); 35 * 36 */ 37 38 package org.jfree.chart.labels.junit; 39 40 import java.io.ByteArrayInputStream; 41 import java.io.ByteArrayOutputStream; 42 import java.io.ObjectInput; 43 import java.io.ObjectInputStream; 44 import java.io.ObjectOutput; 45 import java.io.ObjectOutputStream; 46 import java.text.DateFormat; 47 48 import junit.framework.Test; 49 import junit.framework.TestCase; 50 import junit.framework.TestSuite; 51 52 import org.jfree.chart.labels.IntervalCategoryItemLabelGenerator; 53 54 /** 55 * Tests for the {@link StandardPieToolTipGenerator} class. 56 * 57 * @author David Gilbert 58 */ 59 public class IntervalCategoryToolTipGeneratorTests extends TestCase { 60 61 /** 62 * Returns the tests as a test suite. 63 * 64 * @return the test suite. 65 */ 66 public static Test suite() { 67 return new TestSuite(IntervalCategoryToolTipGeneratorTests.class); 68 } 69 70 /** 71 * Constructs a new set of tests. 72 * 73 * @param name the name of the tests. 74 */ 75 public IntervalCategoryToolTipGeneratorTests(String name) { 76 super(name); 77 } 78 79 /** 80 * Serialize an instance, restore it, and check for equality. 81 */ 82 public void testSerialization() { 83 84 IntervalCategoryItemLabelGenerator g1 85 = new IntervalCategoryItemLabelGenerator(DateFormat.getInstance()); 86 IntervalCategoryItemLabelGenerator g2 = null; 87 88 try { 89 ByteArrayOutputStream buffer = new ByteArrayOutputStream(); 90 ObjectOutput out = new ObjectOutputStream(buffer); 91 out.writeObject(g1); 92 out.close(); 93 94 ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray())); 95 g2 = (IntervalCategoryItemLabelGenerator) in.readObject(); 96 in.close(); 97 } 98 catch (Exception e) { 99 System.out.println(e.toString()); 100 } 101 assertEquals(g1, g2); 102 103 } 104 105 } 106