Search in sources :

Example 81 with CamelContext

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

the class RouteBuilderRefTest method testUsingRouteBuilderRefInCamelXml.

public void testUsingRouteBuilderRefInCamelXml() throws Exception {
    AbstractApplicationContext applicationContext = new ClassPathXmlApplicationContext("org/apache/camel/spring/config/routeBuilderRef.xml");
    CamelContext context = applicationContext.getBean("camel5", CamelContext.class);
    assertValidContext(context);
    // we're done so let's properly close the application context
    IOHelper.close(applicationContext);
}
Also used : CamelContext(org.apache.camel.CamelContext) AbstractApplicationContext(org.springframework.context.support.AbstractApplicationContext) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext)

Example 82 with CamelContext

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

the class RouteRefPropertyPlaceholderMultipleCamelContextRefsTest method testSpringTwoCamelContextDirectEndpoint.

public void testSpringTwoCamelContextDirectEndpoint() throws Exception {
    AbstractXmlApplicationContext ac = createApplicationContext();
    ac.start();
    CamelContext camel1 = ac.getBean("myCamel-1", CamelContext.class);
    CamelContext camel2 = ac.getBean("myCamel-2", CamelContext.class);
    Endpoint start1 = camel1.getEndpoint("direct:start");
    Endpoint start2 = camel2.getEndpoint("direct:start");
    assertNotSame(start1, start2);
    MockEndpoint mock1 = camel1.getEndpoint("mock:end-1", MockEndpoint.class);
    mock1.expectedBodiesReceived("Hello World");
    MockEndpoint mock2 = camel2.getEndpoint("mock:end-2", MockEndpoint.class);
    mock2.expectedBodiesReceived("Bye World");
    camel1.createProducerTemplate().sendBody("direct:start", "Hello World");
    camel2.createProducerTemplate().sendBody("direct:start", "Bye World");
    mock1.assertIsSatisfied();
    mock2.assertIsSatisfied();
    ac.stop();
}
Also used : CamelContext(org.apache.camel.CamelContext) Endpoint(org.apache.camel.Endpoint) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) AbstractXmlApplicationContext(org.springframework.context.support.AbstractXmlApplicationContext)

Example 83 with CamelContext

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

the class SpringCamelContextThreadPoolProfilesTest method testBigProfile.

public void testBigProfile() throws Exception {
    CamelContext context = getMandatoryBean(CamelContext.class, "camel-C");
    ThreadPoolProfile profile = context.getExecutorServiceManager().getThreadPoolProfile("big");
    assertEquals(50, profile.getPoolSize().intValue());
    assertEquals(100, profile.getMaxPoolSize().intValue());
    assertEquals(ThreadPoolRejectedPolicy.DiscardOldest, profile.getRejectedPolicy());
    assertEquals(null, profile.getKeepAliveTime());
    assertEquals(null, profile.getMaxQueueSize());
    // create a thread pool from big
    ExecutorService executor = context.getExecutorServiceManager().newThreadPool(this, "MyBig", "big");
    ThreadPoolExecutor tp = assertIsInstanceOf(ThreadPoolExecutor.class, executor);
    assertEquals(50, tp.getCorePoolSize());
    assertEquals(100, tp.getMaximumPoolSize());
    // should inherit default options
    assertEquals(60, tp.getKeepAliveTime(TimeUnit.SECONDS));
    assertEquals("DiscardOldest", tp.getRejectedExecutionHandler().toString());
}
Also used : CamelContext(org.apache.camel.CamelContext) ThreadPoolProfile(org.apache.camel.spi.ThreadPoolProfile) ExecutorService(java.util.concurrent.ExecutorService) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor)

Example 84 with CamelContext

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

the class SpringCamelContextThreadPoolProfilesTest method testLowProfile.

public void testLowProfile() throws Exception {
    CamelContext context = getMandatoryBean(CamelContext.class, "camel-C");
    ThreadPoolProfile profile = context.getExecutorServiceManager().getThreadPoolProfile("low");
    assertEquals(1, profile.getPoolSize().intValue());
    assertEquals(5, profile.getMaxPoolSize().intValue());
    assertEquals(null, profile.getKeepAliveTime());
    assertEquals(null, profile.getMaxQueueSize());
    assertEquals(null, profile.getRejectedPolicy());
    // create a thread pool from low
    ExecutorService executor = context.getExecutorServiceManager().newThreadPool(this, "MyLow", "low");
    ThreadPoolExecutor tp = assertIsInstanceOf(ThreadPoolExecutor.class, executor);
    assertEquals(1, tp.getCorePoolSize());
    assertEquals(5, tp.getMaximumPoolSize());
    // should inherit default options
    assertEquals(60, tp.getKeepAliveTime(TimeUnit.SECONDS));
    assertEquals("CallerRuns", tp.getRejectedExecutionHandler().toString());
}
Also used : CamelContext(org.apache.camel.CamelContext) ThreadPoolProfile(org.apache.camel.spi.ThreadPoolProfile) ExecutorService(java.util.concurrent.ExecutorService) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor)

Example 85 with CamelContext

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

the class JMXAgentPropertiesTest method testEnableUseHostIPAddress.

public void testEnableUseHostIPAddress() throws Exception {
    CamelContext ctx = createCamelContext();
    ManagementAgent agent = ctx.getManagementStrategy().getManagementAgent();
    agent.start();
    assertTrue(agent.getUseHostIPAddress());
}
Also used : CamelContext(org.apache.camel.CamelContext) ManagementAgent(org.apache.camel.spi.ManagementAgent)

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