use of org.apache.camel.impl.DefaultProducerTemplate in project camel by apache.
the class CamelContextAwareTest method testCamelTemplates.
public void testCamelTemplates() throws Exception {
DefaultProducerTemplate producer1 = getMandatoryBean(DefaultProducerTemplate.class, "producer1");
assertEquals("Inject a wrong camel context", producer1.getCamelContext().getName(), "camel1");
DefaultProducerTemplate producer2 = getMandatoryBean(DefaultProducerTemplate.class, "producer2");
assertEquals("Inject a wrong camel context", producer2.getCamelContext().getName(), "camel2");
DefaultConsumerTemplate consumer = getMandatoryBean(DefaultConsumerTemplate.class, "consumer");
assertEquals("Inject a wrong camel context", consumer.getCamelContext().getName(), "camel2");
}
use of org.apache.camel.impl.DefaultProducerTemplate in project camel by apache.
the class RouteboxDirectProducerOnlyTest method testRouteboxDirectProducerOnlyRequests.
@Test
public void testRouteboxDirectProducerOnlyRequests() throws Exception {
template = new DefaultProducerTemplate(context);
template.start();
context.addRoutes(new RouteBuilder() {
public void configure() {
from("direct:start").to(routeboxUri).to("log:Routes operation performed?showAll=true");
}
});
context.start();
LOG.debug("Beginning Test ---> testRouteboxDirectSyncRequests()");
Book book = new Book("Sir Arthur Conan Doyle", "The Adventures of Sherlock Holmes");
String response = sendAddToCatalogRequest(template, "direct:start", "addToCatalog", book);
assertEquals("Book with Author " + book.getAuthor() + " and title " + book.getTitle() + " added to Catalog", response);
//Thread.sleep(2000);
book = sendFindBookRequest(template, "direct:start", "findBook", "Sir Arthur Conan Doyle");
LOG.debug("Received book with author {} and title {}", book.getAuthor(), book.getTitle());
assertEquals("The Adventures of Sherlock Holmes", book.getTitle());
LOG.debug("Completed Test ---> testRouteboxDirectSyncRequests()");
context.stop();
}
use of org.apache.camel.impl.DefaultProducerTemplate in project camel by apache.
the class RouteboxDirectTest method testRouteboxDirectAsyncRequests.
@Test
public void testRouteboxDirectAsyncRequests() throws Exception {
template = new DefaultProducerTemplate(context);
template.start();
context.addRoutes(new RouteBuilder() {
public void configure() {
from(routeboxUri).to("log:Routes operation performed?showAll=true");
}
});
context.start();
LOG.debug("Beginning Test ---> testRouteboxDirectAsyncRequests()");
Book book = new Book("Sir Arthur Conan Doyle", "The Adventures of Sherlock Holmes");
String response = sendAddToCatalogRequest(template, routeboxUri, "addToCatalog", book);
assertEquals("Book with Author " + book.getAuthor() + " and title " + book.getTitle() + " added to Catalog", response);
// Wait for 2 seconds before a follow-on request if the requests are sent in async mode
// to allow the earlier request to take effect
//Thread.sleep(2000);
book = sendFindBookRequest(template, routeboxUri, "findBook", "Sir Arthur Conan Doyle");
LOG.debug("Received book with author {} and title {}", book.getAuthor(), book.getTitle());
assertEquals("The Adventures of Sherlock Holmes", book.getTitle());
LOG.debug("Completed Test ---> testRouteboxDirectAsyncRequests()");
context.stop();
}
use of org.apache.camel.impl.DefaultProducerTemplate in project camel by apache.
the class RouteboxDispatchMapTest method testRouteboxUsingDispatchMap.
@Test
public void testRouteboxUsingDispatchMap() throws Exception {
template = new DefaultProducerTemplate(context);
template.start();
context.addRoutes(new RouteBuilder() {
public void configure() {
from(routeboxUri).to("log:Routes operation performed?showAll=true");
}
});
context.start();
LOG.debug("Beginning Test ---> testRouteboxUsingDispatchMap()");
Book book = new Book("Sir Arthur Conan Doyle", "The Adventures of Sherlock Holmes");
String response = sendAddToCatalogRequest(template, routeboxUri, "addToCatalog", book);
assertEquals("Book with Author " + book.getAuthor() + " and title " + book.getTitle() + " added to Catalog", response);
book = sendFindBookRequest(template, routeboxUri, "findBook", "Sir Arthur Conan Doyle");
LOG.debug("Received book with author {} and title {}", book.getAuthor(), book.getTitle());
assertEquals("The Adventures of Sherlock Holmes", book.getTitle());
LOG.debug("Completed Test ---> testRouteboxUsingDispatchMap()");
context.stop();
}
use of org.apache.camel.impl.DefaultProducerTemplate in project camel by apache.
the class RouteboxSedaTest method testRouteboxSedaAsyncRequests.
@Test
public void testRouteboxSedaAsyncRequests() throws Exception {
template = new DefaultProducerTemplate(context);
template.start();
context.addRoutes(new RouteBuilder() {
public void configure() {
from(routeboxUri).to("log:Routes operation performed?showAll=true");
}
});
context.start();
LOG.debug("Beginning Test ---> testRouteboxSedaAsyncRequests()");
Book book = new Book("Sir Arthur Conan Doyle", "The Adventures of Sherlock Holmes");
String response = sendAddToCatalogRequest(template, routeboxUri, "addToCatalog", book);
assertEquals("Book with Author " + book.getAuthor() + " and title " + book.getTitle() + " added to Catalog", response);
// Wait for 2 seconds before a follow-on request if the requests are sent in async mode
// to allow the earlier request to take effect
//Thread.sleep(2000);
book = sendFindBookRequest(template, routeboxUri, "findBook", "Sir Arthur Conan Doyle");
LOG.debug("Received book with author {} and title {}", book.getAuthor(), book.getTitle());
assertEquals("The Adventures of Sherlock Holmes", book.getTitle());
LOG.debug("Completed Test ---> testRouteboxSedaAsyncRequests()");
context.stop();
}
Aggregations