Java 类org.quartz.impl.calendar.WeeklyCalendar 实例源码

项目:quartz-redis-jobstore    文件:StoreTriggerTest.java   
@Test
public void resumeTrigger() throws Exception {
    // create and store a job and trigger
    JobDetail job = getJobDetail();
    jobStore.storeJob(job, false);
    CronTriggerImpl trigger = getCronTrigger("trigger1", "group1", job.getKey());
    trigger.computeFirstFireTime(new WeeklyCalendar());
    jobStore.storeTrigger(trigger, false);

    // pause the trigger
    jobStore.pauseTrigger(trigger.getKey());
    assertEquals(Trigger.TriggerState.PAUSED, jobStore.getTriggerState(trigger.getKey()));

    // resume the trigger
    jobStore.resumeTrigger(trigger.getKey());
    // the trigger state should now be NORMAL
    assertEquals(Trigger.TriggerState.NORMAL, jobStore.getTriggerState(trigger.getKey()));

    // attempt to resume the trigger, again
    jobStore.resumeTrigger(trigger.getKey());
    // the trigger state should not have changed
    assertEquals(Trigger.TriggerState.NORMAL, jobStore.getTriggerState(trigger.getKey()));
}
项目:quartz-redis-jobstore    文件:StoreTriggerTest.java   
@Test
@SuppressWarnings("unchecked")
public void triggersFired() throws Exception {
    // store some jobs with triggers
    Map<JobDetail, Set<? extends Trigger>> jobsAndTriggers = getJobsAndTriggers(2, 2, 2, 2, "* * * * * ?");
    jobStore.storeCalendar("testCalendar", new WeeklyCalendar(), false, true);
    jobStore.storeJobsAndTriggers(jobsAndTriggers, false);

    List<OperableTrigger> acquiredTriggers = jobStore.acquireNextTriggers(System.currentTimeMillis() - 1000, 500, 4000);
    assertThat(acquiredTriggers, hasSize(16));

    // ensure that all triggers are in the NORMAL state and have been ACQUIRED
    for (Map.Entry<JobDetail, Set<? extends Trigger>> jobDetailSetEntry : jobsAndTriggers.entrySet()) {
        for (Trigger trigger : jobDetailSetEntry.getValue()) {
            assertEquals(Trigger.TriggerState.NORMAL, jobStore.getTriggerState(trigger.getKey()));
            String triggerHashKey = schema.triggerHashKey(trigger.getKey());
            assertThat(jedis.zscore(schema.triggerStateKey(RedisTriggerState.ACQUIRED), triggerHashKey), not(nullValue()));
        }
    }

    Set<? extends OperableTrigger> triggers = (Set<? extends  OperableTrigger>) new ArrayList<>(jobsAndTriggers.entrySet()).get(0).getValue();
    List<TriggerFiredResult> triggerFiredResults = jobStore.triggersFired(new ArrayList<>(triggers));
    assertThat(triggerFiredResults, hasSize(4));
}
项目:quartz-couchdb-store    文件:CouchDbCalendarStoreIT.java   
@Test
public void shouldGetAllCalendars() throws JobPersistenceException, ParseException {
    Calendar testCalendar = new WeeklyCalendar();
    String calendarName1 = id("weeklyCalendar");
    couchdbStore.storeCalendar(calendarName1, testCalendar, false, false);

    Calendar cronCalendar = new CronCalendar("1 1 1 * * ?");
    String calendarName2 = id("cronCalendar");
    couchdbStore.storeCalendar(calendarName2, cronCalendar, false, false);

    Calendar anotherCalendar = new CronCalendar("1 1 1 * * ?");
    String calendarName3 = id("anotherCalendar");
    couchdbStore.storeCalendar(calendarName3, anotherCalendar, false, false);

    List<CouchDbCalendar> calendars = couchdbStore.getCalendarStore().getCalendars(asList(calendarName1, calendarName3));
    List<String> calendarNames = extract(calendars, on(CouchDbCalendar.class).getName());
    assertEquals(2, calendars.size());
    assertTrue(calendarNames.contains(calendarName1));
    assertTrue(calendarNames.contains(calendarName3));
}
项目:citrine-scheduler    文件:AdminJobTest.java   
@Before
public void setUp() {
  super.setUp();
  TriggerFiredBundle bundle = new TriggerFiredBundle(jobDetail, new SimpleTrigger(), new WeeklyCalendar(), false,
      new Date(), new Date(), new Date(), new Date());
  context = new JobExecutionContext(scheduler, bundle, adminJob);
}
项目:quartz-redis-jobstore    文件:BaseTest.java   
protected CronTriggerImpl getCronTrigger(final String name, final String group, final JobKey jobKey, String cron){
    CronTriggerImpl trigger = (CronTriggerImpl) TriggerBuilder.newTrigger()
            .forJob(jobKey)
            .withIdentity(name, group)
            .withSchedule(CronScheduleBuilder.cronSchedule(cron))
            .usingJobData("timeout", 5)
            .withDescription("A description!")
            .build();
    WeeklyCalendar calendar = new WeeklyCalendar();
    calendar.setDaysExcluded(new boolean[]{false, false, false, false, false, false, false, false, false});
    trigger.computeFirstFireTime(calendar);
    trigger.setCalendarName("testCalendar");
    return trigger;
}
项目:quartz-redis-jobstore    文件:BaseTest.java   
protected Calendar getCalendar(){
    WeeklyCalendar calendar = new WeeklyCalendar();
    // exclude weekends
    calendar.setDayExcluded(1, true);
    calendar.setDayExcluded(7, true);
    calendar.setDescription("Only run on weekdays.");
    return calendar;
}
项目:quartz-couchdb-store    文件:CouchDbStoreIT.java   
@Test
public void shouldDeleteAllJobsTriggersAndCalendars() throws JobPersistenceException {
    JobDetail job = newJob(JobListener.class)
            .withIdentity(id("fooid"), id("bargroup"))
            .usingJobData("foo", "bar")
            .build();
    couchdbStore.storeJob(job, false);

    Calendar testCalendar = new WeeklyCalendar();
    String calendarName = id("weeklyCalendar");
    couchdbStore.storeCalendar(calendarName, testCalendar, false, false);

    SimpleTriggerImpl trigger = (SimpleTriggerImpl) newTrigger()
            .withIdentity(id("fuuid"), id("borgroup"))
            .forJob(JobKey.jobKey("fooid", "bargroup"))
            .startAt(new Date(2010, 10, 20))
            .withSchedule(simpleSchedule()
                    .withIntervalInMinutes(2)
                    .repeatForever())
            .modifiedByCalendar(calendarName)
            .build();
    couchdbStore.storeTrigger(trigger, false);

    couchdbStore.clearAllSchedulingData();

    assertEquals(0, couchdbStore.getNumberOfJobs());
    assertEquals(0, couchdbStore.getNumberOfCalendars());
    assertEquals(0, couchdbStore.getNumberOfTriggers());
    assertEquals(0, couchdbStore.getJobGroupNames().size());
    assertEquals(0, couchdbStore.getCalendarNames().size());
}
项目:quartz-couchdb-store    文件:CouchDbCalendarStoreIT.java   
@Test
public void shouldGetAllCalendarNames() throws JobPersistenceException, ParseException {
    Calendar testCalendar = new WeeklyCalendar();
    String calendarName1 = id("weeklyCalendar");
    couchdbStore.storeCalendar(calendarName1, testCalendar, false, false);

    Calendar cronCalendar = new CronCalendar("1 1 1 * * ?");
    String calendarName2 = id("cronCalendar");
    couchdbStore.storeCalendar(calendarName2, cronCalendar, false, false);

    List<String> calendarNames = couchdbStore.getCalendarNames();
    assertTrue(calendarNames.size()>0);
    assertTrue(calendarNames.contains(calendarName1));
    assertTrue(calendarNames.contains(calendarName2));
}