Set<String> configurationFileNames = effectiveProfile.getConfigurationFileNames();
for (CamelContext camelContext : camelContexts.values()) {
String camelContextID = camelContext.getName();
// check we only add testing stuff to each context once
if (camelContext instanceof ModelCamelContext) {
final ModelCamelContext modelCamelContext = (ModelCamelContext) camelContext;
List<RouteDefinition> routeDefinitions = modelCamelContext.getRouteDefinitions();
if (camelContextsConfigured.add(camelContextID)) {
NodeIdFactory nodeIdFactory = camelContext.getNodeIdFactory();
if (mockInputs || mockOutputs) {
for (RouteDefinition routeDefinition : routeDefinitions) {
String routeId = routeDefinition.idOrCreate(nodeIdFactory);
modelCamelContext.stopRoute(routeId);
final String routeKey = camelContextID + "." + routeId;
LOG.info("Mocking Camel route: " + routeKey);
routeDefinition.adviceWith(modelCamelContext, new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
if (mockOutputs) {
modelCamelContext.addRegisterEndpointCallback(strategy);
}
}
});
// the advised route is automatic restarted
}