use of org.apache.camel.impl.DefaultCamelContext in project camel by apache.
the class ExecJava8IssueTest method test.
@Test
public void test() throws Exception {
if (!OS.isFamilyUnix()) {
System.err.println("The test 'CamelExecTest' does not support the following OS : " + System.getProperty("os.name"));
return;
}
String tempFilePath = tempDir.getAbsolutePath() + "/" + tempFileName;
final File script = File.createTempFile("script", ".sh", tempDir);
writeScript(script);
final String exec = "bash?args=" + script.getAbsolutePath() + " " + tempFilePath + "&outFile=" + tempFilePath;
DefaultCamelContext context = new DefaultCamelContext();
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:source").to("file:" + tempDir.getAbsolutePath() + "?fileName=" + tempFileName).to("exec:" + exec).process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
String output = exchange.getIn().getBody(String.class);
assertEquals("hello world\n", output);
}
});
}
});
context.start();
ProducerTemplate pt = context.createProducerTemplate();
String payload = "hello";
pt.sendBody("direct:source", payload);
}
use of org.apache.camel.impl.DefaultCamelContext in project camel by apache.
the class Main method getCamelContextMap.
protected Map<String, CamelContext> getCamelContextMap() {
Map<String, CamelContext> answer = new HashMap<String, CamelContext>();
CamelContext camelContext = createContext();
if (registry.size() > 0) {
// set the registry through which we've already bound some beans
if (DefaultCamelContext.class.isAssignableFrom(camelContext.getClass())) {
CompositeRegistry compositeRegistry = new CompositeRegistry();
// make sure camel look up the Object from the registry first
compositeRegistry.addRegistry(registry);
// use the camel old registry as a fallback
compositeRegistry.addRegistry(((DefaultCamelContext) camelContext).getRegistry());
((DefaultCamelContext) camelContext).setRegistry(compositeRegistry);
}
}
answer.put("camel-1", camelContext);
return answer;
}
use of org.apache.camel.impl.DefaultCamelContext in project camel by apache.
the class BeanLookupUsingJndiRegistryIssueTest method testCamelWithJndi.
public void testCamelWithJndi() throws Exception {
JndiContext jndi = new JndiContext();
jndi.bind("foo", new MyOtherDummyBean());
CamelContext camel = new DefaultCamelContext(jndi);
camel.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").bean("foo");
}
});
camel.start();
String reply = camel.createProducerTemplate().requestBody("direct:start", "Camel", String.class);
assertEquals("Hello Camel", reply);
camel.stop();
}
use of org.apache.camel.impl.DefaultCamelContext in project camel by apache.
the class ComponentDiscoveryTest method testComponentDiscovery.
@Test
public void testComponentDiscovery() throws Exception {
CamelContext context = new DefaultCamelContext();
SortedMap<String, Properties> map = CamelContextHelper.findComponents(context);
assertNotNull("Should never return null", map);
assertTrue("Component map should never be empty", !map.isEmpty());
String[] expectedComponentNames = { "file", "vm" };
for (String expectedName : expectedComponentNames) {
Properties properties = map.get(expectedName);
assertTrue("Component map contain component: " + expectedName, properties != null);
}
Set<Map.Entry<String, Properties>> entries = map.entrySet();
for (Map.Entry<String, Properties> entry : entries) {
LOG.info("Found component " + entry.getKey() + " with properties: " + entry.getValue());
}
}
use of org.apache.camel.impl.DefaultCamelContext in project camel by apache.
the class RefInvalidTest method createCamelContext.
@Override
protected CamelContext createCamelContext() throws Exception {
CamelContext context = new DefaultCamelContext(registry);
registry.put("foo", context.getEndpoint("seda:foo"));
return context;
}
Aggregations