use of org.springframework.context.support.AbstractXmlApplicationContext in project camel by apache.
the class SpringTwoCamelContextDirectEndpointTest method testSpringTwoCamelContextDirectEndpoint.
public void testSpringTwoCamelContextDirectEndpoint() throws Exception {
AbstractXmlApplicationContext ac = createApplicationContext();
ac.start();
CamelContext camel1 = ac.getBean("camel-1", CamelContext.class);
CamelContext camel2 = ac.getBean("camel-2", CamelContext.class);
Endpoint start1 = camel1.getEndpoint("direct:start");
Endpoint start2 = camel2.getEndpoint("direct:start");
assertNotSame(start1, start2);
Endpoint foo1 = camel1.getEndpoint("direct:foo");
Endpoint foo2 = camel2.getEndpoint("direct:foo");
assertNotSame(foo1, foo2);
MockEndpoint mock1 = camel1.getEndpoint("mock:a", MockEndpoint.class);
mock1.expectedBodiesReceived("Hello World");
MockEndpoint mock2 = camel2.getEndpoint("mock:b", MockEndpoint.class);
mock2.expectedBodiesReceived("Bye World");
camel1.createProducerTemplate().sendBody("direct:start", "Hello World");
camel2.createProducerTemplate().sendBody("direct:start", "Bye World");
mock1.assertIsSatisfied();
mock2.assertIsSatisfied();
ac.stop();
}
use of org.springframework.context.support.AbstractXmlApplicationContext in project camel by apache.
the class SpringQuartzPersistentStoreRestartAppChangeOptionsTest method testRestartAppChangeTriggerOptions.
@Test
public void testRestartAppChangeTriggerOptions() throws Exception {
// Test creates application context twice with different simple trigger options in configuration xml.
// Both times it retrieves back the option, accessing it via trigger (so, using value stored in DB).
// After that it asserts that two options are not equal.
// load spring app
AbstractXmlApplicationContext app = new ClassPathXmlApplicationContext("org/apache/camel/component/quartz/SpringQuartzPersistentStoreRestartAppChangeOptionsTest1.xml");
app.start();
CamelContext camel = app.getBean("camelContext", CamelContext.class);
assertNotNull(camel);
SimpleTrigger trigger = (SimpleTrigger) getTrigger(camel, "quartzRoute");
long repeatInterval = trigger.getRepeatInterval();
app.stop();
log.info("Restarting ...");
log.info("Restarting ...");
log.info("Restarting ...");
// load spring app
AbstractXmlApplicationContext app2 = new ClassPathXmlApplicationContext("org/apache/camel/component/quartz/SpringQuartzPersistentStoreRestartAppChangeOptionsTest2.xml");
app2.start();
CamelContext camel2 = app2.getBean("camelContext", CamelContext.class);
assertNotNull(camel2);
SimpleTrigger trigger2 = (SimpleTrigger) getTrigger(camel2, "quartzRoute");
long repeatInterval2 = trigger2.getRepeatInterval();
app2.stop();
// we're done so let's properly close the application contexts, but close
// the second app before the first one so that the quartz scheduler running
// inside it can be properly shutdown
IOHelper.close(app2, app);
assertNotEquals(repeatInterval, repeatInterval2);
}
use of org.springframework.context.support.AbstractXmlApplicationContext in project camel by apache.
the class SpringQuartzPersistentStoreRestartAppTest method testQuartzPersistentStoreRestart.
@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, but close
// the second app before the first one so that the quartz scheduler running
// inside it can be properly shutdown
IOHelper.close(app2, app);
}
use of org.springframework.context.support.AbstractXmlApplicationContext in project camel by apache.
the class SpringQuartzPersistentStoreRestartAppChangeOptionsTest method testRestartAppChangeTriggerOptions.
@Test
public void testRestartAppChangeTriggerOptions() throws Exception {
// Test creates application context twice with different simple trigger options in configuration xml.
// Both times it retrieves back the option, accessing it via trigger (so, using value stored in DB).
// After that it asserts that two options are not equal.
// load spring app
AbstractXmlApplicationContext app = new ClassPathXmlApplicationContext("org/apache/camel/component/quartz2/SpringQuartzPersistentStoreRestartAppChangeOptionsTest1.xml");
app.start();
CamelContext camel = app.getBean("camelContext", CamelContext.class);
assertNotNull(camel);
SimpleTrigger trigger = (SimpleTrigger) getTrigger(camel, "quartzRoute");
long repeatInterval = trigger.getRepeatInterval();
app.stop();
log.info("Restarting ...");
log.info("Restarting ...");
log.info("Restarting ...");
// load spring app
AbstractXmlApplicationContext app2 = new ClassPathXmlApplicationContext("org/apache/camel/component/quartz2/SpringQuartzPersistentStoreRestartAppChangeOptionsTest2.xml");
app2.start();
CamelContext camel2 = app2.getBean("camelContext", CamelContext.class);
assertNotNull(camel2);
SimpleTrigger trigger2 = (SimpleTrigger) getTrigger(camel2, "quartzRoute");
long repeatInterval2 = trigger2.getRepeatInterval();
app2.stop();
// we're done so let's properly close the application contexts, but close
// the second app before the first one so that the quartz scheduler running
// inside it can be properly shutdown
IOHelper.close(app2, app);
assertNotEquals(repeatInterval, repeatInterval2);
}
use of org.springframework.context.support.AbstractXmlApplicationContext in project camel by apache.
the class SpringQuartzPersistentStoreRestartAppTest method testQuartzPersistentStoreRestart.
@Test
public void testQuartzPersistentStoreRestart() throws Exception {
// load spring app
AbstractXmlApplicationContext app = new ClassPathXmlApplicationContext("org/apache/camel/component/quartz2/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/quartz2/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, but close
// the second app before the first one so that the quartz scheduler running
// inside it can be properly shutdown
IOHelper.close(app2, app);
}
Aggregations