* .
*/
@Test
public void testWillBlockSchedules() throws Exception {
Calendar trueBlockOutStartDate = new GregorianCalendar( 2013, Calendar.JANUARY, 7 );
IJobTrigger trueBlockOutTrigger =
new SimpleJobTrigger( trueBlockOutStartDate.getTime(), null, -1, TIME.WEEK.time / 1000 );
trueBlockOutTrigger.setDuration( duration );
Calendar falseBlockOutStartDate = new GregorianCalendar( 2013, Calendar.JANUARY, 9 );
IJobTrigger falseBlockOutTrigger =
new SimpleJobTrigger( falseBlockOutStartDate.getTime(), null, -1, TIME.WEEK.time / 1000 );
falseBlockOutTrigger.setDuration( duration );
IJobTrigger trueComplexBlockOutTrigger = new ComplexJobTrigger();
trueComplexBlockOutTrigger.setStartTime( trueBlockOutStartDate.getTime() );
trueComplexBlockOutTrigger.setCronString( "0 0 0 ? * 2 *" ); //$NON-NLS-1$
trueComplexBlockOutTrigger.setDuration( duration );
IJobTrigger falseComplexBlockOutTrigger = new ComplexJobTrigger();
falseComplexBlockOutTrigger.setStartTime( falseBlockOutStartDate.getTime() );
falseComplexBlockOutTrigger.setCronString( "0 0 0 ? * WED *" ); //$NON-NLS-1$
falseComplexBlockOutTrigger.setDuration( duration );
Calendar scheduleStartDate = new GregorianCalendar( 2013, Calendar.JANUARY, 7, 1, 0, 0 );
IJobTrigger scheduleTrigger = new SimpleJobTrigger( scheduleStartDate.getTime(), null, -1, TIME.WEEK.time / 1000 );
addJob( scheduleTrigger, "scheduleTrigger" ); //$NON-NLS-1$
assertEquals( 1, this.blockOutManager.willBlockSchedules( trueBlockOutTrigger ).size() );
assertEquals( 1, this.blockOutManager.willBlockSchedules( trueComplexBlockOutTrigger ).size() );
assertEquals( 0, this.blockOutManager.willBlockSchedules( falseBlockOutTrigger ).size() );
assertEquals( 0, this.blockOutManager.willBlockSchedules( falseComplexBlockOutTrigger ).size() );
IJobTrigger cronTrigger = new ComplexJobTrigger();
cronTrigger.setStartTime( scheduleStartDate.getTime() );
cronTrigger.setCronString( "0 0 1 ? * 2-3 *" ); //$NON-NLS-1$
addJob( cronTrigger, "cronTrigger" ); //$NON-NLS-1$
assertEquals( 2, this.blockOutManager.willBlockSchedules( trueBlockOutTrigger ).size() );
assertEquals( 2, this.blockOutManager.willBlockSchedules( trueComplexBlockOutTrigger ).size() );
assertEquals( 0, this.blockOutManager.willBlockSchedules( falseBlockOutTrigger ).size() );
assertEquals( 0, this.blockOutManager.willBlockSchedules( falseComplexBlockOutTrigger ).size() );
IJobTrigger complexJobTrigger1 = new ComplexJobTrigger( null, null, null, ComplexJobTrigger.MONDAY, 0 );
complexJobTrigger1.setStartTime( scheduleStartDate.getTime() );
addJob( complexJobTrigger1, "complexJobTrigger1" ); //$NON-NLS-1$
assertEquals( 3, this.blockOutManager.willBlockSchedules( trueBlockOutTrigger ).size() );
assertEquals( 3, this.blockOutManager.willBlockSchedules( trueComplexBlockOutTrigger ).size() );
assertEquals( 0, this.blockOutManager.willBlockSchedules( falseBlockOutTrigger ).size() );
assertEquals( 0, this.blockOutManager.willBlockSchedules( falseComplexBlockOutTrigger ).size() );
// Test non-standard interval
IJobTrigger complexJobTrigger2 = new ComplexJobTrigger( null, null, 1, null, 0 );
complexJobTrigger2.setStartTime( scheduleStartDate.getTime() );
addJob( complexJobTrigger2, "complexJobTrigger2" ); //$NON-NLS-1$
assertEquals( 4, this.blockOutManager.willBlockSchedules( trueBlockOutTrigger ).size() );
assertEquals( 4, this.blockOutManager.willBlockSchedules( trueComplexBlockOutTrigger ).size() );
assertEquals( 1, this.blockOutManager.willBlockSchedules( falseBlockOutTrigger ).size() );