Search in sources :

Example 36 with SimpleRegistry

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

the class JpaWithNamedQueryAndParametersTest method setUp.

@Before
public void setUp() throws Exception {
    camelContext = new DefaultCamelContext();
    SimpleRegistry registry = new SimpleRegistry();
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("custName", "Willem");
    // bind the params
    registry.put("params", params);
    camelContext.setRegistry(registry);
    template = camelContext.createProducerTemplate();
    ServiceHelper.startServices(template, camelContext);
    Endpoint value = camelContext.getEndpoint(getEndpointUri());
    assertNotNull("Could not find endpoint!", value);
    assertTrue("Should be a JPA endpoint but was: " + value, value instanceof JpaEndpoint);
    endpoint = (JpaEndpoint) value;
    transactionTemplate = endpoint.createTransactionTemplate();
    entityManager = endpoint.createEntityManager();
}
Also used : Endpoint(org.apache.camel.Endpoint) HashMap(java.util.HashMap) SimpleRegistry(org.apache.camel.impl.SimpleRegistry) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Before(org.junit.Before)

Example 37 with SimpleRegistry

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

the class SmppComponentTest method createEndpointWithSessionStateListener.

@Test
public void createEndpointWithSessionStateListener() throws Exception {
    SimpleRegistry registry = new SimpleRegistry();
    registry.put("sessionStateListener", new SessionStateListener() {

        @Override
        public void onStateChange(SessionState arg0, SessionState arg1, Session arg2) {
        }
    });
    context.setRegistry(registry);
    component = new SmppComponent(context);
    SmppEndpoint endpoint = (SmppEndpoint) component.createEndpoint("smpp://smppclient@localhost:2775?password=password&sessionStateListener=#sessionStateListener");
    assertNotNull(endpoint.getConfiguration().getSessionStateListener());
}
Also used : SessionState(org.jsmpp.extra.SessionState) SessionStateListener(org.jsmpp.session.SessionStateListener) SimpleRegistry(org.apache.camel.impl.SimpleRegistry) Session(org.jsmpp.session.Session) Test(org.junit.Test)

Example 38 with SimpleRegistry

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

the class Sjms2EndpointConnectionSettingsTest 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 39 with SimpleRegistry

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

the class RabbitMQComponentTest method testConnectionFactoryRef.

@Test
public void testConnectionFactoryRef() throws Exception {
    SimpleRegistry registry = new SimpleRegistry();
    ConnectionFactory connectionFactoryMock = Mockito.mock(ConnectionFactory.class);
    registry.put("connectionFactoryMock", connectionFactoryMock);
    CamelContext defaultContext = new DefaultCamelContext(registry);
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("connectionFactory", "#connectionFactoryMock");
    RabbitMQEndpoint endpoint = new RabbitMQComponent(defaultContext).createEndpoint("rabbitmq:localhost/exchange", "localhost/exchange", params);
    assertSame(connectionFactoryMock, endpoint.getConnectionFactory());
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) ConnectionFactory(com.rabbitmq.client.ConnectionFactory) HashMap(java.util.HashMap) SimpleRegistry(org.apache.camel.impl.SimpleRegistry) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Test(org.junit.Test)

Example 40 with SimpleRegistry

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

the class SjmsBatchConsumerAsyncStartTest method createCamelContext.

// lets just test that any of the existing tests works
@Override
public CamelContext createCamelContext() throws Exception {
    SimpleRegistry registry = new SimpleRegistry();
    registry.put("testStrategy", new ListAggregationStrategy());
    ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(broker.getTcpConnectorUri());
    SjmsComponent sjmsComponent = new SjmsComponent();
    sjmsComponent.setConnectionFactory(connectionFactory);
    SjmsBatchComponent sjmsBatchComponent = new SjmsBatchComponent();
    sjmsBatchComponent.setConnectionFactory(connectionFactory);
    // turn on async start listener
    sjmsBatchComponent.setAsyncStartListener(true);
    CamelContext context = new DefaultCamelContext(registry);
    context.addComponent("sjms", sjmsComponent);
    context.addComponent("sjms-batch", sjmsBatchComponent);
    return context;
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) ConnectionFactory(javax.jms.ConnectionFactory) ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) SimpleRegistry(org.apache.camel.impl.SimpleRegistry) SjmsComponent(org.apache.camel.component.sjms.SjmsComponent) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

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