use of org.quartz.Scheduler in project camel by apache.
the class QuartzCustomCalendarNoFireTest method testQuartzCustomCronRouteNoFire.
@Test
public void testQuartzCustomCronRouteNoFire() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMinimumMessageCount(0);
QuartzComponent component = context.getComponent("quartz2", QuartzComponent.class);
Scheduler scheduler = component.getScheduler();
Calendar c = scheduler.getCalendar(QuartzConstants.QUARTZ_CAMEL_CUSTOM_CALENDAR);
Date now = new Date();
java.util.Calendar tomorrow = java.util.Calendar.getInstance();
tomorrow.setTime(now);
tomorrow.add(java.util.Calendar.DAY_OF_MONTH, 1);
assertEquals(true, c.isTimeIncluded(tomorrow.getTimeInMillis()));
assertEquals(false, c.isTimeIncluded(now.getTime()));
assertMockEndpointsSatisfied();
}
use of org.quartz.Scheduler in project camel by apache.
the class QuartzEndpointConfigureTest method testConfigureName.
@Test
public void testConfigureName() throws Exception {
QuartzEndpoint endpoint = resolveMandatoryEndpoint("quartz2://myName");
Scheduler scheduler = endpoint.getComponent().getScheduler();
TriggerKey triggerKey = endpoint.getTriggerKey();
JobDetail jobDetail = scheduler.getJobDetail(JobKey.jobKey(triggerKey.getName(), triggerKey.getGroup()));
assertEquals("getName()", "myName", triggerKey.getName());
assertEquals("getGroup()", "Camel_" + context.getManagementName(), triggerKey.getGroup());
assertEquals("getJobName", "myName", jobDetail.getKey().getName());
assertEquals("getJobGroup", "Camel_" + context.getManagementName(), jobDetail.getKey().getGroup());
}
use of org.quartz.Scheduler in project camel by apache.
the class QuartzEndpointConfigureTest method testConfigureAnotherCronExpression.
@Test
public void testConfigureAnotherCronExpression() throws Exception {
QuartzEndpoint endpoint = resolveMandatoryEndpoint("quartz2://myGroup/myTimerName?cron=0+0+*+*+*+?");
Scheduler scheduler = endpoint.getComponent().getScheduler();
TriggerKey triggerKey = endpoint.getTriggerKey();
Trigger trigger = scheduler.getTrigger(triggerKey);
JobDetail jobDetail = scheduler.getJobDetail(JobKey.jobKey(triggerKey.getName(), triggerKey.getGroup()));
assertEquals("getName()", "myTimerName", triggerKey.getName());
assertEquals("getGroup()", "myGroup", triggerKey.getGroup());
assertEquals("getJobName", "myTimerName", jobDetail.getKey().getName());
assertEquals("getJobGroup", "myGroup", jobDetail.getKey().getGroup());
assertIsInstanceOf(CronTrigger.class, trigger);
CronTrigger cronTrigger = (CronTrigger) trigger;
assertEquals("cron expression", "0 0 * * * ?", cronTrigger.getCronExpression());
}
use of org.quartz.Scheduler in project camel by apache.
the class SpringQuartzPersistentStoreRestartAppChangeOptionsTest method getTrigger.
private Trigger getTrigger(CamelContext camel, String routeId) throws SchedulerException {
QuartzEndpoint endpoint = (QuartzEndpoint) (camel.getRoute(routeId).getEndpoint());
QuartzComponent component = endpoint.getComponent();
Scheduler scheduler = component.getScheduler();
return scheduler.getTrigger(endpoint.getTrigger().getName(), endpoint.getTrigger().getGroup());
}
use of org.quartz.Scheduler in project camel by apache.
the class QuartzComponentCamelContextSharedSchedulerTest method setUp.
@Before
public void setUp() throws Exception {
camel1 = new DefaultCamelContext();
camel1.setName("camel-1");
camel1.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("quartz2://myGroup/myTimerName?cron=0/2+*+*+*+*+?").to("mock:one");
}
});
camel1.start();
camel2 = new DefaultCamelContext();
camel2.setName("camel-2");
Scheduler camel1Scheduler = camel1.getComponent("quartz2", QuartzComponent.class).getScheduler();
QuartzComponent camel2QuartzComponent = camel2.getComponent("quartz2", QuartzComponent.class);
camel2QuartzComponent.setScheduler(camel1Scheduler);
camel2.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("quartz2://myOtherGroup/myOtherTimerName?cron=0/1+*+*+*+*+?").to("mock:two");
}
});
camel2.start();
}
Aggregations