Search in sources :

Example 86 with CamelContext

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

the class MainDummyTest method testMain.

public void testMain() throws Exception {
    Main main = new Main();
    main.start();
    // should also be a Camel
    CamelContext camel = main.getApplicationContext().getBean(CamelContext.class);
    assertNotNull("Camel should be in Spring", camel);
    DummyBean dummy = (DummyBean) main.getApplicationContext().getBean("dummy");
    assertNotNull(dummy);
    assertEquals("John Doe", dummy.getName());
    main.stop();
}
Also used : CamelContext(org.apache.camel.CamelContext)

Example 87 with CamelContext

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

the class MainTest method testMain.

public void testMain() throws Exception {
    // lets make a simple route
    Main main = new Main();
    main.addRouteBuilder(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("file://src/test/data?noop=true").process(new MyProcessor()).to("mock:results");
        }
    });
    main.start();
    List<CamelContext> contextList = main.getCamelContexts();
    assertNotNull(contextList);
    assertEquals("size", 1, contextList.size());
    CamelContext camelContext = contextList.get(0);
    MockEndpoint endpoint = camelContext.getEndpoint("mock:results", MockEndpoint.class);
    // in case we add more files in src/test/data
    endpoint.expectedMinimumMessageCount(2);
    endpoint.assertIsSatisfied();
    List<Exchange> list = endpoint.getReceivedExchanges();
    LOG.debug("Received: " + list);
    main.stop();
}
Also used : CamelContext(org.apache.camel.CamelContext) Exchange(org.apache.camel.Exchange) RouteBuilder(org.apache.camel.builder.RouteBuilder) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) MyProcessor(org.apache.camel.spring.example.MyProcessor)

Example 88 with CamelContext

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

the class DualCamelContextEndpointOutsideTest method testDualCamelContextEndpoint.

public void testDualCamelContextEndpoint() throws Exception {
    CamelContext camelA = applicationContext.getBean("camel-A", CamelContext.class);
    assertNotNull(camelA);
    CamelContext camelB = applicationContext.getBean("camel-B", CamelContext.class);
    assertNotNull(camelB);
    MockEndpoint mockA = camelA.getEndpoint("mock:mock1", MockEndpoint.class);
    mockA.expectedBodiesReceived("Hello A");
    MockEndpoint mockB = camelB.getEndpoint("mock:mock2", MockEndpoint.class);
    mockB.expectedBodiesReceived("Hello B");
    ProducerTemplate producer1 = camelA.createProducerTemplate();
    producer1.sendBody("direct:start1", "Hello A");
    ProducerTemplate producer2 = camelB.createProducerTemplate();
    producer2.sendBody("direct:start2", "Hello B");
    // make sure we properly stop the services we created
    ServiceHelper.stopServices(producer1, producer2);
    mockA.assertIsSatisfied();
    mockB.assertIsSatisfied();
}
Also used : CamelContext(org.apache.camel.CamelContext) ProducerTemplate(org.apache.camel.ProducerTemplate) MockEndpoint(org.apache.camel.component.mock.MockEndpoint)

Example 89 with CamelContext

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

the class SpringTestSupport method createCamelContext.

@SuppressWarnings("deprecation")
@Override
protected CamelContext createCamelContext() throws Exception {
    CamelContext context = SpringCamelContext.springCamelContext(applicationContext);
    context.setLazyLoadTypeConverters(isLazyLoadingTypeConverter());
    return context;
}
Also used : CamelContext(org.apache.camel.CamelContext)

Example 90 with CamelContext

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

the class SpringRemotingRouteTest method testBeanRoutes.

public void testBeanRoutes() throws Exception {
    AbstractXmlApplicationContext applicationContext = createApplicationContext();
    CamelContext camelContext = SpringCamelContext.springCamelContext(applicationContext);
    // START SNIPPET: invoke
    ISay proxy = applicationContext.getBean("sayProxy", ISay.class);
    String rc = proxy.say();
    assertEquals("Hello", rc);
    // END SNIPPET: invoke
    camelContext.stop();
    IOHelper.close(applicationContext);
}
Also used : CamelContext(org.apache.camel.CamelContext) SpringCamelContext(org.apache.camel.spring.SpringCamelContext) AbstractXmlApplicationContext(org.springframework.context.support.AbstractXmlApplicationContext)

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