String invalid_day_of_month="2ndXXX,-8";
ScheduleExpression expr = new ScheduleExpression().dayOfMonth("1stsun,4,6,"+invalid_day_of_month).hour(23).minute(1).second(59).start(new Date(0));
boolean parseExceptionThrown = false;
try {
new EJBCronTrigger(expr);
} catch (ParseException e){
parseExceptionThrown=true;
}
assertTrue(parseExceptionThrown);
// invalid year
String invalid_years = "19876,87";
expr = new ScheduleExpression().year("1999,2012"+invalid_years).month(5).dayOfMonth(6).hour(2).minute(1).second(59).start(new Date(0));
parseExceptionThrown = false;
try {
new EJBCronTrigger(expr);
} catch (ParseException e){
parseExceptionThrown=true;
}
assertTrue(parseExceptionThrown);
// invalid month
String invalid_month = "XXX,14";
expr = new ScheduleExpression().month("1,2,4,sep,"+invalid_month).dayOfMonth(6).hour(2).minute(1).second(59).start(new Date(0));
parseExceptionThrown = false;
try {
new EJBCronTrigger(expr);
} catch (ParseException e){
parseExceptionThrown=true;
}
assertTrue(parseExceptionThrown);
// invalid days in week
String invalid_days_in_week = "8,WEEE";
expr = new ScheduleExpression().month(5).dayOfWeek("SUN,4,5,"+ invalid_days_in_week).hour(2).minute(1).second(59).start(new Date(0));
parseExceptionThrown = false;
try {
new EJBCronTrigger(expr);
} catch (ParseException e){
parseExceptionThrown=true;
}
assertTrue(parseExceptionThrown);
// invalid hours
String invalid_hours="15,-2";
expr = new ScheduleExpression().dayOfMonth(6).hour("1,5,9,18,22,"+invalid_hours).minute(1).second(59).start(new Date(0));
parseExceptionThrown = false;
try {
new EJBCronTrigger(expr);
} catch (ParseException e){
parseExceptionThrown=true;
}
assertTrue(parseExceptionThrown);
// invalid minute
String invalid_minutes="61,-4";
expr = new ScheduleExpression().dayOfMonth(6).hour(2).minute("1,45,58,"+invalid_minutes).second(59).start(new Date(0));
parseExceptionThrown = false;
try {
new EJBCronTrigger(expr);
} catch (ParseException e){
parseExceptionThrown=true;
}
assertTrue(parseExceptionThrown);
// invalid second
String invalid_seconds="61,-4";
expr = new ScheduleExpression().dayOfMonth(6).hour(2).minute(1).second("1,45,58,"+invalid_seconds).start(new Date(0));
parseExceptionThrown = false;
try {
new EJBCronTrigger(expr);
} catch (ParseException e){
parseExceptionThrown=true;
}
assertTrue(parseExceptionThrown);