public class SpringQuartzPersistentStoreRestartAppTest extends TestSupport {
@Test
public void testQuartzPersistentStoreRestart() throws Exception {
// load spring app
AbstractXmlApplicationContext app = new ClassPathXmlApplicationContext("org/apache/camel/component/quartz/SpringQuartzPersistentStoreTest.xml");
app.start();
CamelContext camel = app.getBean("camelContext", CamelContext.class);
assertNotNull(camel);
MockEndpoint mock = camel.getEndpoint("mock:result", MockEndpoint.class);
mock.expectedMinimumMessageCount(2);
mock.assertIsSatisfied();
app.stop();
log.info("Restarting ...");
log.info("Restarting ...");
log.info("Restarting ...");
// NOTE:
// To test a restart where the app has crashed, then you can in QuartzEndpoint
// in the doShutdown method, then remove the following code line
// deleteTrigger(getTrigger());
// then when we restart then there is old stale data which QuartzComponent
// is supposed to handle and start again
// load spring app
AbstractXmlApplicationContext app2 = new ClassPathXmlApplicationContext("org/apache/camel/component/quartz/SpringQuartzPersistentStoreRestartTest.xml");
app2.start();
CamelContext camel2 = app2.getBean("camelContext", CamelContext.class);
assertNotNull(camel2);
MockEndpoint mock2 = camel2.getEndpoint("mock:result", MockEndpoint.class);
mock2.expectedMinimumMessageCount(2);
mock2.assertIsSatisfied();
app2.stop();
// we're done so let's properly close the application contexts
app.close();
app2.close();
}