use of org.apache.camel.model.RouteDefinition in project camel by apache.
the class CamelContextAddRouteDefinitionsFromXmlTest method testAddRouteDefinitionsFromXml3.
public void testAddRouteDefinitionsFromXml3() throws Exception {
RouteDefinition route = loadRoute("route3.xml");
assertNotNull(route);
assertEquals("foo", route.getId());
assertEquals(0, context.getRoutes().size());
context.addRouteDefinition(route);
assertEquals(1, context.getRoutes().size());
assertTrue("Route should be started", context.getRouteStatus("foo").isStarted());
getMockEndpoint("mock:foo").whenExchangeReceived(2, new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.setException(new IllegalArgumentException("Damn"));
}
});
getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
getMockEndpoint("mock:handled").expectedBodiesReceived("Bye World");
template.sendBody("direct:start", "Hello World");
template.sendBody("direct:start", "Bye World");
assertMockEndpointsSatisfied();
}
use of org.apache.camel.model.RouteDefinition in project camel by apache.
the class CamelContextAddRouteDefinitionsFromXmlTest method testAddRouteDefinitionsFromXml.
public void testAddRouteDefinitionsFromXml() throws Exception {
RouteDefinition route = loadRoute("route1.xml");
assertNotNull(route);
assertEquals("foo", route.getId());
assertEquals(0, context.getRoutes().size());
context.addRouteDefinition(route);
assertEquals(1, context.getRoutes().size());
assertTrue("Route should be started", context.getRouteStatus("foo").isStarted());
getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
template.sendBody("direct:start", "Hello World");
assertMockEndpointsSatisfied();
}
use of org.apache.camel.model.RouteDefinition in project camel by apache.
the class CamelContextAddRouteDefinitionsFromXmlTest method testRemoveRouteDefinitionsFromXml.
public void testRemoveRouteDefinitionsFromXml() throws Exception {
RouteDefinition route = loadRoute("route1.xml");
assertNotNull(route);
assertEquals("foo", route.getId());
assertEquals(0, context.getRoutes().size());
context.addRouteDefinition(route);
assertEquals(1, context.getRouteDefinitions().size());
assertEquals(1, context.getRoutes().size());
assertTrue("Route should be started", context.getRouteStatus("foo").isStarted());
context.removeRouteDefinition(route);
assertEquals(0, context.getRoutes().size());
assertNull(context.getRouteStatus("foo"));
assertEquals(0, context.getRouteDefinitions().size());
}
use of org.apache.camel.model.RouteDefinition in project camel by apache.
the class CamelContextAddRouteDefinitionsFromXmlTest method testAddRouteDefinitionsFromXmlIsPrepared.
public void testAddRouteDefinitionsFromXmlIsPrepared() throws Exception {
RouteDefinition route = loadRoute("route1.xml");
assertNotNull(route);
assertEquals("foo", route.getId());
assertEquals(0, context.getRoutes().size());
context.addRouteDefinition(route);
assertEquals(1, context.getRoutes().size());
assertTrue("Route should be started", context.getRouteStatus("foo").isStarted());
// should be prepared, check parents has been set
assertNotNull("Parent should be set on outputs");
route = context.getRouteDefinition("foo");
for (ProcessorDefinition<?> output : route.getOutputs()) {
assertNotNull("Parent should be set on output", output.getParent());
assertEquals(route, output.getParent());
}
}
use of org.apache.camel.model.RouteDefinition in project camel by apache.
the class CamelContextAddRouteDefinitionsFromXmlTest method testAddRouteDefinitionsAfterExceptionFromXml.
public void testAddRouteDefinitionsAfterExceptionFromXml() throws Exception {
RouteDefinition route = loadRoute("route4_error.xml");
assertNotNull(route);
assertEquals("foo", route.getId());
assertEquals(0, context.getRoutes().size());
try {
context.addRouteDefinition(route);
} catch (Exception e) {
// catch this is error to simulate test case!!!!
}
// load route with same id
route = loadRoute("route4_ok.xml");
assertNotNull(route);
assertEquals("foo", route.getId());
assertEquals(0, context.getRoutes().size());
context.addRouteDefinition(route);
assertEquals(1, context.getRoutes().size());
}
Aggregations