微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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,"* * * * * ?");
    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);

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

    Calendar anotherCalendar = new CronCalendar("1 1 1 * * ?");
    String calendarName3 = id("anotherCalendar");
    couchdbStore.storeCalendar(calendarName3,anotherCalendar,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 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});
    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,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,false);

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。