Author: bleny Date: 2011-07-19 18:46:06 +0200 (Tue, 19 Jul 2011) New Revision: 2154 Url: http://nuiton.org/repositories/revision/nuiton-utils/2154 Log: removing junk code ; adding a regression test for PeriodDates (issue #1634) Modified: trunk/nuiton-utils/src/test/java/org/nuiton/util/PeriodDatesTest.java Modified: trunk/nuiton-utils/src/test/java/org/nuiton/util/PeriodDatesTest.java =================================================================== --- trunk/nuiton-utils/src/test/java/org/nuiton/util/PeriodDatesTest.java 2011-07-17 12:11:05 UTC (rev 2153) +++ trunk/nuiton-utils/src/test/java/org/nuiton/util/PeriodDatesTest.java 2011-07-19 16:46:06 UTC (rev 2154) @@ -32,6 +32,7 @@ import org.junit.Assert; import org.junit.Before; import org.junit.BeforeClass; +import org.junit.Ignore; import org.junit.Test; import java.text.DateFormat; @@ -39,6 +40,7 @@ import java.util.Date; import java.util.GregorianCalendar; import java.util.List; +import java.util.concurrent.TimeUnit; /** @author fdesbois */ public class PeriodDatesTest { @@ -46,46 +48,9 @@ /** Logger */ private static final Log log = LogFactory.getLog(PeriodDatesTest.class); - - @BeforeClass - public static void setUpClass() throws Exception { - } - - @AfterClass - public static void tearDownClass() throws Exception { - } - - @Before - public void setUp() { - } - - @After - public void tearDown() { - } - - /** Test of createMonthsPeriodFromToday method, of class PeriodDates. */ - //@Test - public void testCreateMonthsPeriodFromToday() { - log.info("createMonthsPeriodFromToday"); - } - - /** Test of getPattern method, of class PeriodDates. */ - //@Test - public void testGetPattern() { - log.info("getPattern"); - } - - /** Test of setPattern method, of class PeriodDates. */ - //@Test - public void testSetPattern() { - log.info("setPattern"); - } - /** Test of initDayOfMonthExtremities method, of class PeriodDates. */ @Test public void testInitDayOfMonthExtremities() { - log.info("initDayOfMonthExtremities"); - PeriodDates period = new PeriodDates(); period.setFromDate(DateUtil.createDate(9,8,7,23,12,2010)); period.setThruDate(DateUtil.createDate(6,5,4,26,12,2010)); @@ -101,41 +66,9 @@ Assert.assertEquals(lastDayOf2010.getTime(), period.getThruDate()); } - /** Test of setFromDate method, of class PeriodDates. */ - //@Test - public void testSetFromDate() { - log.info("setFromDate"); - } - - /** Test of getFromDate method, of class PeriodDates. */ - //@Test - public void testGetFromDate() { - log.info("getFromDate"); - } - - /** Test of getFromMonth method, of class PeriodDates. */ - //@Test - public void testGetFromMonth() { - log.info("getFromMonth"); - } - - /** Test of setThruDate method, of class PeriodDates. */ - //@Test - public void testSetThruDate() { - log.info("setThruDate"); - } - - /** Test of getThruDate method, of class PeriodDates. */ - //@Test - public void testGetThruDate() { - log.info("getThruDate"); - } - /** Test of getMonths method, of class PeriodDates. */ @Test public void testGetMonths() { - log.info("getMonths"); - // Prepare two calendars with time not equals to 0 Calendar cal1 = DateUtil.getDefaultCalendar(new Date()); cal1.set(Calendar.DAY_OF_MONTH, 3); @@ -167,64 +100,26 @@ } } - /** Test of getFormatedMonths method, of class PeriodDates. */ - //@Test - public void testGetFormatedMonths() { - log.info("getFormatedMonths"); - } + @Ignore("to be done as described in issue #1634") + @Test(timeout = 60 * 1000) + public void whatIfPeriodDatesIsNotInChronologicalOrder() { + Date january = DateUtil.createDate(1, 1, 2011); + Date december = DateUtil.createDate(1, 12, 2011); - /** Test of beforeEnd method, of class PeriodDates. */ - //@Test - public void testBeforeEnd_Calendar() { - log.info("beforeEnd"); - } + // trying to break PeriodDates by creating an anti-chronological period + try { + PeriodDates periodDates = new PeriodDates(december, january); + Assert.fail(); + } catch (IllegalArgumentException e) { + // as expected + } - /** Test of afterEnd method, of class PeriodDates. */ - //@Test - public void testAfterEnd_Calendar() { - log.info("afterEnd"); + // got ya! + PeriodDates periodDates = new PeriodDates(); + periodDates.setFromDate(december); + periodDates.setThruDate(january); + periodDates.getMonths(); // infinite loop ! } - /** Test of afterBegin method, of class PeriodDates. */ - //@Test - public void testAfterBegin_Calendar() { - log.info("afterBegin"); - } - /** Test of between method, of class PeriodDates. */ - //@Test - public void testBetween_Calendar() { - log.info("between"); - } - - /** Test of beforeEnd method, of class PeriodDates. */ - //@Test - public void testBeforeEnd_Date() { - log.info("beforeEnd"); - } - - /** Test of afterEnd method, of class PeriodDates. */ - //@Test - public void testAfterEnd_Date() { - log.info("afterEnd"); - } - - /** Test of afterBegin method, of class PeriodDates. */ - //@Test - public void testAfterBegin_Date() { - log.info("afterBegin"); - } - - /** Test of between method, of class PeriodDates. */ - //@Test - public void testBetween_Date() { - log.info("between"); - } - - /** Test of toString method, of class PeriodDates. */ - //@Test - public void testToString() { - log.info("toString"); - } - }
participants (1)
-
bleny@users.nuiton.org