use of javax.ejb.ScheduleExpression in project wildfly by wildfly.
the class CancelledTimerServiceBean method createTimer.
public TimerHandle createTimer() {
ScheduleExpression expression = new ScheduleExpression();
expression.second("*");
expression.minute("*");
expression.hour("*");
expression.dayOfMonth("*");
expression.year("*");
TimerConfig timerConfig = new TimerConfig();
timerConfig.setInfo(new String("info"));
return timerService.createCalendarTimer(expression, timerConfig).getHandle();
}
use of javax.ejb.ScheduleExpression in project wildfly by wildfly.
the class CalendarBasedTimeoutTestCase method testNextDayOfWeek.
private void testNextDayOfWeek(Date start) {
ScheduleExpression expression = new ScheduleExpression();
expression.dayOfWeek("6");
expression.hour("3");
expression.minute("21");
expression.second("50");
expression.start(start);
CalendarBasedTimeout calendarTimeout = new CalendarBasedTimeout(expression);
Calendar firstTimeout = calendarTimeout.getFirstTimeout();
Assert.assertNotNull(firstTimeout);
Assert.assertEquals(50, firstTimeout.get(Calendar.SECOND));
Assert.assertEquals(21, firstTimeout.get(Calendar.MINUTE));
Assert.assertEquals(3, firstTimeout.get(Calendar.HOUR_OF_DAY));
Assert.assertEquals(7, firstTimeout.get(Calendar.DAY_OF_WEEK));
Assert.assertEquals(29, firstTimeout.get(Calendar.DAY_OF_MONTH));
}
use of javax.ejb.ScheduleExpression in project wildfly by wildfly.
the class CalendarBasedTimeoutTestCase method testEveryMorningFiveFifteen.
//@Test
public void testEveryMorningFiveFifteen() {
ScheduleExpression everyMorningFiveFifteen = this.getTimezoneSpecificScheduleExpression();
everyMorningFiveFifteen.minute(15);
everyMorningFiveFifteen.hour(5);
CalendarBasedTimeout calendarTimeout = new CalendarBasedTimeout(everyMorningFiveFifteen);
Calendar firstTimeout = calendarTimeout.getFirstTimeout();
Assert.assertNotNull(timeZoneDisplayName, firstTimeout);
int minute = firstTimeout.get(Calendar.MINUTE);
int second = firstTimeout.get(Calendar.SECOND);
int hour = firstTimeout.get(Calendar.HOUR_OF_DAY);
int amOrPm = firstTimeout.get(Calendar.AM_PM);
Assert.assertEquals(timeZoneDisplayName, 0, second);
Assert.assertEquals(timeZoneDisplayName, 15, minute);
Assert.assertEquals(timeZoneDisplayName, 5, hour);
Assert.assertEquals(timeZoneDisplayName, Calendar.AM, amOrPm);
Calendar previousTimeout = firstTimeout;
for (int i = 1; i <= 370; i++) {
Calendar nextTimeout = calendarTimeout.getNextTimeout(previousTimeout);
Assert.assertNotNull(timeZoneDisplayName, nextTimeout);
Assert.assertNotNull(timeZoneDisplayName, nextTimeout.after(previousTimeout));
// logger.debug("First timeout was: " + firstTimeout.getTime() + " Previous timeout was: "
// + previousTimeout.getTime() + " Next timeout is " + nextTimeout.getTime());
Assert.assertEquals(timeZoneDisplayName, 0, nextTimeout.get(Calendar.SECOND));
Assert.assertEquals(timeZoneDisplayName, 15, nextTimeout.get(Calendar.MINUTE));
Assert.assertEquals(timeZoneDisplayName, 5, nextTimeout.get(Calendar.HOUR_OF_DAY));
Assert.assertEquals(timeZoneDisplayName, Calendar.AM, nextTimeout.get(Calendar.AM_PM));
previousTimeout = nextTimeout;
}
}
use of javax.ejb.ScheduleExpression in project wildfly by wildfly.
the class CalendarBasedTimeoutTestCase method testDayOverflow.
/**
* Check if the hour/minute/second is reseted correct if the day must be updated
*/
@Test
public void testDayOverflow() {
int year = 2016;
int month = Calendar.JANUARY;
int dayOfMonth = 14;
int hourOfDay = 9;
int minute = 56;
int second = 0;
Calendar start = new GregorianCalendar();
start.clear();
start.set(year, month, dayOfMonth, hourOfDay, minute, second);
ScheduleExpression expression = new ScheduleExpression().dayOfMonth("2-13").hour("3-9").minute("0/5").second("0").start(start.getTime());
CalendarBasedTimeout calendarTimeout = new CalendarBasedTimeout(expression);
Calendar firstTimeout = calendarTimeout.getFirstTimeout();
Assert.assertNotNull(firstTimeout);
Assert.assertEquals(year, firstTimeout.get(Calendar.YEAR));
Assert.assertEquals(1, firstTimeout.get(Calendar.MONTH));
Assert.assertEquals(2, firstTimeout.get(Calendar.DAY_OF_MONTH));
Assert.assertEquals(3, firstTimeout.get(Calendar.HOUR_OF_DAY));
Assert.assertEquals(0, firstTimeout.get(Calendar.MINUTE));
Assert.assertEquals(0, firstTimeout.get(Calendar.SECOND));
}
use of javax.ejb.ScheduleExpression in project wildfly by wildfly.
the class CalendarBasedTimeoutTestCase method testWFLY1468.
/**
* WFLY-1468
* Create a Timeout with a schedule start date in the past (day before) to ensure the time is set correctly.
* The schedule is on the first day of month to ensure that the calculated time must be moved to the next month.
*
* The test is run for each day of a whole year.
*/
@Test
public void testWFLY1468() {
ScheduleExpression schedule = new ScheduleExpression();
int year = 2013;
int month = Calendar.JUNE;
int dayOfMonth = 3;
int hourOfDay = 2;
int minutes = 0;
Calendar start = new GregorianCalendar(year, month, dayOfMonth, hourOfDay, minutes);
schedule.hour("0-12").month("*").dayOfMonth("3").minute("0/5").second("0").start(start.getTime());
CalendarBasedTimeout calendarTimeout = new CalendarBasedTimeout(schedule);
Calendar firstTimeout = calendarTimeout.getFirstTimeout();
// assert first timeout result
if (firstTimeout.get(Calendar.DAY_OF_MONTH) != 3 || firstTimeout.get(Calendar.HOUR_OF_DAY) != 2 || firstTimeout.get(Calendar.MINUTE) != 0 || firstTimeout.get(Calendar.SECOND) != 0) {
Assert.fail(firstTimeout.toString());
}
}
Aggregations