use of org.apache.camel.spring.example.MyProcessor 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.spring.example.MyProcessor in project camel by apache.
the class CustomProcessorWithNamespacesTest method testXMLRouteLoading.
public void testXMLRouteLoading() throws Exception {
applicationContext = createApplicationContext();
SpringCamelContext context = applicationContext.getBeansOfType(SpringCamelContext.class).values().iterator().next();
assertValidContext(context);
// now lets send a message
ProducerTemplate template = context.createProducerTemplate();
template.start();
template.send("direct:start", new Processor() {
public void process(Exchange exchange) {
Message in = exchange.getIn();
in.setHeader("name", "James");
in.setBody(body);
}
});
template.stop();
MyProcessor myProcessor = applicationContext.getBean("myProcessor", MyProcessor.class);
List<Exchange> list = myProcessor.getExchanges();
assertEquals("Should have received a single exchange: " + list, 1, list.size());
}
use of org.apache.camel.spring.example.MyProcessor in project camel by apache.
the class MainExampleTest method testMain.
public void testMain() throws Exception {
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("file://target/mainTest");
}
});
main.start();
// then some time later
Thread.sleep(1000);
main.stop();
}
Aggregations