use of org.apache.camel.CamelContext in project camel by apache.
the class MainDummyTest method testMain.
public void testMain() throws Exception {
Main main = new Main();
main.start();
// should also be a Camel
CamelContext camel = main.getApplicationContext().getBean(CamelContext.class);
assertNotNull("Camel should be in Spring", camel);
DummyBean dummy = (DummyBean) main.getApplicationContext().getBean("dummy");
assertNotNull(dummy);
assertEquals("John Doe", dummy.getName());
main.stop();
}
use of org.apache.camel.CamelContext in project camel by apache.
the class MainTest method testMain.
public void testMain() throws Exception {
// lets make a simple route
Main main = new Main();
main.addRouteBuilder(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("file://src/test/data?noop=true").process(new MyProcessor()).to("mock:results");
}
});
main.start();
List<CamelContext> contextList = main.getCamelContexts();
assertNotNull(contextList);
assertEquals("size", 1, contextList.size());
CamelContext camelContext = contextList.get(0);
MockEndpoint endpoint = camelContext.getEndpoint("mock:results", MockEndpoint.class);
// in case we add more files in src/test/data
endpoint.expectedMinimumMessageCount(2);
endpoint.assertIsSatisfied();
List<Exchange> list = endpoint.getReceivedExchanges();
LOG.debug("Received: " + list);
main.stop();
}
use of org.apache.camel.CamelContext in project camel by apache.
the class DualCamelContextEndpointOutsideTest method testDualCamelContextEndpoint.
public void testDualCamelContextEndpoint() throws Exception {
CamelContext camelA = applicationContext.getBean("camel-A", CamelContext.class);
assertNotNull(camelA);
CamelContext camelB = applicationContext.getBean("camel-B", CamelContext.class);
assertNotNull(camelB);
MockEndpoint mockA = camelA.getEndpoint("mock:mock1", MockEndpoint.class);
mockA.expectedBodiesReceived("Hello A");
MockEndpoint mockB = camelB.getEndpoint("mock:mock2", MockEndpoint.class);
mockB.expectedBodiesReceived("Hello B");
ProducerTemplate producer1 = camelA.createProducerTemplate();
producer1.sendBody("direct:start1", "Hello A");
ProducerTemplate producer2 = camelB.createProducerTemplate();
producer2.sendBody("direct:start2", "Hello B");
// make sure we properly stop the services we created
ServiceHelper.stopServices(producer1, producer2);
mockA.assertIsSatisfied();
mockB.assertIsSatisfied();
}
use of org.apache.camel.CamelContext in project camel by apache.
the class SpringTestSupport method createCamelContext.
@SuppressWarnings("deprecation")
@Override
protected CamelContext createCamelContext() throws Exception {
CamelContext context = SpringCamelContext.springCamelContext(applicationContext);
context.setLazyLoadTypeConverters(isLazyLoadingTypeConverter());
return context;
}
use of org.apache.camel.CamelContext in project camel by apache.
the class SpringRemotingRouteTest method testBeanRoutes.
public void testBeanRoutes() throws Exception {
AbstractXmlApplicationContext applicationContext = createApplicationContext();
CamelContext camelContext = SpringCamelContext.springCamelContext(applicationContext);
// START SNIPPET: invoke
ISay proxy = applicationContext.getBean("sayProxy", ISay.class);
String rc = proxy.say();
assertEquals("Hello", rc);
// END SNIPPET: invoke
camelContext.stop();
IOHelper.close(applicationContext);
}
Aggregations