Java Code Examples for org.apache.camel.CamelContext#init()

The following examples show how to use org.apache.camel.CamelContext#init() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CustomConverterTest.java    From wildfly-camel with Apache License 2.0 6 votes vote down vote up
@Test
public void testMarshal() throws Exception {

    CamelContext camelctx = new DefaultCamelContext(false);
    camelctx.setLoadTypeConverters(true);
    camelctx.init();
    
    camelctx.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:start").convertBodyTo(Map.class);
        }
    });

    camelctx.start();
    try {
        ProducerTemplate producer = camelctx.createProducerTemplate();
        Map<?, ?> result = producer.requestBody("direct:start", new Customer("John", "Doe"), Map.class);
        Assert.assertEquals("{firstName=John, lastName=Doe}", result.toString());
    } finally {
        camelctx.close();
    }
}
 
Example 2
Source File: AbstractEmailTest.java    From syndesis with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a camel context complete with a properties component that handles
 * lookups of secret values such as passwords. Fetches the values from external
 * properties file.
 *
 * @return CamelContext
 */
protected CamelContext createCamelContext() {
    CamelContext ctx = new SpringCamelContext(applicationContext);
    ctx.disableJMX();
    ctx.init();

    PropertiesComponent pc = new PropertiesComponent();
    pc.addLocation(new PropertiesLocation("classpath:mail-test-options.properties"));
    ctx.setPropertiesComponent(pc);
    return ctx;
}