Search in sources :

Example 36 with DefaultCamelContext

use of org.apache.camel.impl.DefaultCamelContext in project camel by apache.

the class DefaultExchangeFormatterTest method setUp.

@Before
public void setUp() {
    camelContext = new DefaultCamelContext();
    Message message = new DefaultMessage();
    message.setBody("This is the message body");
    exchange = new DefaultExchange(camelContext);
    exchange.setIn(message);
    exchangeFormatter = new DefaultExchangeFormatter();
}
Also used : DefaultMessage(org.apache.camel.impl.DefaultMessage) DefaultExchange(org.apache.camel.impl.DefaultExchange) Message(org.apache.camel.Message) DefaultMessage(org.apache.camel.impl.DefaultMessage) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Before(org.junit.Before)

Example 37 with DefaultCamelContext

use of org.apache.camel.impl.DefaultCamelContext in project camel by apache.

the class RouteServicesStartupOrderTest method testRouteServiceStartupOrder.

public void testRouteServiceStartupOrder() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMessageCount(1);
    template.sendBody("direct:start", "Hello World");
    assertMockEndpointsSatisfied();
    // assert correct order
    DefaultCamelContext dcc = (DefaultCamelContext) context;
    List<RouteStartupOrder> order = dcc.getRouteStartupOrder();
    assertEquals(4, order.size());
    assertEquals("seda://foo", order.get(0).getRoute().getEndpoint().getEndpointUri());
    assertEquals("direct://start", order.get(1).getRoute().getEndpoint().getEndpointUri());
    assertEquals("seda://bar", order.get(2).getRoute().getEndpoint().getEndpointUri());
    assertEquals("direct://bar", order.get(3).getRoute().getEndpoint().getEndpointUri());
    // assert route service was started in order as well
    assertEquals("2143", startOrder);
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) RouteStartupOrder(org.apache.camel.spi.RouteStartupOrder) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Example 38 with DefaultCamelContext

use of org.apache.camel.impl.DefaultCamelContext in project camel by apache.

the class RouteShutdownNotReverseOrderTest method testRouteShutdownNotReverseOrder.

public void testRouteShutdownNotReverseOrder() throws Exception {
    // flip to not reverse
    context.getShutdownStrategy().setShutdownRoutesInReverseOrder(false);
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMessageCount(1);
    template.sendBody("direct:bar", "Hello World");
    assertMockEndpointsSatisfied();
    // assert correct startup order
    DefaultCamelContext dcc = (DefaultCamelContext) context;
    List<RouteStartupOrder> order = dcc.getRouteStartupOrder();
    assertEquals(2, order.size());
    assertEquals("direct://bar", order.get(0).getRoute().getEndpoint().getEndpointUri());
    assertEquals("direct://foo", order.get(1).getRoute().getEndpoint().getEndpointUri());
    // assert correct shutdown order
    context.stop();
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) RouteStartupOrder(org.apache.camel.spi.RouteStartupOrder) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Example 39 with DefaultCamelContext

use of org.apache.camel.impl.DefaultCamelContext in project camel by apache.

the class RouteShutdownReverseOrderTest method testRouteShutdownReverseOrder.

public void testRouteShutdownReverseOrder() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMessageCount(1);
    template.sendBody("direct:bar", "Hello World");
    assertMockEndpointsSatisfied();
    // assert correct startup order
    DefaultCamelContext dcc = (DefaultCamelContext) context;
    List<RouteStartupOrder> order = dcc.getRouteStartupOrder();
    assertEquals(2, order.size());
    assertEquals("direct://bar", order.get(0).getRoute().getEndpoint().getEndpointUri());
    assertEquals("direct://foo", order.get(1).getRoute().getEndpoint().getEndpointUri());
    // assert correct shutdown order
    context.stop();
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) RouteStartupOrder(org.apache.camel.spi.RouteStartupOrder) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Example 40 with DefaultCamelContext

use of org.apache.camel.impl.DefaultCamelContext in project camel by apache.

the class RouteStartupOrderSimpleTest method testRouteStartupOrder.

public void testRouteStartupOrder() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMessageCount(1);
    template.sendBody("direct:start", "Hello World");
    assertMockEndpointsSatisfied();
    // assert correct order
    DefaultCamelContext dcc = (DefaultCamelContext) context;
    List<RouteStartupOrder> order = dcc.getRouteStartupOrder();
    assertEquals(2, order.size());
    assertEquals("direct://start", order.get(0).getRoute().getEndpoint().getEndpointUri());
    assertEquals("seda://foo", order.get(1).getRoute().getEndpoint().getEndpointUri());
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) RouteStartupOrder(org.apache.camel.spi.RouteStartupOrder) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Aggregations

DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)474 CamelContext (org.apache.camel.CamelContext)206 Test (org.junit.Test)183 DefaultExchange (org.apache.camel.impl.DefaultExchange)128 RouteBuilder (org.apache.camel.builder.RouteBuilder)101 Exchange (org.apache.camel.Exchange)91 Before (org.junit.Before)70 SimpleRegistry (org.apache.camel.impl.SimpleRegistry)61 RegisteredDelivery (org.jsmpp.bean.RegisteredDelivery)39 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)38 ESMClass (org.jsmpp.bean.ESMClass)30 ProducerTemplate (org.apache.camel.ProducerTemplate)27 CountDownLatch (java.util.concurrent.CountDownLatch)15 Endpoint (org.apache.camel.Endpoint)13 FailedToCreateRouteException (org.apache.camel.FailedToCreateRouteException)13 Processor (org.apache.camel.Processor)12 RouteStartupOrder (org.apache.camel.spi.RouteStartupOrder)12 Address (org.jsmpp.bean.Address)11 SubmitMultiResult (org.jsmpp.bean.SubmitMultiResult)11 Date (java.util.Date)10