git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1078821 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Timothy A. Bish 2011-03-07 15:55:08 +00:00
parent 1c1aa17311
commit 74a45502e2
1 changed files with 49 additions and 23 deletions

View File

@ -52,6 +52,32 @@ public class CronParserTest {
assertEquals(2010,result.get(Calendar.YEAR));
}
@Test
public void testgetNextTimeCase1() throws MessageFormatException {
// using an absolute date so that result will be absolute - Monday 15 Nov 2010
Calendar current = Calendar.getInstance();
current.set(2011, Calendar.MARCH, 7, 9, 15, 30);
System.out.println("start:" + current.getTime());
String test = "50 20 * * 5";
long next = CronParser.getNextScheduledTime(test, current.getTimeInMillis());
Calendar result = Calendar.getInstance();
result.setTimeInMillis(next);
System.out.println("next:" + result.getTime());
assertEquals(30,result.get(Calendar.SECOND));
assertEquals(50,result.get(Calendar.MINUTE));
assertEquals(20,result.get(Calendar.HOUR_OF_DAY));
// expecting Friday 11th
assertEquals(11,result.get(Calendar.DAY_OF_MONTH));
assertEquals(Calendar.FRIDAY,result.get(Calendar.DAY_OF_WEEK));
assertEquals(Calendar.MARCH,result.get(Calendar.MONTH));
assertEquals(2011,result.get(Calendar.YEAR));
}
@Test
public void testgetNextTimeMonth() throws MessageFormatException {