Search in sources :

Example 21 with CamelContext

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

the class SmppComponentTest method createEndpointStringStringMapShouldReturnASmppEndpoint.

@Test
public void createEndpointStringStringMapShouldReturnASmppEndpoint() throws Exception {
    CamelContext context = new DefaultCamelContext();
    component = new SmppComponent(context);
    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put("password", "secret");
    Endpoint endpoint = component.createEndpoint("smpp://smppclient@localhost:2775", "?password=secret", parameters);
    SmppEndpoint smppEndpoint = (SmppEndpoint) endpoint;
    assertEquals("smpp://smppclient@localhost:2775", smppEndpoint.getEndpointUri());
    assertEquals("smpp://smppclient@localhost:2775", smppEndpoint.getEndpointKey());
    assertSame(component, smppEndpoint.getComponent());
    assertNotNull(smppEndpoint.getConfiguration());
    assertEquals("secret", smppEndpoint.getConfiguration().getPassword());
    assertEquals("smpp://smppclient@localhost:2775", smppEndpoint.getConnectionString());
    assertEquals(ExchangePattern.InOnly, smppEndpoint.getExchangePattern());
    assertTrue(smppEndpoint.getBinding() instanceof SmppBinding);
    assertNotNull(smppEndpoint.getCamelContext());
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Endpoint(org.apache.camel.Endpoint) HashMap(java.util.HashMap) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Test(org.junit.Test)

Example 22 with CamelContext

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

the class SmppComponentTest method constructorCamelContextShouldSetTheContext.

@Test
public void constructorCamelContextShouldSetTheContext() {
    CamelContext context = new DefaultCamelContext();
    component = new SmppComponent(context);
    assertSame(context, component.getCamelContext());
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Test(org.junit.Test)

Example 23 with CamelContext

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

the class CamelConfiguration method camelContext.

/**
     * Get's the {@link CamelContext} to be used.
     */
@Bean
public CamelContext camelContext() throws Exception {
    CamelContext camelContext = createCamelContext();
    SpringCamelContext.setNoStart(true);
    setupCamelContext(camelContext);
    return camelContext;
}
Also used : CamelContext(org.apache.camel.CamelContext) SpringCamelContext(org.apache.camel.spring.SpringCamelContext) Bean(org.springframework.context.annotation.Bean)

Example 24 with CamelContext

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

the class RoutesCollector method onApplicationEvent.

// Overridden
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
    ApplicationContext applicationContext = event.getApplicationContext();
    // only listen to context refresh of "my" applicationContext
    if (this.applicationContext.equals(applicationContext)) {
        CamelContext camelContext = event.getApplicationContext().getBean(CamelContext.class);
        // only add and start Camel if its stopped (initial state)
        if (camelContext.getStatus().isStopped()) {
            LOG.debug("Post-processing CamelContext bean: {}", camelContext.getName());
            for (RoutesBuilder routesBuilder : configuration.routes()) {
                // filter out abstract classes
                boolean abs = Modifier.isAbstract(routesBuilder.getClass().getModifiers());
                if (!abs) {
                    try {
                        LOG.debug("Injecting following route into the CamelContext: {}", routesBuilder);
                        camelContext.addRoutes(routesBuilder);
                    } catch (Exception e) {
                        throw new CamelSpringJavaconfigInitializationException(e);
                    }
                }
            }
            try {
                boolean skip = "true".equalsIgnoreCase(System.getProperty("skipStartingCamelContext"));
                if (skip) {
                    LOG.info("Skipping starting CamelContext(s) as system property skipStartingCamelContext is set to be true.");
                } else {
                    // start camel
                    camelContext.start();
                }
            } catch (Exception e) {
                throw new CamelSpringJavaconfigInitializationException(e);
            }
        }
    } else {
        LOG.debug("Ignore ContextRefreshedEvent: {}", event);
    }
}
Also used : CamelContext(org.apache.camel.CamelContext) ApplicationContext(org.springframework.context.ApplicationContext) RoutesBuilder(org.apache.camel.RoutesBuilder)

Example 25 with CamelContext

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

the class MainTest method testOptionBP.

@Test
public void testOptionBP() throws Exception {
    CamelContext context = createCamelContext(new String[] { "-bp", "org.apache.camel.spring.javaconfig.config" });
    context.start();
    runTests(context);
    context.stop();
}
Also used : CamelContext(org.apache.camel.CamelContext) SpringCamelContext(org.apache.camel.spring.SpringCamelContext) Test(org.junit.Test)

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