Search in sources :

Example 91 with CamelContext

use of org.apache.camel.CamelContext in project camel by apache.

the class SpringRemotingTwoCamelContextTest method testProxyWithTwoCamelContext.

public void testProxyWithTwoCamelContext() throws Exception {
    AbstractXmlApplicationContext applicationContext = createApplicationContext();
    CamelContext camelContext = SpringCamelContext.springCamelContext(applicationContext);
    ISay proxy = applicationContext.getBean("sayProxy1", ISay.class);
    String rc = proxy.say();
    assertEquals("context-1", rc);
    proxy = applicationContext.getBean("sayProxy2", ISay.class);
    rc = proxy.say();
    assertEquals("context-2", rc);
    camelContext.stop();
    IOHelper.close(applicationContext);
}
Also used : CamelContext(org.apache.camel.CamelContext) SpringCamelContext(org.apache.camel.spring.SpringCamelContext) AbstractXmlApplicationContext(org.springframework.context.support.AbstractXmlApplicationContext)

Example 92 with CamelContext

use of org.apache.camel.CamelContext in project camel by apache.

the class SpringRemotingBeanConverterTest method testBeanRoutes.

public void testBeanRoutes() throws Exception {
    AbstractXmlApplicationContext applicationContext = createApplicationContext();
    CamelContext camelContext = SpringCamelContext.springCamelContext(applicationContext);
    Invoker invoker = applicationContext.getBean("invokerProxy", Invoker.class);
    String response = invoker.invoke(new Bean.SubClass());
    assertEquals("Hello from Sub", response);
    camelContext.stop();
    IOHelper.close(applicationContext);
}
Also used : CamelContext(org.apache.camel.CamelContext) SpringCamelContext(org.apache.camel.spring.SpringCamelContext) AbstractXmlApplicationContext(org.springframework.context.support.AbstractXmlApplicationContext)

Example 93 with CamelContext

use of org.apache.camel.CamelContext in project camel by apache.

the class BaseUrlRewriteTest method createCamelContext.

@Override
protected CamelContext createCamelContext() throws Exception {
    CamelContext context = super.createCamelContext();
    context.addComponent("properties", new PropertiesComponent("ref:prop"));
    return context;
}
Also used : CamelContext(org.apache.camel.CamelContext) PropertiesComponent(org.apache.camel.component.properties.PropertiesComponent)

Example 94 with CamelContext

use of org.apache.camel.CamelContext in project camel by apache.

the class XmlSignatureTest method doSignatureRouteTest.

public Exchange doSignatureRouteTest(RouteBuilder builder, Exchange e, Map<String, Object> headers) throws Exception {
    CamelContext context = new DefaultCamelContext();
    try {
        context.addRoutes(builder);
        context.start();
        MockEndpoint mock = context.getEndpoint("mock:result", MockEndpoint.class);
        mock.setExpectedMessageCount(1);
        ProducerTemplate template = context.createProducerTemplate();
        if (e != null) {
            template.send("direct:in", e);
        } else {
            template.sendBodyAndHeaders("direct:in", payload, headers);
        }
        assertMockEndpointsSatisfied();
        return mock.getReceivedExchanges().get(0);
    } finally {
        context.stop();
    }
}
Also used : DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) CamelContext(org.apache.camel.CamelContext) ProducerTemplate(org.apache.camel.ProducerTemplate) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Example 95 with CamelContext

use of org.apache.camel.CamelContext in project camel by apache.

the class CamelBlueprintTestSupport method createCamelContext.

@Override
protected CamelContext createCamelContext() throws Exception {
    CamelContext answer = null;
    Long timeout = getCamelContextCreationTimeout();
    if (timeout == null) {
        answer = CamelBlueprintHelper.getOsgiService(bundleContext, CamelContext.class);
    } else if (timeout >= 0) {
        answer = CamelBlueprintHelper.getOsgiService(bundleContext, CamelContext.class, timeout);
    } else {
        throw new IllegalArgumentException("getCamelContextCreationTimeout cannot return a negative value.");
    }
    // must override context so we use the correct one in testing
    context = (ModelCamelContext) answer;
    return answer;
}
Also used : CamelContext(org.apache.camel.CamelContext) ModelCamelContext(org.apache.camel.model.ModelCamelContext)

Aggregations

CamelContext (org.apache.camel.CamelContext)1478 Test (org.junit.Test)691 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)684 RouteBuilder (org.apache.camel.builder.RouteBuilder)448 ProducerTemplate (org.apache.camel.ProducerTemplate)434 ConnectionFactory (javax.jms.ConnectionFactory)220 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)210 Exchange (org.apache.camel.Exchange)109 HashMap (java.util.HashMap)93 Endpoint (org.apache.camel.Endpoint)52 DefaultExchange (org.apache.camel.impl.DefaultExchange)50 IOException (java.io.IOException)46 Map (java.util.Map)45 SimpleRegistry (org.apache.camel.impl.SimpleRegistry)44 CountDownLatch (java.util.concurrent.CountDownLatch)42 SpringCamelContext (org.apache.camel.spring.SpringCamelContext)42 ArrayList (java.util.ArrayList)41 Processor (org.apache.camel.Processor)40 PropertiesComponent (org.apache.camel.component.properties.PropertiesComponent)37 CamelExecutionException (org.apache.camel.CamelExecutionException)33