001    package org.hackystat.utilities.time.interval;
002    
003    import junit.framework.TestCase;
004    
005    import org.hackystat.utilities.time.period.Month;
006    
007    /**
008     * Tests month interval.
009     * 
010     * @author Hongbing Kou
011     * @version $Id: TestMonthInterval.java,v 1.1.1.1 2005/10/20 23:56:40 johnson Exp $
012     */
013    public class TestMonthInterval extends TestCase {
014      /**
015       * Tests the month interval. 
016       * 
017       * @throws Exception If error in test.
018       */
019      public void testMonthInterval() throws Exception {
020        MonthInterval interval = new MonthInterval("2003", "6", "2004", "0");
021    
022        assertFalse("Test interval type is daily", interval.isDailyInterval());
023        assertFalse("Test interval type is not weekly", interval.isWeeklyInterval());
024        assertTrue("Test interval type is not monthly", interval.isMonthlyInterval());
025    
026        assertEquals("Checking the from month", new Month(2003, 6), interval.getStartMonth());
027        assertEquals("Checking the to month", new Month(2004, 0), interval.getEndMonth());
028        assertEquals("Check the toString() for interval", "Month Interval : Jul-2003 ~ Jan-2004",
029                     interval.toString());    
030    
031        
032        interval = new MonthInterval("2004", "0", "2004", "0");    
033        assertEquals("Check the toString() for interval", "Month Interval : Jan-2004 ~ Jan-2004",
034                     interval.toString());    
035      }
036    }