~ubuntu-branches/ubuntu/lucid/libjcommon-java/lucid

« back to all changes in this revision

Viewing changes to source/org/jfree/util/junit/ObjectTableTests.java

  • Committer: Bazaar Package Importer
  • Author(s): Wolfgang Baer
  • Date: 2006-02-09 15:58:13 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060209155813-fzi9zwh2rzedbllq
Tags: 1.0.0-1
* New stable upstream release (closes: #328574)
* Move to main - build with kaffe
* Use cdbs build system - added cdbs build-dependency
* Move package to pkg-java-maintainers for comaintenance, 
  added Christian Bayle and myself as uploaders
* Removed unneeded README.Debian
* Added README.Debian-source how the upstream tarball was cleaned
* Move big documentation in an own -doc package
* Register javadoc api with doc-base
* Standards-Version 3.6.2 (no changes)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ========================================================================
 
2
 * JCommon : a free general purpose class library for the Java(tm) platform
 
3
 * ========================================================================
 
4
 *
 
5
 * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
 
6
 * 
 
7
 * Project Info:  http://www.jfree.org/jcommon/index.html
 
8
 *
 
9
 * This library is free software; you can redistribute it and/or modify it 
 
10
 * under the terms of the GNU Lesser General Public License as published by 
 
11
 * the Free Software Foundation; either version 2.1 of the License, or 
 
12
 * (at your option) any later version.
 
13
 *
 
14
 * This library is distributed in the hope that it will be useful, but 
 
15
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
 
16
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 
 
17
 * License for more details.
 
18
 *
 
19
 * You should have received a copy of the GNU Lesser General Public
 
20
 * License along with this library; if not, write to the Free Software
 
21
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
 
22
 * USA.  
 
23
 *
 
24
 * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 
 
25
 * in the United States and other countries.]
 
26
 * 
 
27
 * --------------------
 
28
 * ObjectTableTests.java
 
29
 * --------------------
 
30
 * (C) Copyright 2003-2005, by Object Refinery Limited and Contributors.
 
31
 *
 
32
 * Original Author:  David Gilbert (for Object Refinery Limited);
 
33
 * Contributor(s):   -;
 
34
 *
 
35
 * $Id: ObjectTableTests.java,v 1.5 2005/10/18 13:25:14 mungady Exp $
 
36
 *
 
37
 * Changes
 
38
 * -------
 
39
 * 29-Apr-2003 : Version 1 (DG);
 
40
 *
 
41
 */
 
42
 
 
43
package org.jfree.util.junit;
 
44
 
 
45
import java.awt.Color;
 
46
 
 
47
import junit.framework.Test;
 
48
import junit.framework.TestCase;
 
49
import junit.framework.TestSuite;
 
50
 
 
51
import org.jfree.util.ObjectTable;
 
52
 
 
53
/**
 
54
 * Tests for the {@link ObjectTable} class.
 
55
 */
 
56
public class ObjectTableTests extends TestCase {
 
57
 
 
58
    /**
 
59
     * Basic object table.
 
60
     */
 
61
    public class TObjectTable extends ObjectTable {
 
62
 
 
63
        /**
 
64
         * Constructor.
 
65
         */
 
66
        public TObjectTable() {
 
67
            super();
 
68
        }
 
69
 
 
70
        /**
 
71
         * Returns the object from a particular cell in the table.
 
72
         * Returns null, if there is no object at the given position.
 
73
         *
 
74
         * @param row  the row index (zero-based).
 
75
         * @param column  the column index (zero-based).
 
76
         *
 
77
         * @return The object.
 
78
         */
 
79
        public Object getObject(final int row, final int column) {
 
80
            return super.getObject(row, column);
 
81
        }
 
82
 
 
83
        /**
 
84
         * Sets the object for a cell in the table.  The table is expanded if necessary.
 
85
         *
 
86
         * @param row  the row index (zero-based).
 
87
         * @param column  the column index (zero-based).
 
88
         * @param object  the object.
 
89
         */
 
90
        public void setObject(final int row, final int column, final Object object) {
 
91
            super.setObject(row, column, object);
 
92
        }
 
93
    }
 
94
 
 
95
    /**
 
96
     * Returns the tests as a test suite.
 
97
     *
 
98
     * @return The test suite.
 
99
     */
 
100
    public static Test suite() {
 
101
        return new TestSuite(ObjectTableTests.class);
 
102
    }
 
103
 
 
104
    /**
 
105
     * Constructs a new set of tests.
 
106
     *
 
107
     * @param name  the name of the tests.
 
108
     */
 
109
    public ObjectTableTests(final String name) {
 
110
        super(name);
 
111
    }
 
112
 
 
113
    /**
 
114
     * When an ObjectTable is created, it should be empty and return null for all lookups.
 
115
     */
 
116
    public void testCreate() {
 
117
 
 
118
        final TObjectTable t = new TObjectTable();
 
119
 
 
120
        // the new table should have zero rows and zero columns...
 
121
        assertEquals(t.getColumnCount(), 0);
 
122
        assertEquals(t.getRowCount(), 0);
 
123
 
 
124
        // ...and should return null for any lookup
 
125
        assertNull(t.getObject(0, 0));
 
126
        assertNull(t.getObject(12, 12));
 
127
 
 
128
    }
 
129
 
 
130
    /**
 
131
     * When an object is added to the table outside the current bounds, the table
 
132
     * should resize automatically.
 
133
     */
 
134
    public void testSetObject1() {
 
135
 
 
136
        final TObjectTable t = new TObjectTable();
 
137
        t.setObject(8, 5, Color.red);
 
138
        assertEquals(6, t.getColumnCount());
 
139
        assertEquals(9, t.getRowCount());
 
140
        assertNull(t.getObject(7, 4));
 
141
        assertEquals(Color.red, t.getObject(8, 5));
 
142
 
 
143
    }
 
144
 
 
145
}