1 /*
2 Bloof - visualize the evolution of your software project
3 Copyright ( C ) 2003 Lukasz Pekacki <lukasz@pekacki.de>
4 http://bloof.sf.net/
5
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License along with
15 this program; if not, write to the Free Software Foundation, Inc.,
16 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
18 $RCSfile: TimeIntervalTest.java,v $
19 Created on $Date: 2003/05/31 01:25:42 $
20 */
21 package net.sf.bloof.test.metrics;
22
23 import net.sf.bloof.metrics.TimeInterval;
24
25 import java.util.Calendar;
26 import java.util.Date;
27
28 import junit.framework.TestCase;
29
30 /***
31 *
32 * @author Lukasz Pekacki <pekacki@users.sourceforge.net>
33 * @version $Id: TimeIntervalTest.java,v 1.3 2003/05/31 01:25:42 pekacki Exp $
34 */
35 public class TimeIntervalTest extends TestCase {
36 /***
37 * Usual interval of one year
38 */
39 public void testNormalTimeInterval( ) {
40 Calendar cal = Calendar.getInstance( );
41 Date from = cal.getTime( );
42 cal.add( Calendar.DAY_OF_YEAR, 1 );
43 Date to = cal.getTime( );
44 TimeInterval timeInter = new TimeInterval( from,to );
45 assertEquals( from, timeInter.getFrom( ) );
46 assertEquals( to, timeInter.getTo( ) );
47
48 }
49
50 /***
51 * Usual single Date zero Interval
52 */
53 public void testZeroInterval( ) {
54 Calendar cal = Calendar.getInstance( );
55 Date from = cal.getTime( );
56 Date to = cal.getTime( );
57 TimeInterval timeInter = new TimeInterval( from,to );
58 assertEquals( from, timeInter.getFrom( ) );
59 assertEquals( to, timeInter.getTo( ) );
60 }
61
62 /***
63 * Handling of wrong Date
64 */
65 public void testWrongInterval( ) {
66 Calendar cal = Calendar.getInstance( );
67 Date from = cal.getTime( );
68 cal.add( Calendar.DAY_OF_YEAR, -1 );
69 Date to = cal.getTime( );
70 try {
71 TimeInterval timeInter = new TimeInterval( from,to );
72 if ( timeInter == null ) {}
73 fail( "Exception should have happend."+"from:" + from + " - to:" + to + "; are illegal Arguments!" );
74 } catch ( IllegalArgumentException ia ) {
75 // do nothing
76 }
77 }
78
79 }
This page was automatically generated by Maven