Search in sources :

Example 11 with SimpleRegistry

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

the class ValidatorEndpointClearCachedSchemaTest method createCamelContext.

@Override
protected CamelContext createCamelContext() throws Exception {
    simpleReg = new SimpleRegistry();
    context = new DefaultCamelContext(simpleReg);
    context.setClassResolver(new ClassResolverImpl());
    return context;
}
Also used : SimpleRegistry(org.apache.camel.impl.SimpleRegistry) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Example 12 with SimpleRegistry

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

the class ServiceCallConfigurationTest method testDefaultConfigurationFromRegistryWithDefaultName.

@Test
public void testDefaultConfigurationFromRegistryWithDefaultName() 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(org.apache.camel.model.cloud.ServiceCallConstants.DEFAULT_SERVICE_CALL_CONFIG_ID, 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 13 with SimpleRegistry

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

the class ResourceHelperTest method testLoadRegistry.

public void testLoadRegistry() throws Exception {
    SimpleRegistry registry = new SimpleRegistry();
    registry.put("myBean", "This is a log4j logging configuration file");
    CamelContext context = new DefaultCamelContext(registry);
    context.start();
    InputStream is = ResourceHelper.resolveMandatoryResourceAsInputStream(context, "ref:myBean");
    assertNotNull(is);
    String text = context.getTypeConverter().convertTo(String.class, is);
    assertNotNull(text);
    assertTrue(text.contains("log4j"));
    is.close();
    context.stop();
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) SimpleRegistry(org.apache.camel.impl.SimpleRegistry) InputStream(java.io.InputStream) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Example 14 with SimpleRegistry

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

the class DdbStreamEndpointTest method setup.

@Before
public void setup() throws Exception {
    SimpleRegistry registry = new SimpleRegistry();
    registry.put("someSeqNumProv", sequenceNumberProvider);
    registry.put("ddbStreamsClient", amazonDynamoDBStreams);
    context = new DefaultCamelContext(registry);
}
Also used : SimpleRegistry(org.apache.camel.impl.SimpleRegistry) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Before(org.junit.Before)

Example 15 with SimpleRegistry

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

the class GroovyShellFactoryTest method testExpressionReturnsTheCorrectValue.

@Test
public void testExpressionReturnsTheCorrectValue() {
    // Given
    GroovyShellFactory groovyShellFactory = mock(GroovyShellFactory.class);
    given(groovyShellFactory.createGroovyShell(any(Exchange.class))).willReturn(new GroovyShell());
    SimpleRegistry registry = new SimpleRegistry();
    registry.put("groovyShellFactory", groovyShellFactory);
    CamelContext camelContext = new DefaultCamelContext(registry);
    // When
    assertExpression(GroovyLanguage.groovy("exchange.in.body"), new DefaultExchange(camelContext), null);
    // Then
    verify(groovyShellFactory).createGroovyShell(any(Exchange.class));
}
Also used : DefaultExchange(org.apache.camel.impl.DefaultExchange) Exchange(org.apache.camel.Exchange) CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) DefaultExchange(org.apache.camel.impl.DefaultExchange) SimpleRegistry(org.apache.camel.impl.SimpleRegistry) GroovyShell(groovy.lang.GroovyShell) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Test(org.junit.Test)

Aggregations

SimpleRegistry (org.apache.camel.impl.SimpleRegistry)64 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)61 CamelContext (org.apache.camel.CamelContext)40 Test (org.junit.Test)31 RouteBuilder (org.apache.camel.builder.RouteBuilder)14 Before (org.junit.Before)8 FailedToCreateRouteException (org.apache.camel.FailedToCreateRouteException)5 EchoRequest (org.opennms.core.rpc.echo.EchoRequest)5 EchoRpcModule (org.opennms.core.rpc.echo.EchoRpcModule)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 DefaultExchange (org.apache.camel.impl.DefaultExchange)4 EchoResponse (org.opennms.core.rpc.echo.EchoResponse)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