use of org.quartz.JobDetail in project camel by apache.
the class QuartzJobRouteUnderscoreTest method testQuartzRoute.
@Test
public void testQuartzRoute() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(2);
mock.message(0).header("triggerGroup").isEqualTo("my_group");
mock.message(0).header("triggerName").isEqualTo("my_timer");
assertMockEndpointsSatisfied();
JobDetail detail = mock.getReceivedExchanges().get(0).getIn().getHeader("jobDetail", JobDetail.class);
assertNotNull(detail);
assertEquals("my_job", detail.getName());
}
use of org.quartz.JobDetail in project camel by apache.
the class QuartzRouteFireNowTest method testQuartzRoute.
@Test
public void testQuartzRoute() throws Exception {
resultEndpoint = getMockEndpoint("mock:result");
resultEndpoint.expectedMessageCount(2);
resultEndpoint.message(0).header("triggerName").isEqualTo("myTimerName");
resultEndpoint.message(0).header("triggerGroup").isEqualTo("myGroup");
// lets test the receive worked
resultEndpoint.assertIsSatisfied();
JobDetail job = resultEndpoint.getReceivedExchanges().get(0).getIn().getHeader("jobDetail", JobDetail.class);
assertNotNull(job);
assertEquals("simple", job.getJobDataMap().get(QuartzConstants.QUARTZ_TRIGGER_TYPE));
assertEquals(25000L, job.getJobDataMap().get(QuartzConstants.QUARTZ_TRIGGER_SIMPLE_REPEAT_INTERVAL));
assertEquals(2, job.getJobDataMap().get(QuartzConstants.QUARTZ_TRIGGER_SIMPLE_REPEAT_COUNTER));
}
use of org.quartz.JobDetail in project camel by apache.
the class QuartzCronRouteTest method testQuartzCronRoute.
@Test
public void testQuartzCronRoute() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMinimumMessageCount(3);
assertMockEndpointsSatisfied();
Trigger trigger = mock.getReceivedExchanges().get(0).getIn().getHeader("trigger", Trigger.class);
Assert.assertThat(trigger instanceof CronTrigger, CoreMatchers.is(true));
JobDetail detail = mock.getReceivedExchanges().get(0).getIn().getHeader("jobDetail", JobDetail.class);
Assert.assertThat(detail.getJobClass().equals(CamelJob.class), CoreMatchers.is(true));
Assert.assertThat(detail.getJobDataMap().get(QuartzConstants.QUARTZ_TRIGGER_TYPE).equals("cron"), CoreMatchers.is(true));
Assert.assertThat(detail.getJobDataMap().get(QuartzConstants.QUARTZ_TRIGGER_CRON_EXPRESSION).equals("0/2 * * * * ?"), CoreMatchers.is(true));
}
use of org.quartz.JobDetail in project camel by apache.
the class QuartzCronTriggerRouteTest method testQuartzCronRoute.
@Test
public void testQuartzCronRoute() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMinimumMessageCount(3);
assertMockEndpointsSatisfied();
JobDetail job = mock.getReceivedExchanges().get(0).getIn().getHeader("jobDetail", JobDetail.class);
assertNotNull(job);
assertEquals("cron", job.getJobDataMap().get(QuartzConstants.QUARTZ_TRIGGER_TYPE));
assertEquals("UTC", job.getJobDataMap().get(QuartzConstants.QUARTZ_TRIGGER_CRON_TIMEZONE));
assertEquals("0/2 * * * * ?", job.getJobDataMap().get(QuartzConstants.QUARTZ_TRIGGER_CRON_EXPRESSION));
}
use of org.quartz.JobDetail in project camel by apache.
the class QuartzEndpointConfigureTest method testConfigureGroupAndName.
@Test
public void testConfigureGroupAndName() throws Exception {
QuartzEndpoint endpoint = resolveMandatoryEndpoint("quartz2://myGroup/myName?trigger.repeatCount=3&trigger.repeatInterval=1000");
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()", "myName", triggerKey.getName());
assertEquals("getGroup()", "myGroup", triggerKey.getGroup());
assertEquals("getJobName", "myName", jobDetail.getKey().getName());
assertEquals("getJobGroup", "myGroup", jobDetail.getKey().getGroup());
SimpleTrigger simpleTrigger = assertIsInstanceOf(SimpleTrigger.class, trigger);
assertEquals("getRepeatCount()", 3, simpleTrigger.getRepeatCount());
}
Aggregations