Search in sources :

Example 96 with ProducerTemplate

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

the class LifecycleTest method testCamelContext.

@Test
public void testCamelContext() throws Exception {
    CamelContext context = getCamelContext();
    assertNotNull(context);
    assertEquals("MyCamel", context.getName());
    ProducerTemplate template = context.createProducerTemplate();
    MockEndpoint mock = context.getEndpoint("mock:foo", MockEndpoint.class);
    mock.expectedBodiesReceived("Hello World");
    template.sendBody("seda:foo", "World");
    mock.assertIsSatisfied();
    template.stop();
}
Also used : CamelContext(org.apache.camel.CamelContext) ProducerTemplate(org.apache.camel.ProducerTemplate) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 97 with ProducerTemplate

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

the class MultipleRoutesTest method testCamelContext.

@Test
public void testCamelContext() throws Exception {
    CamelContext context = getCamelContext();
    assertNotNull(context);
    assertEquals("MyCamel", context.getName());
    assertEquals(2, context.getRoutes().size());
    ProducerTemplate template = context.createProducerTemplate();
    MockEndpoint mock = context.getEndpoint("mock:foo", MockEndpoint.class);
    mock.expectedMessageCount(1);
    MockEndpoint mock2 = context.getEndpoint("mock:bar", MockEndpoint.class);
    mock2.expectedMessageCount(1);
    template.sendBody("seda:foo", "Hello World");
    template.sendBody("direct:bar", "Bye World");
    mock.assertIsSatisfied();
    mock2.assertIsSatisfied();
    template.stop();
}
Also used : CamelContext(org.apache.camel.CamelContext) ProducerTemplate(org.apache.camel.ProducerTemplate) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 98 with ProducerTemplate

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

the class RoutesFromPackageScanTest method testRoutes.

@Test
public void testRoutes() throws Exception {
    CamelContext context = getCamelContext();
    assertNotNull(context);
    assertEquals("MyCamel", context.getName());
    assertEquals(2, context.getRoutes().size());
    assertNotNull(context.getRoute("foo"));
    assertNotNull(context.getRoute("bar"));
    ProducerTemplate template = context.createProducerTemplate();
    MockEndpoint mock = context.getEndpoint("mock:foo", MockEndpoint.class);
    mock.expectedMessageCount(1);
    MockEndpoint mock2 = context.getEndpoint("mock:bar", MockEndpoint.class);
    mock2.expectedMessageCount(1);
    template.sendBody("direct:foo", "Hello World");
    template.sendBody("direct:bar", "Bye World");
    mock.assertIsSatisfied();
    mock2.assertIsSatisfied();
    template.stop();
}
Also used : CamelContext(org.apache.camel.CamelContext) ProducerTemplate(org.apache.camel.ProducerTemplate) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 99 with ProducerTemplate

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

the class RoutesFromXmlTest method testRoutes.

@Test
public void testRoutes() throws Exception {
    CamelContext context = getCamelContext();
    assertNotNull(context);
    assertEquals("MyCamel", context.getName());
    assertEquals(2, context.getRoutes().size());
    ProducerTemplate template = context.createProducerTemplate();
    MockEndpoint mock = context.getEndpoint("mock:foo", MockEndpoint.class);
    mock.expectedMessageCount(1);
    MockEndpoint mock2 = context.getEndpoint("mock:bar", MockEndpoint.class);
    mock2.expectedMessageCount(1);
    template.sendBody("direct:foo", "Hello World");
    template.sendBody("direct:bar", "Bye World");
    mock.assertIsSatisfied();
    mock2.assertIsSatisfied();
    template.stop();
}
Also used : CamelContext(org.apache.camel.CamelContext) ProducerTemplate(org.apache.camel.ProducerTemplate) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 100 with ProducerTemplate

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

the class SingleRouteTest method testCamelContext.

@Test
public void testCamelContext() throws Exception {
    CamelContext context = getCamelContext();
    assertNotNull(context);
    assertEquals("MyCamel", context.getName());
    ProducerTemplate template = context.createProducerTemplate();
    MockEndpoint mock = context.getEndpoint("mock:foo", MockEndpoint.class);
    mock.expectedMessageCount(1);
    template.sendBody("seda:foo", "Hello World");
    mock.assertIsSatisfied();
    template.stop();
}
Also used : CamelContext(org.apache.camel.CamelContext) ProducerTemplate(org.apache.camel.ProducerTemplate) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Aggregations

ProducerTemplate (org.apache.camel.ProducerTemplate)130 Test (org.junit.Test)58 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)53 CamelContext (org.apache.camel.CamelContext)48 Exchange (org.apache.camel.Exchange)36 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)27 Deployment (org.activiti.engine.test.Deployment)16 RouteBuilder (org.apache.camel.builder.RouteBuilder)16 Processor (org.apache.camel.Processor)8 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)8 HashMap (java.util.HashMap)7 Task (org.activiti.engine.task.Task)7 Endpoint (org.apache.camel.Endpoint)7 File (java.io.File)6 ArrayList (java.util.ArrayList)5 Message (org.apache.camel.Message)4 List (java.util.List)3 ExecutorService (java.util.concurrent.ExecutorService)3 HistoricVariableInstance (org.activiti.engine.history.HistoricVariableInstance)3 ConsumerTemplate (org.apache.camel.ConsumerTemplate)3