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 AbstractInfluxDbTest method createCamelContext.
@Override
protected CamelContext createCamelContext() throws Exception {
applicationContext = new AnnotationConfigApplicationContext(MockedInfluxDbConfiguration.class);
CamelContext ctx = new SpringCamelContext(applicationContext);
PropertiesComponent pc = new PropertiesComponent("classpath:influxdb.test.properties");
ctx.addComponent("properties", pc);
return ctx;
}
use of org.apache.camel.spring.SpringCamelContext in project camel by apache.
the class CxfEndpointTest method testSpringCxfEndpoint.
@Test
public void testSpringCxfEndpoint() throws Exception {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(new String[] { "org/apache/camel/component/cxf/CxfEndpointBeans.xml" });
CxfComponent cxfComponent = new CxfComponent(new SpringCamelContext(ctx));
CxfSpringEndpoint endpoint = (CxfSpringEndpoint) cxfComponent.createEndpoint("cxf://bean:serviceEndpoint");
assertEquals("Got the wrong endpoint address", endpoint.getAddress(), "http://localhost:" + port2 + "/CxfEndpointTest/helloworld");
assertEquals("Got the wrong endpont service class", endpoint.getServiceClass().getCanonicalName(), "org.apache.camel.component.cxf.HelloService");
}
Aggregations