use of org.apache.camel.spring.SpringCamelContext in project camel by apache.
the class CamelContextAutoStartupTest method testAutoStartupFalse.
public void testAutoStartupFalse() throws Exception {
ac = new ClassPathXmlApplicationContext("org/apache/camel/spring/config/CamelContextAutoStartupTestFalse.xml");
SpringCamelContext camel = ac.getBeansOfType(SpringCamelContext.class).values().iterator().next();
assertNotNull(camel.getName());
assertEquals(true, camel.isStarted());
assertEquals(Boolean.FALSE, camel.isAutoStartup());
assertEquals(1, camel.getRoutes().size());
assertEquals(false, camel.getRouteStatus("foo").isStarted());
// now starting route manually
camel.startRoute("foo");
assertEquals(Boolean.FALSE, camel.isAutoStartup());
assertEquals(1, camel.getRoutes().size());
assertEquals(true, camel.getRouteStatus("foo").isStarted());
// and now we can send a message to the route and see that it works
MockEndpoint mock = camel.getEndpoint("mock:result", MockEndpoint.class);
mock.expectedMessageCount(1);
ProducerTemplate template = camel.createProducerTemplate();
template.start();
template.sendBody("direct:start", "Hello World");
template.stop();
mock.assertIsSatisfied();
}
use of org.apache.camel.spring.SpringCamelContext in project camel by apache.
the class CamelContextAutoStartupTest method testAutoStartupTrue.
public void testAutoStartupTrue() throws Exception {
ac = new ClassPathXmlApplicationContext("org/apache/camel/spring/config/CamelContextAutoStartupTestTrue.xml");
SpringCamelContext camel = ac.getBeansOfType(SpringCamelContext.class).values().iterator().next();
assertNotNull(camel.getName());
assertEquals(true, camel.isStarted());
assertEquals(Boolean.TRUE, camel.isAutoStartup());
assertEquals(1, camel.getRoutes().size());
// send a message to the route and see that it works
MockEndpoint mock = camel.getEndpoint("mock:result", MockEndpoint.class);
mock.expectedMessageCount(1);
ProducerTemplate template = camel.createProducerTemplate();
template.start();
template.sendBody("direct:start", "Hello World");
template.stop();
mock.assertIsSatisfied();
}
use of org.apache.camel.spring.SpringCamelContext in project camel by apache.
the class CamelContextFactoryBeanTest method testAutoStartup.
public void testAutoStartup() throws Exception {
applicationContext = new ClassPathXmlApplicationContext("org/apache/camel/spring/camelContextFactoryBean.xml");
SpringCamelContext context = applicationContext.getBean("camel4", SpringCamelContext.class);
assertFalse(context.isAutoStartup());
// there is 1 route but its not started
assertEquals(1, context.getRoutes().size());
context = applicationContext.getBean("camel3", SpringCamelContext.class);
assertTrue(context.isAutoStartup());
// there is 1 route but and its started
assertEquals(1, context.getRoutes().size());
}
use of org.apache.camel.spring.SpringCamelContext in project camel by apache.
the class CamelProxyTest method testCamelProxy.
public void testCamelProxy() throws Exception {
AbstractApplicationContext ac = new ClassPathXmlApplicationContext("org/apache/camel/spring/config/CamelProxyTest.xml");
MyProxySender sender = ac.getBean("myProxySender", MyProxySender.class);
String reply = sender.hello("World");
assertEquals("Hello World", reply);
// test sending inOnly message
MyProxySender anotherSender = ac.getBean("myAnotherProxySender", MyProxySender.class);
SpringCamelContext context = ac.getBeansOfType(SpringCamelContext.class).values().iterator().next();
MockEndpoint result = resolveMandatoryEndpoint(context, "mock:result", MockEndpoint.class);
result.expectedBodiesReceived("Hello my friends!");
anotherSender.greeting("Hello my friends!");
result.assertIsSatisfied();
result.reset();
// test sending inOnly message with other sender
MyProxySender myProxySenderWithCamelContextId = ac.getBean("myProxySenderWithCamelContextId", MyProxySender.class);
result.expectedBodiesReceived("Hello my friends again!");
myProxySenderWithCamelContextId.greeting("Hello my friends again!");
result.assertIsSatisfied();
// we're done so let's properly close the application context
IOHelper.close(ac);
}
use of org.apache.camel.spring.SpringCamelContext in project camel by apache.
the class RouteAutoStartupPropertiesTest method testAutoStartupFalse.
public void testAutoStartupFalse() throws Exception {
ac = new ClassPathXmlApplicationContext("org/apache/camel/spring/config/RouteAutoStartupFalseTest.xml");
SpringCamelContext camel = ac.getBeansOfType(SpringCamelContext.class).values().iterator().next();
assertEquals(false, camel.getRouteStatus("foo").isStarted());
// now starting route manually
camel.startRoute("foo");
assertEquals(true, camel.getRouteStatus("foo").isStarted());
// and now we can send a message to the route and see that it works
MockEndpoint mock = camel.getEndpoint("mock:result", MockEndpoint.class);
mock.expectedMessageCount(1);
ProducerTemplate template = camel.createProducerTemplate();
template.start();
template.sendBody("direct:start", "Hello World");
template.stop();
mock.assertIsSatisfied();
}
Aggregations