KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfree > data > junit > TaskSeriesCollectionTests


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  * TaskSeriesCollectionTests.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: TaskSeriesCollectionTests.java,v 1.5 2003/09/17 11:37:58 mungady Exp $
31  *
32  * Changes
33  * -------
34  * 10-Apr-2003 : Version 1 (DG);
35  * 04-Sep-2003 : Added test for bug report 800324 (DG);
36  *
37  */

38
39 package org.jfree.data.junit;
40
41 import java.util.Date JavaDoc;
42
43 import junit.framework.Test;
44 import junit.framework.TestCase;
45 import junit.framework.TestSuite;
46
47 import org.jfree.data.gantt.Task;
48 import org.jfree.data.gantt.TaskSeries;
49 import org.jfree.data.gantt.TaskSeriesCollection;
50 import org.jfree.data.time.SimpleTimePeriod;
51
52 /**
53  * Tests for the {@link TaskSeriesCollection} class.
54  *
55  * @author David Gilbert
56  */

57 public class TaskSeriesCollectionTests extends TestCase {
58
59     /**
60      * Returns the tests as a test suite.
61      *
62      * @return the test suite.
63      */

64     public static Test suite() {
65         return new TestSuite(TaskSeriesCollectionTests.class);
66     }
67
68     /**
69      * Constructs a new set of tests.
70      *
71      * @param name the name of the tests.
72      */

73     public TaskSeriesCollectionTests(String JavaDoc name) {
74         super(name);
75     }
76
77     /**
78      * A test for bug report 697153.
79      */

80     public void test697153() {
81
82         TaskSeries s1 = new TaskSeries("S1");
83         s1.add(new Task("Task 1", new SimpleTimePeriod(new Date JavaDoc(), new Date JavaDoc())));
84         s1.add(new Task("Task 2", new SimpleTimePeriod(new Date JavaDoc(), new Date JavaDoc())));
85         s1.add(new Task("Task 3", new SimpleTimePeriod(new Date JavaDoc(), new Date JavaDoc())));
86
87         TaskSeries s2 = new TaskSeries("S2");
88         s2.add(new Task("Task 2", new SimpleTimePeriod(new Date JavaDoc(), new Date JavaDoc())));
89         s2.add(new Task("Task 3", new SimpleTimePeriod(new Date JavaDoc(), new Date JavaDoc())));
90         s2.add(new Task("Task 4", new SimpleTimePeriod(new Date JavaDoc(), new Date JavaDoc())));
91
92         TaskSeriesCollection tsc = new TaskSeriesCollection();
93         tsc.add(s1);
94         tsc.add(s2);
95
96         s1.removeAll();
97
98         int taskCount = tsc.getColumnCount();
99
100         assertEquals(3, taskCount);
101
102     }
103
104     /**
105      * A test for bug report 800324.
106      */

107     public void test800324() {
108         TaskSeries s1 = new TaskSeries("S1");
109         s1.add(new Task("Task 1", new SimpleTimePeriod(new Date JavaDoc(), new Date JavaDoc())));
110         s1.add(new Task("Task 2", new SimpleTimePeriod(new Date JavaDoc(), new Date JavaDoc())));
111         s1.add(new Task("Task 3", new SimpleTimePeriod(new Date JavaDoc(), new Date JavaDoc())));
112                 
113         TaskSeriesCollection tsc = new TaskSeriesCollection();
114         tsc.add(s1);
115
116         // these methods should return null since the column number is too high...
117
Number JavaDoc start = tsc.getStartValue(0, 3);
118         assertEquals(start, null);
119         Number JavaDoc end = tsc.getEndValue(0, 3);
120         assertEquals(end, null);
121
122         int count = tsc.getSubIntervalCount(0, 3);
123         assertEquals(0, count);
124         
125     }
126 }
127
Popular Tags