dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #01206
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 353: Fixed error in weeklyperiod test
------------------------------------------------------------
revno: 353
committer: Bob Jolliffe <bobjolliffe@xxxxxxxxx
branch nick: dhis2
timestamp: Wed 2009-06-03 10:00:20 +0100
message:
Fixed error in weeklyperiod test
modified:
dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/WeeklyPeriodTypeTest.java
=== modified file 'dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/WeeklyPeriodTypeTest.java'
--- dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/WeeklyPeriodTypeTest.java 2009-05-28 11:18:43 +0000
+++ dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/WeeklyPeriodTypeTest.java 2009-06-03 09:00:20 +0000
@@ -38,53 +38,56 @@
* @author Bob Jolliffe
* @version $Id$
*/
-public class WeeklyPeriodTypeTest
-{
- /**
- * Test method for
- * {@link org.hisp.dhis.period.WeeklyPeriodType#generatePeriods(org.hisp.dhis.period.Period)}.
- */
- @Test
- public void testGeneratePeriods()
- {
- // get calendar of default locale
- Calendar testCal = Calendar.getInstance();
- WeeklyPeriodType wpt = new WeeklyPeriodType();
- for ( int year = 1990; year < 2020; year++ )
- {
- for ( int day = -7; day < 7; day++ )
- {
- testCal.set( year, 0, 1 ); // 1st day of year
- testCal.add( Calendar.DATE, day );
- Period p1 = wpt.createPeriod( testCal.getTime() );
- List<Period> generatedPeriods = wpt.generatePeriods( p1 );
- assertTrue( "Period " + p1 + " in generated set", generatedPeriods.contains( p1 ) );
- }
- }
- }
-
- /**
- * Test method for
- * {@link org.hisp.dhis.period.WeeklyPeriodType#createPeriod(Calendar)}.
- */
- @Test
- @SuppressWarnings( "deprecation" )
- public void testCreatePeriod()
- {
- Calendar testCal = Calendar.getInstance();
- Calendar startCal = Calendar.getInstance();
- Calendar endCal = Calendar.getInstance();
-
- // arbitrary instance - should increase coverage
- testCal.set( 2009, 4, 27 ); // Wednesday
- WeeklyPeriodType wpt = new WeeklyPeriodType();
-
- assertFalse( startCal.after( testCal ) );
- assertFalse( endCal.before( testCal ) );
- Period p = wpt.createPeriod( testCal.getTime() );
- startCal.set( Calendar.DAY_OF_MONTH, p.getStartDate().getDate() );
- assertTrue( startCal.get( Calendar.DAY_OF_WEEK ) == Calendar.MONDAY );
- endCal.set( Calendar.DAY_OF_MONTH, p.getEndDate().getDate() );
- assertTrue( endCal.get( Calendar.DAY_OF_WEEK ) == Calendar.SUNDAY );
- }
+public class WeeklyPeriodTypeTest {
+
+
+ /**
+ * Test method for {@link org.hisp.dhis.period.WeeklyPeriodType#generatePeriods(org.hisp.dhis.period.Period)}.
+ */
+ @Test
+ public void testGeneratePeriods() {
+ // get calendar of default locale
+ Calendar testCal = Calendar.getInstance();
+ WeeklyPeriodType wpt = new WeeklyPeriodType();
+ for (int year = 1990; year<2020; year++) {
+ for (int day=-7; day<7; day++)
+ {
+ testCal.set(year, 0, 1); // 1st day of year
+ testCal.add(Calendar.DATE, day);
+ // System.err.println("testing "+testCal.getTime());
+ Period p1 = wpt.createPeriod(testCal.getTime());
+ List<Period> generatedPeriods = wpt.generatePeriods(p1);
+ assertTrue("Period "+p1+" in generated set",generatedPeriods.contains(p1));
+ }
+ }
+
+ }
+
+ /**
+ * Test method for {@link org.hisp.dhis.period.WeeklyPeriodType#createPeriod(Calendar)}.
+ */
+ @Test
+ public void testCreatePeriod() {
+ Calendar testCal = Calendar.getInstance();
+ Calendar startCal = Calendar.getInstance();
+ Calendar endCal = Calendar.getInstance();
+
+ // arbitrary instance - should increase coverage
+ testCal.set(2009, 4, 27); // Wednesday
+ WeeklyPeriodType wpt = new WeeklyPeriodType();
+
+
+ Period p = wpt.createPeriod(testCal.getTime());
+ startCal.setTime(p.getStartDate());
+ endCal.setTime(p.getEndDate());
+
+ assertFalse("start date after given date",startCal.after(testCal));
+ assertFalse("end date before given date", endCal.before(testCal));
+
+ assertTrue(startCal.get(Calendar.DAY_OF_WEEK)==Calendar.MONDAY);
+ assertTrue(endCal.get(Calendar.DAY_OF_WEEK)==Calendar.SUNDAY);
+
+
+ }
+
}
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription.