org.apache.camel.model.RoutesDefinition Java Examples

The following examples show how to use org.apache.camel.model.RoutesDefinition. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IntegrationRouteLoaderTest.java    From syndesis with Apache License 2.0 6 votes vote down vote up
@Test
public void integrationRouteLoaderTest() throws Exception {
    IntegrationRouteLoader irl = new IntegrationRouteLoader();
    TestRuntime runtime = new TestRuntime();

    irl.load(runtime,
        Sources.fromURI("classpath:/syndesis/integration/integration.syndesis?language=syndesis"));

    assertThat(runtime.builders).hasSize(1);
    final RoutesBuilder routeBuilder = runtime.builders.get(0);
    assertThat(routeBuilder).isInstanceOf(RouteBuilder.class);

    RouteBuilder rb = (RouteBuilder) routeBuilder;
    // initialize routes
    rb.configure();
    final RoutesDefinition routeCollection = rb.getRouteCollection();
    final List<RouteDefinition> routes = routeCollection.getRoutes();
    assertThat(routes).hasSize(1);
    final RouteDefinition route = routes.get(0);
    final FromDefinition input = route.getInput();
    assertThat(input).isNotNull();
    assertThat(input.getEndpointUri()).isEqualTo("direct:expression");
}
 
Example #2
Source File: OIntegrationConfig.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
@OMethod(
			order=10,bootstrap=BootstrapType.SUCCESS,icon = FAIconType.play,
			filters={
					@OFilter(fClass = PlaceFilter.class, fData = "STRUCTURE_TABLE"),
					@OFilter(fClass = WidgetTypeFilter.class, fData = "parameters"),
//					@OFilter(fClass = PlaceFilter.class, fData = "STRUCTURE_TABLE|DATA_TABLE"),

			}
	)
	public void start(IMethodContext data){
		final CamelContext context = getOrMakeContextByRid(getDocument().getIdentity().toString(),data.getCurrentWidget());
		new Thread(new Runnable() {
			@Override
			public void run() {
				try {
					if (context.getStatus().isSuspended()){
						context.resume();
						//target.add(CamelWidget.this.form);
					}else if (!context.getStatus().isStarted()){
						clearContext(context);
						String script = getDocument().field("script");
						RoutesDefinition routes = context.loadRoutesDefinition(new ByteArrayInputStream( script.getBytes()));
						context.addRouteDefinitions(routes.getRoutes());
						context.start();
					}
				} catch (Exception e) {
					LOG.error("Cannot start or resume Camel Context",e);
				}
			}
		}).start();
		waitingRefresh(context);
	}
 
Example #3
Source File: IntegrationTestSupport.java    From syndesis with Apache License 2.0 5 votes vote down vote up
protected void dumpRoutes(CamelContext context, RoutesDefinition definition) {
    if (!LOGGER.isInfoEnabled()) {
        return;
    }

    try {
        ExtendedCamelContext extendedCamelContext = context.adapt(ExtendedCamelContext.class);
        ModelToXMLDumper dumper = extendedCamelContext.getModelToXMLDumper();
        LOGGER.info("Routes: \n{}", dumper.dumpModelAsXml(context, definition));
    } catch (Exception e) {
        LOGGER.warn("Unable to dump routes as XML", e);
    }
}
 
Example #4
Source File: SyncopeCamelContext.java    From syncope with Apache License 2.0 5 votes vote down vote up
private void loadRouteDefinitions(final List<String> routes) {
    try {
        RoutesDefinition routeDefs = (RoutesDefinition) camelContext.adapt(ExtendedCamelContext.class).
                getXMLRoutesDefinitionLoader().loadRoutesDefinition(
                        camelContext,
                        new ByteArrayInputStream(("<routes xmlns=\"http://camel.apache.org/schema/spring\">"
                                + routes.stream().collect(Collectors.joining())
                                + "</routes>").getBytes(StandardCharsets.UTF_8)));
        camelContext.addRouteDefinitions(routeDefs.getRoutes());
    } catch (Exception e) {
        LOG.error("While adding route definitions into Camel Context {}", getCamelContext(), e);
        throw new CamelException(e);
    }
}
 
Example #5
Source File: IntegrationRouteBuilder.java    From syndesis with Apache License 2.0 5 votes vote down vote up
private void loadFragments(Step step) {
    if (StepKind.extension != step.getStepKind()) {
        return;
    }

    final StepAction action = step.getActionAs(StepAction.class)
                                  .orElseThrow(() -> new IllegalArgumentException(
                                          String.format("Missing step action on step: %s - %s", step.getId(), step.getName())));

    if (action.getDescriptor().getKind() == StepAction.Kind.ENDPOINT) {
        final ModelCamelContext context = getContext();
        final String resource = action.getDescriptor().getResource();

        if (ObjectHelper.isNotEmpty(resource) && resources.add(resource)) {
            final Object instance = mandatoryLoadResource(context, resource);
            final RoutesDefinition definitions = mandatoryConvertToRoutesDefinition(resource, instance);

            LOGGER.debug("Resolved resource: {} as {}", resource, instance.getClass());

            try {
                context.addRouteDefinitions(definitions.getRoutes());
            } catch (Exception e) {
                throw new IllegalStateException(e);
            }
        }
    }
}
 
Example #6
Source File: IntegrationTestSupport.java    From syndesis with Apache License 2.0 5 votes vote down vote up
public static void dumpRoutes(CamelContext context, RoutesDefinition definition) {
    if (!LOGGER.isInfoEnabled()) {
        return;
    }

    try {
        ExtendedCamelContext extendedCamelContext = context.adapt(ExtendedCamelContext.class);
        ModelToXMLDumper dumper = extendedCamelContext.getModelToXMLDumper();
        LOGGER.info("Routes: \n{}", dumper.dumpModelAsXml(context, definition));
    } catch (Exception e) {
        LOGGER.warn("Unable to dump route definition as XML");
        LOGGER.debug("Error encountered while dumping route definition as XML", e);
    }
}
 
Example #7
Source File: CamelRouteAdapter.java    From mdw with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the latest version whose attributes match the custom attribute
 * criteria specified via "CustomAttributes".
 * Override to apply additional or non-standard conditions.
 * @param version
 */
protected RoutesDefinition getRoutesDefinition(String name, String version) throws AdapterException {
    String modifier = "";
    Map<String,String> params = getHandlerParameters();
    if (params != null) {
        for (String paramName : params.keySet()) {
            if (modifier.length() == 0)
                modifier += "?";
            else
                modifier += "&amp;";

            modifier += paramName + "=" + params.get(paramName);
        }
    }

    RoutesDefinitionRuleSet rdrs;
    if (version == null)
        rdrs = CamelRouteCache.getRoutesDefinitionRuleSet(name, modifier);
    else
        rdrs = CamelRouteCache.getRoutesDefinitionRuleSet(new AssetVersionSpec(name, version), modifier);

    if (rdrs == null) {
        throw new AdapterException("Unable to load Camel route: " + name + modifier);
    }
    else {
        logDebug("Using RoutesDefinition: " + rdrs.getRuleSet().getLabel());
        return rdrs.getRoutesDefinition();
    }
}
 
Example #8
Source File: IntegrationRouteBuilderTest.java    From syndesis with Apache License 2.0 5 votes vote down vote up
@Test
public void testIntegrationRouteBuilder() throws Exception {
    String configurationLocation = "classpath:syndesis/integration/integration.json";

    IntegrationRouteBuilder routeBuilder = new IntegrationRouteBuilder(configurationLocation, Resources.loadServices(IntegrationStepHandler.class), policyFactories);

    // initialize routes
    routeBuilder.configure();

    // Dump routes as XML for troubleshooting
    dumpRoutes(new DefaultCamelContext(), routeBuilder.getRouteCollection());

    RoutesDefinition routes = routeBuilder.getRouteCollection();

    assertThat(routes.getRoutes()).hasSize(1);

    RouteDefinition route = routes.getRoutes().get(0);

    assertThat(route.getRoutePolicies()).hasSize(1);

    assertThat(route.getInput()).isNotNull();
    assertThat(route.getInput()).hasFieldOrPropertyWithValue("uri", "direct:expression");
    assertThat(route.getOutputs()).hasSize(2);
    assertThat(getOutput(route, 0)).isInstanceOf(PipelineDefinition.class);
    assertThat(getOutput(route, 0).getOutputs()).hasSize(2);
    assertThat(getOutput(route, 0).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(route, 0).getOutputs().get(1)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(route, 1)).isInstanceOf(SplitDefinition.class);
    assertThat(getOutput(route, 1).getOutputs()).hasSize(3);
    assertThat(getOutput(route, 1, 0)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(route, 1, 1)).isInstanceOf(ProcessDefinition.class);
    assertThat(getOutput(route, 1, 2)).isInstanceOf(PipelineDefinition.class);
    assertThat(getOutput(route, 1, 2).getOutputs()).hasSize(3);
    assertThat(getOutput(route, 1, 2, 0)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(route, 1, 2, 1)).isInstanceOf(ToDefinition.class);
    assertThat(getOutput(route, 1, 2, 1)).hasFieldOrPropertyWithValue("uri", "mock:expression");
    assertThat(getOutput(route, 1, 2, 2)).isInstanceOf(ProcessDefinition.class);
}
 
Example #9
Source File: RoutesDefinitionRuleSet.java    From mdw with Apache License 2.0 5 votes vote down vote up
public RoutesDefinitionRuleSet(RoutesDefinition routes, Asset ruleSet) {
    this.routesDefinition = routes;
    this.ruleSet = ruleSet;

    for (RouteDefinition routeDef : routesDefinition.getRoutes()) {
        routeIds.add(routeDef.getId());
    }
}
 
Example #10
Source File: CamelRouteCache.java    From mdw with Apache License 2.0 5 votes vote down vote up
public static RoutesDefinition getRoutesDefinition(String name, String modifier) {
    RoutesDefinitionRuleSet rdrs = getRoutesDefinitionRuleSet(name, modifier);
    if (rdrs == null)
        return null;
    else
        return rdrs.getRoutesDefinition();
}
 
Example #11
Source File: XmlModel.java    From fabric8-forge with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the root element to be marshalled as XML
 *
 * @return
 */
public Object marshalRootElement() {
    if (justRoutes) {
        RoutesDefinition routes = new RoutesDefinition();
        routes.setRoutes(contextElement.getRoutes());
        return routes;
    } else {
        return contextElement;
    }
}
 
Example #12
Source File: IntegrationRouteTest.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@Test
public void integrationWithSplitTest() throws Exception {
    final RouteBuilder routeBuilder = new IntegrationRouteBuilder("", Resources.loadServices(IntegrationStepHandler.class)) {
        @Override
        protected Integration loadIntegration() {
            return newIntegration(
                new Step.Builder()
                    .id("step-1")
                    .stepKind(StepKind.endpoint)
                    .action(new ConnectorAction.Builder()
                        .descriptor(new ConnectorDescriptor.Builder()
                            .componentScheme("direct")
                            .putConfiguredProperty("name", "start")
                            .build())
                        .build())
                    .build(),
                new Step.Builder()
                    .stepKind(StepKind.split)
                    .build(),
                new Step.Builder()
                    .id("step-2")
                    .stepKind(StepKind.endpoint)
                    .action(new ConnectorAction.Builder()
                        .descriptor(new ConnectorDescriptor.Builder()
                            .componentScheme("bean")
                            .putConfiguredProperty("beanName", "io.syndesis.integration.runtime.IntegrationRouteTest.TestConfiguration")
                            .build())
                        .build())
                    .build(),
                new Step.Builder()
                    .id("step-3")
                    .stepKind(StepKind.endpoint)
                    .action(new ConnectorAction.Builder()
                        .descriptor(new ConnectorDescriptor.Builder()
                            .componentScheme("mock")
                            .putConfiguredProperty("name", "result")
                            .build())
                        .build())
                    .build(),
                new Step.Builder()
                        .stepKind(StepKind.aggregate)
                        .build());
        }
    };

    // initialize routes
    routeBuilder.configure();

    dumpRoutes(new DefaultCamelContext(), routeBuilder.getRouteCollection());

    RoutesDefinition routes = routeBuilder.getRouteCollection();
    assertThat(routes.getRoutes()).hasSize(1);

    RouteDefinition route = routes.getRoutes().get(0);

    assertThat(route.getInput()).isNotNull();
    assertThat(route.getInput()).hasFieldOrPropertyWithValue("uri", "direct:start");
    assertThat(route.getOutputs()).hasSize(4);
    assertThat(getOutput(route, 0)).isInstanceOf(PipelineDefinition.class);
    assertThat(getOutput(route, 0).getOutputs()).hasSize(2);
    assertThat(getOutput(route, 0).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(route, 0).getOutputs().get(1)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(route, 1)).isInstanceOf(SplitDefinition.class);
    assertThat(getOutput(route, 1).getOutputs()).hasSize(4);
    assertThat(getOutput(route, 1, 0)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(route, 1, 1)).isInstanceOf(ProcessDefinition.class);
    assertThat(getOutput(route, 1, 2)).isInstanceOf(PipelineDefinition.class);
    assertThat(getOutput(route, 1, 3)).isInstanceOf(PipelineDefinition.class);
    assertThat(getOutput(route, 2)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(route, 3)).isInstanceOf(ProcessDefinition.class);
}
 
Example #13
Source File: CamelRouteAdapter.java    From mdw with Apache License 2.0 4 votes vote down vote up
@Override
protected Object invoke(Object pConnection, Object request)
throws AdapterException, ConnectionException {
    try {
        String routeDefAttr = getAttributeValueSmart(ROUTE_DEF);
        String routeDefVer = getAttributeValueSmart(ROUTE_DEF_VER);
        if (routeDefAttr == null)
            throw new AdapterException("Missing attribute: " + ROUTE_DEF);

        RoutesDefinition routesDef = getRoutesDefinition(routeDefAttr, routeDefVer);

        RouteDefinition routeDef = null;
        if (routesDef.getRoutes().size() == 0) {
            throw new AdapterException("No routes found in " + routesDef);
        }
        if (routesDef.getRoutes().size() > 1) {
            String routeId = getAttributeValueSmart(ROUTE_ID);
            if (routeId == null)
                throw new AdapterException(ROUTE_ID + " attribute required when route definition contains more than one route");
            for (RouteDefinition route : routesDef.getRoutes()) {
                if (routeId.equals(route.getId()))
                  routeDef = route;
            }
            if (routeDef == null)
                throw new AdapterException("Cannot find route ID=" + routeId + " in route definition asset '" + ROUTE_DEF + "'.");
        }
        else {
            routeDef = routesDef.getRoutes().get(0);
        }

        Map<String,Object> headers = getHeaders();
        if (headers == null)
            headers = new HashMap<String,Object>();
        headers.put("routeId", routeDef.getId());

        WorkflowHandler handler = getWorkflowHandler(routeDefAttr);
        if (handler == null)
            throw new EventException("No workflow handler for: " + routeDefAttr + ".  Make sure that the mdw-camel bundle is started");

        return handler.invoke(request, headers);
    }
    catch (Exception ex) {
        getLogger().error(ex.getMessage(), ex);
        throw new AdapterException(-1, ex.getMessage(), ex);
    }
}
 
Example #14
Source File: CamelRouteCache.java    From mdw with Apache License 2.0 4 votes vote down vote up
public static RoutesDefinition getRoutesDefinition(String name) {
    return getRoutesDefinition(name, null);
}
 
Example #15
Source File: IntegrationRouteTest.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@Test
public void integrationWithSchedulerAndSplitTest() throws Exception {
    final RouteBuilder routeBuilder = new IntegrationRouteBuilder("", Resources.loadServices(IntegrationStepHandler.class)) {
        @Override
        protected Integration loadIntegration() {
            Integration integration = newIntegration(
                new Step.Builder()
                    .id("step-1")
                    .stepKind(StepKind.endpoint)
                    .action(new ConnectorAction.Builder()
                        .descriptor(new ConnectorDescriptor.Builder()
                            .componentScheme("log")
                            .putConfiguredProperty("loggerName", "timer")
                            .build())
                        .build())
                    .build(),
                new Step.Builder()
                    .stepKind(StepKind.split)
                    .build(),
                new Step.Builder()
                    .id("step-2")
                    .stepKind(StepKind.endpoint)
                    .action(new ConnectorAction.Builder()
                        .descriptor(new ConnectorDescriptor.Builder()
                            .componentScheme("mock")
                            .putConfiguredProperty("name", "timer")
                            .build())
                        .build())
                    .build(),
                new Step.Builder()
                    .stepKind(StepKind.aggregate)
                    .build());

            final Flow flow = integration.getFlows().get(0);
            final Flow flowWithScheduler = flow.builder()
                .scheduler(new Scheduler.Builder()
                    .type(Scheduler.Type.timer)
                    .expression("1s")
                    .build())
                .build();

            return new Integration.Builder()
                .createFrom(integration)
                .flows(singleton(flowWithScheduler))
                .build();
        }
    };

    // initialize routes
    routeBuilder.configure();

    dumpRoutes(new DefaultCamelContext(), routeBuilder.getRouteCollection());

    RoutesDefinition routes = routeBuilder.getRouteCollection();
    assertThat(routes.getRoutes()).hasSize(1);

    RouteDefinition route = routes.getRoutes().get(0);

    assertThat(route.getInput()).isNotNull();
    assertThat(route.getInput()).hasFieldOrPropertyWithValue("uri", "timer:integration?period=1s");
    assertThat(route.getOutputs()).hasSize(5);
    assertThat(getOutput(route, 0)).isInstanceOf(PipelineDefinition.class);
    assertThat(getOutput(route, 0).getOutputs()).hasSize(2);
    assertThat(getOutput(route, 0, 0)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(route, 0, 1)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(route, 1)).isInstanceOf(ToDefinition.class);
    assertThat(getOutput(route, 1)).hasFieldOrPropertyWithValue("uri", "log:timer");
    assertThat(getOutput(route, 2)).isInstanceOf(SplitDefinition.class);
    assertThat(getOutput(route, 2).getOutputs()).hasSize(3);
    assertThat(getOutput(route, 2, 0)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(route, 2, 1)).isInstanceOf(ProcessDefinition.class);
    assertThat(getOutput(route, 2, 2)).isInstanceOf(PipelineDefinition.class);
    assertThat(getOutput(route, 2, 2).getOutputs()).hasSize(3);
    assertThat(getOutput(route, 2, 2, 0)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(route, 2, 2, 1)).isInstanceOf(ToDefinition.class);
    assertThat(getOutput(route, 2, 2, 1)).hasFieldOrPropertyWithValue("uri", "mock:timer");
    assertThat(getOutput(route, 2, 2, 2)).isInstanceOf(ProcessDefinition.class);
    assertThat(getOutput(route, 3)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(route, 4)).isInstanceOf(ProcessDefinition.class);
}
 
Example #16
Source File: CustomRoutesCollector.java    From camel-quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public List<RoutesDefinition> collectXmlRoutesFromDirectory(CamelContext camelContext, String directory) throws Exception {
    return Collections.emptyList();
}
 
Example #17
Source File: IntegrationRouteTest.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@Test
public void integrationWithSchedulerTest() throws Exception {
    final RouteBuilder routeBuilder = new IntegrationRouteBuilder("", Resources.loadServices(IntegrationStepHandler.class)) {
        @Override
        protected Integration loadIntegration() {
            Integration integration = newIntegration(
                new Step.Builder()
                    .id("step-1")
                    .stepKind(StepKind.endpoint)
                    .action(new ConnectorAction.Builder()
                        .descriptor(new ConnectorDescriptor.Builder()
                            .componentScheme("log")
                            .putConfiguredProperty("loggerName", "timer")
                            .build())
                        .build())
                    .build(),
                new Step.Builder()
                    .id("step-2")
                    .stepKind(StepKind.endpoint)
                    .action(new ConnectorAction.Builder()
                        .descriptor(new ConnectorDescriptor.Builder()
                            .componentScheme("mock")
                            .putConfiguredProperty("name", "timer")
                            .build())
                        .build())
                    .build());

            final Flow flow = integration.getFlows().get(0);
            final Flow flowWithScheduler = flow.builder()
                .scheduler(new Scheduler.Builder()
                    .type(Scheduler.Type.timer)
                    .expression("1s")
                    .build())
                .build();

            return new Integration.Builder()
                .createFrom(integration)
                .flows(singleton(flowWithScheduler))
                .build();
        }
    };

    // initialize routes
    routeBuilder.configure();

    dumpRoutes(new DefaultCamelContext(), routeBuilder.getRouteCollection());

    RoutesDefinition routes = routeBuilder.getRouteCollection();
    assertThat(routes.getRoutes()).hasSize(1);

    RouteDefinition route = routes.getRoutes().get(0);

    // Timer
    assertThat(route.getInput()).isNotNull();
    assertThat(route.getInput()).hasFieldOrPropertyWithValue("uri", "timer:integration?period=1s");
    assertThat(route.getOutputs()).hasSize(5);
    assertThat(getOutput(route, 0)).isInstanceOf(PipelineDefinition.class);
    assertThat(getOutput(route, 0).getOutputs()).hasSize(2);
    assertThat(getOutput(route, 0, 0)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(route, 0, 1)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(route, 1)).isInstanceOf(ToDefinition.class);
    assertThat(getOutput(route, 1)).hasFieldOrPropertyWithValue("uri", "log:timer");
    assertThat(getOutput(route, 2)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(route, 3)).isInstanceOf(ProcessDefinition.class);
    assertThat(getOutput(route, 4)).isInstanceOf(PipelineDefinition.class);
    assertThat(getOutput(route, 4).getOutputs()).hasSize(3);
    assertThat(getOutput(route, 4, 0)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(route, 4, 1)).isInstanceOf(ToDefinition.class);
    assertThat(getOutput(route, 4, 1)).hasFieldOrPropertyWithValue("uri", "mock:timer");
    assertThat(getOutput(route, 4, 2)).isInstanceOf(ProcessDefinition.class);
}
 
Example #18
Source File: IntegrationRouteBuilderTest.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@Test
public void testMultiFlowIntegrationRouteBuilder() throws Exception {
    String configurationLocation = "classpath:syndesis/integration/multi-flow-integration.json";

    IntegrationRouteBuilder routeBuilder = new IntegrationRouteBuilder(configurationLocation, Resources.loadServices(IntegrationStepHandler.class), policyFactories);

    // initialize routes
    routeBuilder.configure();

    // Dump routes as XML for troubleshooting
    dumpRoutes(new DefaultCamelContext(), routeBuilder.getRouteCollection());

    RoutesDefinition routes = routeBuilder.getRouteCollection();

    assertThat(routes.getRoutes()).hasSize(3);

    RouteDefinition primaryRoute = routes.getRoutes().get(0);

    assertThat(primaryRoute.getRoutePolicies()).hasSize(1);
    assertThat(primaryRoute.getRoutePolicies().get(0)).isInstanceOf(IntegrationActivityTrackingPolicy.class);

    assertThat(primaryRoute.getInput()).isNotNull();
    assertThat(primaryRoute.getInput()).hasFieldOrPropertyWithValue("uri", "direct:expression");
    assertThat(primaryRoute.getOutputs()).hasSize(2);
    assertThat(getOutput(primaryRoute, 0)).isInstanceOf(PipelineDefinition.class);
    assertThat(getOutput(primaryRoute, 0).getOutputs()).hasSize(2);
    assertThat(getOutput(primaryRoute, 0).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(primaryRoute, 0).getOutputs().get(1)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(primaryRoute, 1)).isInstanceOf(SplitDefinition.class);
    assertThat(getOutput(primaryRoute, 1).getOutputs()).hasSize(5);
    assertThat(getOutput(primaryRoute, 1, 0)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(primaryRoute, 1, 1)).isInstanceOf(ProcessDefinition.class);
    assertThat(getOutput(primaryRoute, 1, 2)).isInstanceOf(PipelineDefinition.class);
    assertThat(getOutput(primaryRoute, 1, 2).getOutputs()).hasSize(2);
    assertThat(getOutput(primaryRoute, 1, 2, 0)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(primaryRoute, 1, 2, 1)).isInstanceOf(LogDefinition.class);
    assertThat(getOutput(primaryRoute, 1, 2, 1)).hasFieldOrPropertyWithValue("message", "Body: [${bean:bodyLogger}] Before");
    assertThat(getOutput(primaryRoute, 1, 3)).isInstanceOf(PipelineDefinition.class);
    assertThat(getOutput(primaryRoute, 1, 3).getOutputs()).hasSize(3);
    assertThat(getOutput(primaryRoute, 1, 3, 0)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(primaryRoute, 1, 3, 1)).isInstanceOf(ChoiceDefinition.class);
    assertThat(getOutput(primaryRoute, 1, 3, 2)).isInstanceOf(ProcessDefinition.class);
    assertThat(getOutput(primaryRoute, 1, 4)).isInstanceOf(PipelineDefinition.class);
    assertThat(getOutput(primaryRoute, 1, 4).getOutputs()).hasSize(2);
    assertThat(getOutput(primaryRoute, 1, 4, 0)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(primaryRoute, 1, 4, 1)).isInstanceOf(LogDefinition.class);
    assertThat(getOutput(primaryRoute, 1, 4, 1)).hasFieldOrPropertyWithValue("message", "Body: [${bean:bodyLogger}] Finished");

    RouteDefinition conditionalRoute = routes.getRoutes().get(1);

    assertThat(conditionalRoute.getRoutePolicies()).hasSize(1);
    assertThat(conditionalRoute.getRoutePolicies().get(0)).isInstanceOf(FlowActivityTrackingPolicy.class);

    assertThat(conditionalRoute.getInput()).isNotNull();
    assertThat(conditionalRoute.getInput()).hasFieldOrPropertyWithValue("uri", "direct");
    assertThat(conditionalRoute.getOutputs()).hasSize(5);
    assertThat(getOutput(conditionalRoute, 0)).isInstanceOf(PipelineDefinition.class);
    assertThat(getOutput(conditionalRoute, 0).getOutputs()).hasSize(2);
    assertThat(getOutput(conditionalRoute, 0).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(conditionalRoute, 0).getOutputs().get(1)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(conditionalRoute, 1)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(conditionalRoute, 2)).isInstanceOf(ProcessDefinition.class);
    assertThat(getOutput(conditionalRoute, 3)).isInstanceOf(PipelineDefinition.class);
    assertThat(getOutput(conditionalRoute, 3).getOutputs()).hasSize(2);
    assertThat(getOutput(conditionalRoute, 3, 0)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(conditionalRoute, 3, 1)).isInstanceOf(LogDefinition.class);
    assertThat(getOutput(conditionalRoute, 3, 1)).hasFieldOrPropertyWithValue("message", "Body: [${bean:bodyLogger}] Found <Play>");
    assertThat(getOutput(conditionalRoute, 4)).isInstanceOf(PipelineDefinition.class);
    assertThat(getOutput(conditionalRoute, 4).getOutputs()).hasSize(3);
    assertThat(getOutput(conditionalRoute, 4, 0)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(conditionalRoute, 4, 1)).isInstanceOf(ToDefinition.class);
    assertThat(getOutput(conditionalRoute, 4, 1)).hasFieldOrPropertyWithValue("uri", "bean:io.syndesis.connector.flow.NoOpBean?method=process");
    assertThat(getOutput(conditionalRoute, 4, 2)).isInstanceOf(ProcessDefinition.class);
}
 
Example #19
Source File: IntegrationTestSupport.java    From syndesis with Apache License 2.0 4 votes vote down vote up
public static void dumpRoutes(ModelCamelContext context) {
    RoutesDefinition definition = new RoutesDefinition();
    definition.setRoutes(context.getRouteDefinitions());

    dumpRoutes(context, definition);
}
 
Example #20
Source File: IntegrationTestSupport.java    From syndesis with Apache License 2.0 4 votes vote down vote up
protected void dumpRoutes(ModelCamelContext context) {
    RoutesDefinition definition = new RoutesDefinition();
    definition.setRoutes(context.adapt(ModelCamelContext.class).getRouteDefinitions());

    dumpRoutes(context, definition);
}
 
Example #21
Source File: ApplicationRuntime.java    From camel-k-runtime with Apache License 2.0 4 votes vote down vote up
@Override
public List<RoutesDefinition> collectXmlRoutesFromDirectory(CamelContext camelContext, String directory) throws Exception {
    return Collections.emptyList();
}
 
Example #22
Source File: RoutesDefinitionRuleSet.java    From mdw with Apache License 2.0 votes vote down vote up
public RoutesDefinition getRoutesDefinition() { return routesDefinition; }