use of org.apache.camel.model.RouteDefinition in project camel by apache.
the class RemoveRouteDefinitionTest method testShutdownRoute.
@SuppressWarnings("deprecation")
public void testShutdownRoute() throws Exception {
// JMX tests dont work well on AIX CI servers (hangs them)
if (isPlatform("aix")) {
return;
}
MBeanServer mbeanServer = getMBeanServer();
Set<ObjectName> set = mbeanServer.queryNames(new ObjectName("*:type=routes,*"), null);
assertEquals(1, set.size());
ObjectName on = set.iterator().next();
boolean registered = mbeanServer.isRegistered(on);
assertEquals("Should be registered", true, registered);
RouteDefinition definition = context.getRouteDefinition("route1");
List<RouteDefinition> routeDefinitions = new ArrayList<RouteDefinition>();
routeDefinitions.add(definition);
context.shutdownRoute("route1");
// route is shutdown (= also removed), so its not longer in JMX
set = mbeanServer.queryNames(new ObjectName("*:type=routes,*"), null);
assertEquals(0, set.size());
}
use of org.apache.camel.model.RouteDefinition in project camel by apache.
the class RemoveRouteDefinitionTest method testStopAndRemoveRoute.
public void testStopAndRemoveRoute() throws Exception {
// JMX tests dont work well on AIX CI servers (hangs them)
if (isPlatform("aix")) {
return;
}
MBeanServer mbeanServer = getMBeanServer();
Set<ObjectName> set = mbeanServer.queryNames(new ObjectName("*:type=routes,*"), null);
assertEquals(1, set.size());
ObjectName on = set.iterator().next();
boolean registered = mbeanServer.isRegistered(on);
assertEquals("Should be registered", true, registered);
RouteDefinition definition = context.getRouteDefinition("route1");
List<RouteDefinition> routeDefinitions = new ArrayList<RouteDefinition>();
routeDefinitions.add(definition);
// must stop before we can remove
context.stopRoute("route1");
context.removeRoute("route1");
// route is removed, so its not longer in JMX
set = mbeanServer.queryNames(new ObjectName("*:type=routes,*"), null);
assertEquals(0, set.size());
}
use of org.apache.camel.model.RouteDefinition in project camel by apache.
the class AdviceWithTwoRoutesOnExceptionTest method testAdviceWithA.
public void testAdviceWithA() throws Exception {
RouteDefinition route = context.getRouteDefinition("a");
route.adviceWith(context, new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
interceptSendToEndpoint("mock://a").skipSendToOriginalEndpoint().throwException(new IllegalArgumentException("Forced"));
}
});
getMockEndpoint("mock:a").expectedMessageCount(0);
getMockEndpoint("mock:error").expectedMessageCount(1);
getMockEndpoint("mock:error").message(0).exchangeProperty(Exchange.EXCEPTION_CAUGHT).isInstanceOf(IllegalArgumentException.class);
template.sendBody("direct:a", "Hello World");
assertMockEndpointsSatisfied();
}
use of org.apache.camel.model.RouteDefinition in project camel by apache.
the class AdviceWithTwoRoutesTest method testAdviceWithB.
public void testAdviceWithB() throws Exception {
RouteDefinition route = context.getRouteDefinition("b");
route.adviceWith(context, new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
interceptSendToEndpoint("mock://b").skipSendToOriginalEndpoint().to("mock:detour");
}
});
getMockEndpoint("mock:b").expectedMessageCount(0);
getMockEndpoint("mock:detour").expectedMessageCount(1);
template.sendBody("direct:b", "Hello World");
assertMockEndpointsSatisfied();
}
use of org.apache.camel.model.RouteDefinition in project camel by apache.
the class AdviceWithTwoRoutesTest method testAdviceWithAB.
public void testAdviceWithAB() throws Exception {
RouteDefinition route = context.getRouteDefinition("a");
route.adviceWith(context, new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
interceptSendToEndpoint("mock://a").skipSendToOriginalEndpoint().to("mock:detour");
}
});
route = context.getRouteDefinition("b");
route.adviceWith(context, new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
interceptSendToEndpoint("mock://b").skipSendToOriginalEndpoint().to("mock:detour");
}
});
getMockEndpoint("mock:a").expectedMessageCount(0);
getMockEndpoint("mock:b").expectedMessageCount(0);
getMockEndpoint("mock:detour").expectedMessageCount(2);
template.sendBody("direct:a", "Hello World");
template.sendBody("direct:b", "Bye World");
assertMockEndpointsSatisfied();
}
Aggregations