Search in sources :

Example 91 with ProducerTemplate

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

the class MainTest method runTests.

private void runTests(CamelContext context) throws Exception {
    MockEndpoint resultEndpoint = context.getEndpoint("mock:result", MockEndpoint.class);
    ProducerTemplate template = context.createProducerTemplate();
    String expectedBody = "<matched/>";
    resultEndpoint.expectedBodiesReceived(expectedBody);
    template.sendBodyAndHeader("direct:start", expectedBody, "foo", "bar");
    resultEndpoint.assertIsSatisfied();
    resultEndpoint.reset();
    resultEndpoint.expectedMessageCount(0);
    template.sendBodyAndHeader("direct:start", "<notMatched/>", "foo", "notMatchedHeaderValue");
    resultEndpoint.assertIsSatisfied();
}
Also used : ProducerTemplate(org.apache.camel.ProducerTemplate) MockEndpoint(org.apache.camel.component.mock.MockEndpoint)

Example 92 with ProducerTemplate

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

the class CamelRestTest method test.

@Test
public void test() throws Exception {
    ProducerTemplate template = context.createProducerTemplate();
    String result = template.requestBody("seda:get-say-hello", "test", String.class);
    Assert.assertEquals("Hello World", result);
}
Also used : ProducerTemplate(org.apache.camel.ProducerTemplate) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 93 with ProducerTemplate

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

the class CamelSpringBootTemplateShutdownTest method setupApplicationContext.

@Before
public void setupApplicationContext() {
    applicationContext = new AnnotationConfigApplicationContext(CamelAutoConfiguration.class);
    camelContext = applicationContext.getBean(CamelContext.class);
    consumerTemplate = applicationContext.getBean(ConsumerTemplate.class);
    producerTemplate = applicationContext.getBean(ProducerTemplate.class);
}
Also used : CamelContext(org.apache.camel.CamelContext) ConsumerTemplate(org.apache.camel.ConsumerTemplate) ProducerTemplate(org.apache.camel.ProducerTemplate) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) Before(org.junit.Before)

Example 94 with ProducerTemplate

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

the class CamelHBaseFilterTest method testPutMultiRowsAndScanWithFilters.

@Test
public void testPutMultiRowsAndScanWithFilters() throws Exception {
    if (systemReady) {
        putMultipleRows();
        ProducerTemplate template = context.createProducerTemplate();
        Endpoint endpoint = context.getEndpoint("direct:scan");
        Exchange exchange = endpoint.createExchange(ExchangePattern.InOut);
        exchange.getIn().setHeader(HBaseAttribute.HBASE_FAMILY.asHeader(), family[0]);
        exchange.getIn().setHeader(HBaseAttribute.HBASE_QUALIFIER.asHeader(), column[0][0]);
        exchange.getIn().setHeader(HBaseAttribute.HBASE_VALUE.asHeader(), body[0][0][0]);
        Exchange resp = template.send(endpoint, exchange);
        Message out = resp.getOut();
        assertTrue("two first keys returned", out.getHeaders().containsValue(body[0][0][0]) && out.getHeaders().containsValue(body[1][0][0]) && !out.getHeaders().containsValue(body[2][0][0]));
    }
}
Also used : Exchange(org.apache.camel.Exchange) ProducerTemplate(org.apache.camel.ProducerTemplate) Endpoint(org.apache.camel.Endpoint) Message(org.apache.camel.Message) Test(org.junit.Test)

Example 95 with ProducerTemplate

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

the class JmxDisabledTest 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