Search in sources :

Example 56 with CamelContext

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

the class CamelPublisherConversionVerificationTest method createPublisher.

@Override
public Publisher<Long> createPublisher(long l) {
    CamelContext context = new DefaultCamelContext();
    RouteBuilder builder = new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("timer:tick?delay=500&period=50&repeatCount=" + l).setBody().simple("random(1000)").to("reactive-streams:prod");
        }
    };
    Publisher<Long> pub = CamelReactiveStreams.get(context).fromStream("prod", Long.class);
    try {
        builder.addRoutesToCamelContext(context);
        context.start();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return pub;
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) RouteBuilder(org.apache.camel.builder.RouteBuilder) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Example 57 with CamelContext

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

the class CamelPublisherVerificationTest method createPublisher.

@Override
public Publisher<Exchange> createPublisher(long l) {
    CamelContext context = new DefaultCamelContext();
    RouteBuilder builder = new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("timer:tick?delay=500&period=50&repeatCount=" + l).to("reactive-streams:prod");
        }
    };
    Publisher<Exchange> pub = CamelReactiveStreams.get(context).fromStream("prod");
    try {
        builder.addRoutesToCamelContext(context);
        context.start();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return pub;
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Exchange(org.apache.camel.Exchange) RouteBuilder(org.apache.camel.builder.RouteBuilder) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Example 58 with CamelContext

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

the class SalesforceComponentConfigurationIntegrationTest method createCamelContext.

protected CamelContext createCamelContext() throws Exception {
    final CamelContext camelContext = super.createCamelContext();
    final SalesforceLoginConfig loginConfig = LoginConfigHelper.getLoginConfig();
    final SalesforceComponent component = new SalesforceComponent();
    component.setLoginConfig(loginConfig);
    // set DTO package
    component.setPackages(new String[] { Merchandise__c.class.getPackage().getName() });
    camelContext.addComponent(componentName, component);
    return camelContext;
}
Also used : CamelContext(org.apache.camel.CamelContext)

Example 59 with CamelContext

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

the class PropertyPlaceholderRouteTest method testCamelContext.

@Test
public void testCamelContext() throws Exception {
    CamelContext context = getCamelContext();
    assertNotNull(context);
    assertEquals("MyCamel", context.getName());
    ProducerTemplate template = context.createProducerTemplate();
    MockEndpoint mock = context.getEndpoint("mock:result", MockEndpoint.class);
    mock.expectedBodiesReceived("Hello World");
    template.sendBody("direct:foo", "World");
    mock.assertIsSatisfied();
    template.stop();
}
Also used : CamelContext(org.apache.camel.CamelContext) ProducerTemplate(org.apache.camel.ProducerTemplate) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 60 with CamelContext

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

the class SjmsEndpointTest method createCamelContext.

protected CamelContext createCamelContext() throws Exception {
    CamelContext camelContext = super.createCamelContext();
    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://broker?broker.persistent=false&broker.useJmx=false");
    SjmsComponent component = new SjmsComponent();
    component.setConnectionCount(3);
    component.setConnectionFactory(connectionFactory);
    camelContext.addComponent("sjms", component);
    return camelContext;
}
Also used : CamelContext(org.apache.camel.CamelContext) ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory)

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