Search in sources :

Example 1 with Book

use of org.apache.camel.component.routebox.demo.Book in project camel by apache.

the class RouteboxDefaultContextAndRouteBuilderTest method testRouteboxUsingDefaultContextAndRouteBuilder.

@Test
public void testRouteboxUsingDefaultContextAndRouteBuilder() 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 ---> testRouteboxUsingDefaultContextAndRouteBuilder()");
    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 ---> testRouteboxUsingDefaultContextAndRouteBuilder()");
    context.stop();
}
Also used : SimpleRouteBuilder(org.apache.camel.component.routebox.demo.SimpleRouteBuilder) RouteBuilder(org.apache.camel.builder.RouteBuilder) Book(org.apache.camel.component.routebox.demo.Book) DefaultProducerTemplate(org.apache.camel.impl.DefaultProducerTemplate) Test(org.junit.Test)

Example 2 with Book

use of org.apache.camel.component.routebox.demo.Book 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();
}
Also used : SimpleRouteBuilder(org.apache.camel.component.routebox.demo.SimpleRouteBuilder) RouteBuilder(org.apache.camel.builder.RouteBuilder) Book(org.apache.camel.component.routebox.demo.Book) DefaultProducerTemplate(org.apache.camel.impl.DefaultProducerTemplate) Test(org.junit.Test)

Example 3 with Book

use of org.apache.camel.component.routebox.demo.Book 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();
}
Also used : SimpleRouteBuilder(org.apache.camel.component.routebox.demo.SimpleRouteBuilder) RouteBuilder(org.apache.camel.builder.RouteBuilder) Book(org.apache.camel.component.routebox.demo.Book) DefaultProducerTemplate(org.apache.camel.impl.DefaultProducerTemplate) Test(org.junit.Test)

Example 4 with Book

use of org.apache.camel.component.routebox.demo.Book 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();
}
Also used : SimpleRouteBuilder(org.apache.camel.component.routebox.demo.SimpleRouteBuilder) RouteBuilder(org.apache.camel.builder.RouteBuilder) Book(org.apache.camel.component.routebox.demo.Book) DefaultProducerTemplate(org.apache.camel.impl.DefaultProducerTemplate) Test(org.junit.Test)

Example 5 with Book

use of org.apache.camel.component.routebox.demo.Book 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();
}
Also used : SimpleRouteBuilder(org.apache.camel.component.routebox.demo.SimpleRouteBuilder) RouteBuilder(org.apache.camel.builder.RouteBuilder) Book(org.apache.camel.component.routebox.demo.Book) DefaultProducerTemplate(org.apache.camel.impl.DefaultProducerTemplate) Test(org.junit.Test)

Aggregations

RouteBuilder (org.apache.camel.builder.RouteBuilder)5 Book (org.apache.camel.component.routebox.demo.Book)5 SimpleRouteBuilder (org.apache.camel.component.routebox.demo.SimpleRouteBuilder)5 DefaultProducerTemplate (org.apache.camel.impl.DefaultProducerTemplate)5 Test (org.junit.Test)5