1 4 package org.oddjob.schedules.schedules; 5 6 import java.text.DateFormat ; 7 import java.text.ParseException ; 8 import java.text.SimpleDateFormat ; 9 import java.util.Date ; 10 11 import junit.framework.TestCase; 12 13 import org.oddjob.schedules.Interval; 14 import org.oddjob.schedules.ScheduleContext; 15 16 20 public class AfterScheduleTest extends TestCase { 21 22 static DateFormat checkFormat = new SimpleDateFormat ("dd-MMM-yy HH:mm:ss:SSS"); 23 static DateFormat inputFormat = new SimpleDateFormat ("dd-MMM-yy HH:mm"); 24 25 public void testAfterInterval() throws ParseException { 26 AfterSchedule after = new AfterSchedule(); 27 IntervalSchedule interval = new IntervalSchedule(); 28 interval.setInterval("00:10"); 29 after.addValueSchedule(interval); 30 31 Date from = inputFormat.parse("01-jan-00 12:00"); 32 Interval next = after.nextDue(new ScheduleContext(from)); 33 assertEquals("Expected start", 34 checkFormat.parse("01-jan-00 12:10:00:000"), 35 next.getFromDate()); 36 assertEquals("Expected end", 37 checkFormat.parse("01-jan-00 12:10:00:000"), 38 next.getToDate()); 39 } 40 } 41 | Popular Tags |