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();
}
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);
}
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);
}
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]));
}
}
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();
}
Aggregations