use of org.apache.camel.component.quartz2.QuartzComponent in project wildfly-camel by wildfly-extras.
the class RouteBuilderF method configure.
@Override
public void configure() throws Exception {
final CountDownLatch startLatch = new CountDownLatch(1);
// verify that a component can be added manually
getContext().addComponent("quartz2", new QuartzComponent() {
@Override
public void onCamelContextStarted(CamelContext context, boolean alreadyStarted) throws Exception {
super.onCamelContextStarted(context, alreadyStarted);
startLatch.countDown();
}
});
from("quartz2://mytimer?trigger.repeatCount=3&trigger.repeatInterval=100").process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
if (startLatch.getCount() > 0)
throw new IllegalStateException("onCamelContextStarted not called");
}
}).to(MOCK_RESULT_URI);
}
use of org.apache.camel.component.quartz2.QuartzComponent in project wildfly-camel by wildfly-extras.
the class QuartzIntegrationTest method testScheduler.
@Test
public void testScheduler() throws Exception {
final CountDownLatch procLatch = new CountDownLatch(3);
ClassLoader loader = QuartzIntegrationTest.class.getClassLoader();
Class<?> sclass = loader.loadClass("org.quartz.Scheduler");
Assert.assertNotNull("Scheduler can be loaded", sclass);
CamelContext camelctx = new DefaultCamelContext();
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("quartz2://mytimer?trigger.repeatCount=3&trigger.repeatInterval=100").process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
CamelContext context = exchange.getContext();
QuartzComponent comp = context.getComponent("quartz2", QuartzComponent.class);
Scheduler scheduler = comp.getScheduler();
Assert.assertNotNull("Scheduler not null", scheduler);
procLatch.countDown();
}
}).to("mock:result");
}
});
camelctx.start();
try {
Assert.assertTrue("ProcLatch reached zero", procLatch.await(500, TimeUnit.MILLISECONDS));
} finally {
camelctx.stop();
}
}
Aggregations