use of org.springframework.context.support.ClassPathXmlApplicationContext 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.springframework.context.support.ClassPathXmlApplicationContext in project camel by apache.
the class CamelContextFactoryBeanTest method testClassPathRouteLoadingUsingNamespaces.
public void testClassPathRouteLoadingUsingNamespaces() throws Exception {
applicationContext = new ClassPathXmlApplicationContext("org/apache/camel/spring/camelContextFactoryBean.xml");
CamelContext context = applicationContext.getBean("camel3", CamelContext.class);
assertValidContext(context);
}
use of org.springframework.context.support.ClassPathXmlApplicationContext in project camel by apache.
the class CamelContextFactoryBeanTest method testRouteBuilderRef.
public void testRouteBuilderRef() throws Exception {
applicationContext = new ClassPathXmlApplicationContext("org/apache/camel/spring/camelContextRouteBuilderRef.xml");
CamelContext context = applicationContext.getBean("camel5", CamelContext.class);
assertNotNull("No context found!", context);
assertValidContext(context);
}
use of org.springframework.context.support.ClassPathXmlApplicationContext 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.springframework.context.support.ClassPathXmlApplicationContext 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);
}
Aggregations