Search in sources :

Example 41 with SimpleRegistry

use of org.apache.camel.impl.SimpleRegistry in project camel by apache.

the class SjmsBatchEndpointTest method createCamelContext.

@Override
protected CamelContext createCamelContext() throws Exception {
    SimpleRegistry registry = new SimpleRegistry();
    registry.put("aggStrategy", AggregationStrategies.groupedExchange());
    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
    connectionFactory.setBrokerURL(broker.getTcpConnectorUri());
    SjmsComponent sjmsComponent = new SjmsComponent();
    sjmsComponent.setConnectionFactory(connectionFactory);
    SjmsBatchComponent sjmsBatchComponent = new SjmsBatchComponent();
    sjmsBatchComponent.setConnectionFactory(connectionFactory);
    CamelContext context = new DefaultCamelContext(registry);
    context.addComponent("sjms-batch", sjmsBatchComponent);
    context.addComponent("sjms", sjmsComponent);
    return context;
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) SimpleRegistry(org.apache.camel.impl.SimpleRegistry) SjmsComponent(org.apache.camel.component.sjms.SjmsComponent) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Example 42 with SimpleRegistry

use of org.apache.camel.impl.SimpleRegistry in project camel by apache.

the class SjmsEndpointConnectionSettingsTest method createCamelContext.

@Override
protected CamelContext createCamelContext() throws Exception {
    SimpleRegistry registry = new SimpleRegistry();
    registry.put("activemq", connectionFactory);
    registry.put("connresource", connectionResource);
    return new DefaultCamelContext(registry);
}
Also used : SimpleRegistry(org.apache.camel.impl.SimpleRegistry) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Example 43 with SimpleRegistry

use of org.apache.camel.impl.SimpleRegistry in project camel by apache.

the class SedaQueueTest method createCamelContext.

@Override
protected CamelContext createCamelContext() throws Exception {
    SimpleRegistry simpleRegistry = new SimpleRegistry();
    simpleRegistry.put("arrayQueue", new ArrayBlockingQueue<Exchange>(10));
    return new DefaultCamelContext(simpleRegistry);
}
Also used : Exchange(org.apache.camel.Exchange) SimpleRegistry(org.apache.camel.impl.SimpleRegistry) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Example 44 with SimpleRegistry

use of org.apache.camel.impl.SimpleRegistry in project camel by apache.

the class ServiceCallConfigurationTest method testDefaultConfigurationFromRegistryWithNonDefaultName.

@Test
public void testDefaultConfigurationFromRegistryWithNonDefaultName() throws Exception {
    StaticServiceDiscovery sd = new StaticServiceDiscovery();
    sd.addServer("127.0.0.1:8080");
    sd.addServer("127.0.0.1:8081");
    BlacklistServiceFilter sf = new BlacklistServiceFilter();
    sf.addServer("127.0.0.1:8080");
    ServiceCallConfigurationDefinition conf = new ServiceCallConfigurationDefinition();
    conf.setServiceDiscovery(sd);
    conf.serviceFilter(sf);
    SimpleRegistry reg = new SimpleRegistry();
    reg.put(UUID.randomUUID().toString(), conf);
    CamelContext context = new DefaultCamelContext(reg);
    context.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("direct:start").routeId("default").serviceCall().name("scall").component("file").end();
        }
    });
    context.start();
    DefaultServiceCallProcessor proc = findServiceCallProcessor(context.getRoute("default"));
    Assert.assertNotNull(proc);
    Assert.assertTrue(proc.getLoadBalancer() instanceof DefaultLoadBalancer);
    DefaultLoadBalancer loadBalancer = (DefaultLoadBalancer) proc.getLoadBalancer();
    Assert.assertEquals(sd, loadBalancer.getServiceDiscovery());
    Assert.assertEquals(sf, loadBalancer.getServiceFilter());
    context.stop();
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) RouteBuilder(org.apache.camel.builder.RouteBuilder) SimpleRegistry(org.apache.camel.impl.SimpleRegistry) ServiceCallConfigurationDefinition(org.apache.camel.model.cloud.ServiceCallConfigurationDefinition) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Test(org.junit.Test)

Example 45 with SimpleRegistry

use of org.apache.camel.impl.SimpleRegistry in project camel by apache.

the class BlueprintComponentResolverTest method testOsgiResolverFindLanguageDoubleFallbackTest.

@Test
public void testOsgiResolverFindLanguageDoubleFallbackTest() throws Exception {
    SimpleRegistry registry = new SimpleRegistry();
    registry.put("allstar", new SampleComponent(false));
    registry.put("allstar-component", new SampleComponent(true));
    CamelContext camelContext = new DefaultCamelContext(registry);
    BlueprintComponentResolver resolver = new BlueprintComponentResolver(null);
    Component component = resolver.resolveComponent("allstar", camelContext);
    assertNotNull("We should find the super component", component);
    assertTrue("We should get the super component here", component instanceof SampleComponent);
    assertFalse("We should NOT find the fallback component", ((SampleComponent) component).isFallback());
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) SimpleRegistry(org.apache.camel.impl.SimpleRegistry) Component(org.apache.camel.Component) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Test(org.junit.Test)

Aggregations

SimpleRegistry (org.apache.camel.impl.SimpleRegistry)60 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)57 CamelContext (org.apache.camel.CamelContext)35 Test (org.junit.Test)25 RouteBuilder (org.apache.camel.builder.RouteBuilder)14 Before (org.junit.Before)8 FailedToCreateRouteException (org.apache.camel.FailedToCreateRouteException)5 ActiveMQConnectionFactory (org.apache.activemq.ActiveMQConnectionFactory)4 Component (org.apache.camel.Component)4 Exchange (org.apache.camel.Exchange)4 DummyRestConsumerFactory (org.apache.camel.component.rest.DummyRestConsumerFactory)4 HashMap (java.util.HashMap)3 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)3 SjmsComponent (org.apache.camel.component.sjms.SjmsComponent)3 Config (com.hazelcast.config.Config)2 HazelcastInstance (com.hazelcast.core.HazelcastInstance)2 Properties (java.util.Properties)2 ConnectionFactory (javax.jms.ConnectionFactory)2 FileComponent (org.apache.camel.component.file.FileComponent)2 HystrixConfigurationDefinition (org.apache.camel.model.HystrixConfigurationDefinition)2