private void replaceFromEndpoints() throws Exception { for (final Map.Entry<String, String> entry : fromEndpoints.entrySet()) { context.getRouteDefinition(entry.getKey()).adviceWith(context, new AdviceWithRouteBuilder() { @Override public void configure() throws Exception { replaceFromWith(entry.getValue()); } }); } }
public static RouteDefinition getRouteDefinition(String routeId, ModelCamelContext camelContext) { final RouteDefinition routeDefinition = camelContext.getRouteDefinition(routeId); if (routeDefinition == null) { throw new IllegalStateException("route '" + routeId + "' not found!"); } return routeDefinition; } }
private void weaveRoute(String id, Consumer<AdviceWithRouteBuilder> consumer) throws Exception { camelContext.getRouteDefinition(id) .adviceWith(camelContext, new AdviceWithRouteBuilder() { @Override public void configure() { consumer.accept(this); } }); }
@Before public void mockEndpoints() throws Exception { if (tracing) { context.setTracing(true); context.setStreamCaching(true); context.getProperties().put(Exchange.LOG_DEBUG_BODY_STREAMS, Boolean.TRUE.toString()); } context.removeComponent("petals"); context.addComponent("petals", new MockComponent()); for (final String from : routesToMock()) { RouteDefinition routeDef = context.getRouteDefinition(from); assertNotNull("You should set the routeId of one of the routes to '" + from + "' from mocking to work", routeDef); routeDef.adviceWith(context, new AdviceWithRouteBuilder() { @Override public void configure() throws Exception { replaceFromWith("direct:" + from); } }); } context.start(); }