use of org.apache.camel.ProducerTemplate in project camel by apache.
the class JettyJmsTwowayTest method testSendingRequest.
@Test
public void testSendingRequest() throws Exception {
assertNotNull("the camelContext should not be null", camelContext);
ProducerTemplate template = camelContext.createProducerTemplate();
Exchange exchange = template.send(URL, new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.getIn().setBody("<hello>Willem</hello>");
exchange.getIn().setHeader("Operation", "greetMe");
}
});
assertEquals("get result ", "<response><hello>Willem</hello></response>", exchange.getOut().getBody(String.class));
template.stop();
}
use of org.apache.camel.ProducerTemplate in project camel by apache.
the class JettyMulticastJmsFileTest method testJettyMulticastJmsFile.
@Test
public void testJettyMulticastJmsFile() throws Exception {
TestSupport.deleteDirectory("target/jetty");
ProducerTemplate template = camelContext.createProducerTemplate();
String out = template.requestBody(URL, "Hello World", String.class);
assertEquals("Bye World", out);
template.stop();
ConsumerTemplate consumer = camelContext.createConsumerTemplate();
String in = consumer.receiveBody("jms:queue:foo", 5000, String.class);
assertEquals("Hello World", in);
String in2 = consumer.receiveBody("file://target/jetty?noop=true&readLock=none", 5000, String.class);
assertEquals("Hello World", in2);
consumer.stop();
}
use of org.apache.camel.ProducerTemplate in project camel by apache.
the class ContainerWideInterceptorTest method testTwo.
public void testTwo() throws Exception {
int start = myInterceptor.getCount();
MockEndpoint result = camel2.getEndpoint("mock:result", MockEndpoint.class);
result.expectedBodiesReceived("Bye World");
ProducerTemplate template = camel2.createProducerTemplate();
template.start();
template.sendBody("direct:two", "Bye World");
template.stop();
result.assertIsSatisfied();
// lets see if the counter is +2 since last (has 2 steps in the route)
int delta = myInterceptor.getCount() - start;
assertEquals("Should have been counted +2", 2, delta);
}
use of org.apache.camel.ProducerTemplate in project camel by apache.
the class SignatureAlgorithmTest method doSignatureRouteTest.
public Exchange doSignatureRouteTest(RouteBuilder builder, Exchange e, Map<String, Object> headers) throws Exception {
CamelContext context = new DefaultCamelContext();
try {
context.addRoutes(builder);
context.start();
MockEndpoint mock = context.getEndpoint("mock:result", MockEndpoint.class);
mock.setExpectedMessageCount(1);
ProducerTemplate template = context.createProducerTemplate();
if (e != null) {
template.send("direct:in", e);
} else {
template.sendBodyAndHeaders("direct:in", payload, headers);
}
assertMockEndpointsSatisfied();
return mock.getReceivedExchanges().get(0);
} finally {
context.stop();
}
}
use of org.apache.camel.ProducerTemplate in project camel by apache.
the class SignatureDigestMethodTest method doSignatureRouteTest.
public Exchange doSignatureRouteTest(RouteBuilder builder, Exchange e, Map<String, Object> headers) throws Exception {
CamelContext context = new DefaultCamelContext();
try {
context.addRoutes(builder);
context.start();
MockEndpoint mock = context.getEndpoint("mock:result", MockEndpoint.class);
mock.setExpectedMessageCount(1);
ProducerTemplate template = context.createProducerTemplate();
if (e != null) {
template.send("direct:in", e);
} else {
template.sendBodyAndHeaders("direct:in", payload, headers);
}
assertMockEndpointsSatisfied();
return mock.getReceivedExchanges().get(0);
} finally {
context.stop();
}
}
Aggregations