001: /* ===========================================================
002: * JFreeChart : a free chart library for the Java(tm) platform
003: * ===========================================================
004: *
005: * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
006: *
007: * Project Info: http://www.jfree.org/jfreechart/index.html
008: *
009: * This library is free software; you can redistribute it and/or modify it
010: * under the terms of the GNU Lesser General Public License as published by
011: * the Free Software Foundation; either version 2.1 of the License, or
012: * (at your option) any later version.
013: *
014: * This library is distributed in the hope that it will be useful, but
015: * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
016: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
017: * License for more details.
018: *
019: * You should have received a copy of the GNU Lesser General Public
020: * License along with this library; if not, write to the Free Software
021: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
022: * USA.
023: *
024: * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
025: * in the United States and other countries.]
026: *
027: * ---------------
028: * TitleTests.java
029: * ---------------
030: * (C) Copyright 2004, by Object Refinery Limited and Contributors.
031: *
032: * Original Author: David Gilbert (for Object Refinery Limited);
033: * Contributor(s): -;
034: *
035: * $Id: TitleTests.java,v 1.1.2.1 2006/10/03 15:41:29 mungady Exp $
036: *
037: * Changes
038: * -------
039: * 17-Feb-2004 : Version 1 (DG);
040: *
041: */
042:
043: package org.jfree.chart.title.junit;
044:
045: import junit.framework.Test;
046: import junit.framework.TestCase;
047: import junit.framework.TestSuite;
048:
049: import org.jfree.chart.title.TextTitle;
050: import org.jfree.chart.title.Title;
051: import org.jfree.ui.HorizontalAlignment;
052: import org.jfree.ui.RectangleEdge;
053: import org.jfree.ui.VerticalAlignment;
054:
055: /**
056: * Tests for the abstract {@link Title} class.
057: */
058: public class TitleTests extends TestCase {
059:
060: /**
061: * Returns the tests as a test suite.
062: *
063: * @return The test suite.
064: */
065: public static Test suite() {
066: return new TestSuite(TitleTests.class);
067: }
068:
069: /**
070: * Constructs a new set of tests.
071: *
072: * @param name the name of the tests.
073: */
074: public TitleTests(String name) {
075: super (name);
076: }
077:
078: /**
079: * Some checks for the equals() method.
080: */
081: public void testEquals() {
082:
083: // use the TextTitle class because it is a concrete subclass
084: Title t1 = new TextTitle();
085: Title t2 = new TextTitle();
086: assertEquals(t1, t2);
087:
088: t1.setPosition(RectangleEdge.LEFT);
089: assertFalse(t1.equals(t2));
090: t2.setPosition(RectangleEdge.LEFT);
091: assertTrue(t1.equals(t2));
092:
093: t1.setHorizontalAlignment(HorizontalAlignment.RIGHT);
094: assertFalse(t1.equals(t2));
095: t2.setHorizontalAlignment(HorizontalAlignment.RIGHT);
096: assertTrue(t1.equals(t2));
097:
098: t1.setVerticalAlignment(VerticalAlignment.BOTTOM);
099: assertFalse(t1.equals(t2));
100: t2.setVerticalAlignment(VerticalAlignment.BOTTOM);
101: assertTrue(t1.equals(t2));
102:
103: }
104:
105: /**
106: * Two objects that are equal are required to return the same hashCode.
107: */
108: public void testHashcode() {
109: TextTitle t1 = new TextTitle();
110: TextTitle t2 = new TextTitle();
111: assertTrue(t1.equals(t2));
112: int h1 = t1.hashCode();
113: int h2 = t2.hashCode();
114: assertEquals(h1, h2);
115: }
116:
117: }
|