org.apache.camel.CamelContext.stop()

Here are the examples of the java api org.apache.camel.CamelContext.stop() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

86 Examples 7

19 Source : OutMessageCaptureProcessorTest.java
with Apache License 2.0
from syndesisio

@Test
public void testCaptureWithSplitAggregate() throws Exception {
    final CamelContext context = new SpringCamelContext(applicationContext);
    try {
        final RouteBuilder routes = newIntegrationRouteBuilder(new Step.Builder().id("s1").stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("direct").putConfiguredProperty("name", "expression").build()).build()).build(), new Step.Builder().id("s-split").stepKind(StepKind.split).build(), new Step.Builder().id("s2").stepKind(StepKind.extension).action(new StepAction.Builder().descriptor(new StepDescriptor.Builder().kind(StepAction.Kind.BEAN).entrypoint(Bean1.clreplaced.getName()).build()).build()).build(), new Step.Builder().id("s3").stepKind(StepKind.extension).action(new StepAction.Builder().descriptor(new StepDescriptor.Builder().kind(StepAction.Kind.BEAN).entrypoint(Bean2.clreplaced.getName()).build()).build()).build(), new Step.Builder().id("s4").stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("mock").putConfiguredProperty("name", "expression").build()).build()).build(), new Step.Builder().id("s-aggregate").stepKind(StepKind.aggregate).build());
        // Set up the camel context
        context.addRoutes(routes);
        context.start();
        // Dump routes as XML for troubleshooting
        dumpRoutes(context);
        final ProducerTemplate template = context.createProducerTemplate();
        final MockEndpoint result = context.getEndpoint("mock:expression", MockEndpoint.clreplaced);
        result.expectedBodiesReceived("-862545276");
        template.sendBody("direct:expression", "World");
        result.replacedertIsSatisfied();
        Exchange exchange1 = result.getExchanges().get(0);
        Map<String, Message> messages = OutMessageCaptureProcessor.getCapturedMessageMap(exchange1);
        replacedertThat(messages).hreplacedize(5);
        replacedertThat(messages.get("s-split").getBody()).isEqualTo("World");
        replacedertThat(messages.get("s2").getBody()).isEqualTo("Hello World");
        replacedertThat(messages.get("s3").getBody()).isEqualTo(-862545276);
        replacedertThat(messages.get("s4").getBody()).isEqualTo(-862545276);
        replacedertThat(messages.get("s-aggregate").getBody()).isEqualTo(Collections.singletonList(-862545276));
    } finally {
        context.stop();
    }
}

19 Source : OutMessageCaptureProcessorTest.java
with Apache License 2.0
from syndesisio

@Test
public void testCapture() throws Exception {
    final CamelContext context = new SpringCamelContext(applicationContext);
    try {
        final RouteBuilder routes = newIntegrationRouteBuilder(new Step.Builder().id("s1").stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("direct").putConfiguredProperty("name", "expression").build()).build()).build(), new Step.Builder().id("s2").stepKind(StepKind.extension).action(new StepAction.Builder().descriptor(new StepDescriptor.Builder().kind(StepAction.Kind.BEAN).entrypoint(Bean1.clreplaced.getName()).build()).build()).build(), new Step.Builder().id("s3").stepKind(StepKind.extension).action(new StepAction.Builder().descriptor(new StepDescriptor.Builder().kind(StepAction.Kind.BEAN).entrypoint(Bean2.clreplaced.getName()).build()).build()).build(), new Step.Builder().id("s4").stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("mock").putConfiguredProperty("name", "expression").build()).build()).build());
        // Set up the camel context
        context.addRoutes(routes);
        context.start();
        // Dump routes as XML for troubleshooting
        dumpRoutes(context);
        final ProducerTemplate template = context.createProducerTemplate();
        final MockEndpoint result = context.getEndpoint("mock:expression", MockEndpoint.clreplaced);
        result.expectedBodiesReceived("-862545276");
        template.sendBody("direct:expression", "World");
        result.replacedertIsSatisfied();
        Exchange exchange1 = result.getExchanges().get(0);
        Map<String, Message> messages = OutMessageCaptureProcessor.getCapturedMessageMap(exchange1);
        replacedertThat(messages).hreplacedize(4);
        replacedertThat(messages.get("s1").getBody()).isEqualTo("World");
        replacedertThat(messages.get("s2").getBody()).isEqualTo("Hello World");
        replacedertThat(messages.get("s3").getBody()).isEqualTo(-862545276);
        replacedertThat(messages.get("s4").getBody()).isEqualTo(-862545276);
    } finally {
        context.stop();
    }
}

19 Source : OutMessageCaptureProcessorTest.java
with Apache License 2.0
from syndesisio

@Test
public void testCaptureWithSplitAggregateAndSchedule() throws Exception {
    final CamelContext context = new SpringCamelContext(applicationContext);
    try {
        Integration integration = newIntegration(new Step.Builder().id("s1").stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("direct").putConfiguredProperty("name", "getdata").build()).build()).build(), new Step.Builder().id("s-split").stepKind(StepKind.split).build(), new Step.Builder().id("s2").stepKind(StepKind.extension).action(new StepAction.Builder().descriptor(new StepDescriptor.Builder().kind(StepAction.Kind.BEAN).entrypoint(Bean1.clreplaced.getName()).build()).build()).build(), new Step.Builder().id("s3").stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("mock").putConfiguredProperty("name", "expression").build()).build()).build(), new Step.Builder().id("s-aggregate").stepKind(StepKind.aggregate).build());
        final Flow flow = integration.getFlows().get(0);
        final Flow flowWithScheduler = flow.builder().scheduler(new Scheduler.Builder().expression("60s").build()).build();
        integration = new Integration.Builder().createFrom(integration).flows(singleton(flowWithScheduler)).build();
        IntegrationRouteBuilder routes = newIntegrationRouteBuilder(integration);
        routes.from("direct:getdata").bean(new Bean3());
        // Set up the camel context
        context.addRoutes(routes);
        context.start();
        // Dump routes as XML for troubleshooting
        dumpRoutes(context);
        final MockEndpoint result = context.getEndpoint("mock:expression", MockEndpoint.clreplaced);
        result.expectedBodiesReceived("Hello Hiram", "Hello World");
        result.replacedertIsSatisfied();
        Exchange exchange1 = result.getExchanges().get(0);
        Map<String, Message> messages = OutMessageCaptureProcessor.getCapturedMessageMap(exchange1);
        replacedertThat(messages.get("s-split").getBody()).isEqualTo("Hiram");
        replacedertThat(messages.get("s2").getBody()).isEqualTo("Hello Hiram");
        Exchange exchange2 = result.getExchanges().get(1);
        Map<String, Message> messages2 = OutMessageCaptureProcessor.getCapturedMessageMap(exchange2);
        replacedertThat(messages2.get("s-split").getBody()).isEqualTo("World");
        replacedertThat(messages2.get("s2").getBody()).isEqualTo("Hello World");
    } finally {
        context.stop();
    }
}

19 Source : ActivityTracingWithSplitTest.java
with Apache License 2.0
from syndesisio

@AfterEach
public void after() throws Exception {
    context.stop();
}

19 Source : SplitStepHandlerTest.java
with Apache License 2.0
from syndesisio

@Test
public void testTokenizeSplitStep() throws Exception {
    final CamelContext context = new DefaultCamelContext();
    try {
        final RouteBuilder routes = newIntegrationRouteBuilder(activityTracker, new Step.Builder().id(START_STEP).stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("direct").putConfiguredProperty("name", "expression").build()).build()).build(), new Step.Builder().id(SPLIT_STEP).stepKind(StepKind.split).putConfiguredProperty("language", "tokenize").putConfiguredProperty("expression", "|").build(), new Step.Builder().id(MOCK_STEP).stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("mock").putConfiguredProperty("name", "expression").build()).build()).build());
        // Set up the camel context
        context.setUuidGenerator(KeyGenerator::createKey);
        context.addLogListener(new IntegrationLoggingListener(activityTracker));
        context.addInterceptStrategy(new ActivityTrackingInterceptStrategy(activityTracker));
        context.addRoutes(routes);
        context.start();
        // Dump routes as XML for troubleshooting
        dumpRoutes(context);
        final ProducerTemplate template = context.createProducerTemplate();
        final MockEndpoint result = context.getEndpoint("mock:expression", MockEndpoint.clreplaced);
        final String body = "a|b|c";
        result.expectedMessageCount(3);
        result.expectedBodiesReceived((Object[]) body.split("|"));
        template.sendBody("direct:expression", body);
        result.replacedertIsSatisfied();
        verify(activityTracker).startTracking(any(Exchange.clreplaced));
        verifyActivityStepTracking(SPLIT_STEP, 0);
        verifyActivityStepTracking(MOCK_STEP, 5);
        verify(activityTracker).finishTracking(any(Exchange.clreplaced));
    } finally {
        context.stop();
    }
}

19 Source : SplitStepHandlerTest.java
with Apache License 2.0
from syndesisio

@Test
public void testSplitBody() throws Exception {
    final CamelContext context = new DefaultCamelContext();
    try {
        final RouteBuilder routes = newIntegrationRouteBuilder(activityTracker, new Step.Builder().id(START_STEP).stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("direct").putConfiguredProperty("name", "expression").build()).build()).build(), new Step.Builder().id(SPLIT_STEP).stepKind(StepKind.split).build(), new Step.Builder().id(MOCK_STEP).stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("mock").putConfiguredProperty("name", "expression").build()).build()).build());
        // Set up the camel context
        context.setUuidGenerator(KeyGenerator::createKey);
        context.addLogListener(new IntegrationLoggingListener(activityTracker));
        context.addInterceptStrategy(new ActivityTrackingInterceptStrategy(activityTracker));
        context.addRoutes(routes);
        context.start();
        // Dump routes as XML for troubleshooting
        dumpRoutes(context);
        final ProducerTemplate template = context.createProducerTemplate();
        final MockEndpoint result = context.getEndpoint("mock:expression", MockEndpoint.clreplaced);
        final List<String> body = Arrays.asList("a", "b", "c");
        result.expectedMessageCount(3);
        result.expectedBodiesReceived(body);
        template.sendBody("direct:expression", body);
        result.replacedertIsSatisfied();
        verify(activityTracker).startTracking(any(Exchange.clreplaced));
        verifyActivityStepTracking(SPLIT_STEP, 0);
        verifyActivityStepTracking(MOCK_STEP, 3);
        verify(activityTracker).finishTracking(any(Exchange.clreplaced));
    } finally {
        context.stop();
    }
}

19 Source : SplitStepHandlerJsonTest.java
with Apache License 2.0
from syndesisio

/**
 * Test split to the very end of the integration - no aggregate
 * direct -> split -> mock
 */
@Test
public void testSplitToEnd() throws Exception {
    final CamelContext context = new DefaultCamelContext();
    try {
        final RouteBuilder routes = new IntegrationRouteBuilder("clreplacedpath:/syndesis/integration/split-to-end.json", Resources.loadServices(IntegrationStepHandler.clreplaced));
        // Set up the camel context
        context.addRoutes(routes);
        context.start();
        // Dump routes as XML for troubleshooting
        dumpRoutes(context);
        final ProducerTemplate template = context.createProducerTemplate();
        final MockEndpoint result = context.getEndpoint("mock:expression", MockEndpoint.clreplaced);
        final String[] expected = { "a", "b", "c" };
        final List<String> body = Arrays.asList(expected);
        result.expectedMessageCount(3);
        result.expectedBodiesReceived((Object[]) expected);
        template.sendBody("direct:expression", body);
        result.replacedertIsSatisfied();
    } finally {
        context.stop();
    }
}

19 Source : SplitAggregateStepHandlerTest.java
with Apache License 2.0
from syndesisio

@Test
public void testSplitAggregateWithLatestAggregationStrategy() throws Exception {
    final CamelContext context = new DefaultCamelContext();
    try {
        final RouteBuilder routes = newIntegrationRouteBuilder(activityTracker, new Step.Builder().id(START_STEP).stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("direct").putConfiguredProperty("name", "expression").build()).build()).build(), new Step.Builder().id(SPLIT_STEP).stepKind(StepKind.split).putConfiguredProperty("aggregationStrategy", "latest").build(), new Step.Builder().id(MOCK_STEP).stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("mock").putConfiguredProperty("name", "split").build()).build()).build(), new Step.Builder().id(AGGREGATE_STEP).stepKind(StepKind.aggregate).build());
        // Set up the camel context
        context.setUuidGenerator(KeyGenerator::createKey);
        context.addLogListener(new IntegrationLoggingListener(activityTracker));
        context.addInterceptStrategy(new ActivityTrackingInterceptStrategy(activityTracker));
        context.addRoutes(routes);
        context.start();
        // Dump routes as XML for troubleshooting
        dumpRoutes(context);
        final ProducerTemplate template = context.createProducerTemplate();
        final MockEndpoint result = context.getEndpoint("mock:split", MockEndpoint.clreplaced);
        final List<String> body = Arrays.asList("a", "b", "c");
        result.expectedBodiesReceived(body);
        String response = template.requestBody("direct:expression", body, String.clreplaced);
        result.replacedertIsSatisfied();
        replacedertions.replacedertThat(response).isEqualTo("c");
        verify(activityTracker).startTracking(any(Exchange.clreplaced));
        verifyActivityStepTracking(START_STEP, 1);
        verifyActivityStepTracking(SPLIT_STEP, 0);
        verifyActivityStepTracking(MOCK_STEP, 3);
        verifyActivityStepTracking(AGGREGATE_STEP, 0);
        verify(activityTracker, times(4)).track(eq("exchange"), anyString(), eq("step"), anyString(), eq("id"), anyString(), eq("duration"), anyLong(), eq("failure"), isNull());
        verify(activityTracker).finishTracking(any(Exchange.clreplaced));
    } finally {
        context.stop();
    }
}

19 Source : SplitAggregateStepHandlerTest.java
with Apache License 2.0
from syndesisio

@Test
public void testSplitAggregate() throws Exception {
    final CamelContext context = new DefaultCamelContext();
    try {
        final RouteBuilder routes = newIntegrationRouteBuilder(activityTracker, new Step.Builder().id(START_STEP).stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("direct").putConfiguredProperty("name", "expression").build()).build()).build(), new Step.Builder().id(SPLIT_STEP).stepKind(StepKind.split).build(), new Step.Builder().id(MOCK_STEP).stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("mock").putConfiguredProperty("name", "split").build()).build()).build(), new Step.Builder().id(AGGREGATE_STEP).stepKind(StepKind.aggregate).build());
        // Set up the camel context
        context.setUuidGenerator(KeyGenerator::createKey);
        context.addLogListener(new IntegrationLoggingListener(activityTracker));
        context.addInterceptStrategy(new ActivityTrackingInterceptStrategy(activityTracker));
        context.addRoutes(routes);
        context.start();
        // Dump routes as XML for troubleshooting
        dumpRoutes(context);
        final ProducerTemplate template = context.createProducerTemplate();
        final MockEndpoint result = context.getEndpoint("mock:split", MockEndpoint.clreplaced);
        final List<String> body = Arrays.asList("a", "b", "c");
        result.expectedBodiesReceived("a", "b", "c");
        List<?> response = template.requestBody("direct:expression", body, List.clreplaced);
        result.replacedertIsSatisfied();
        replacedertions.replacedertThat(response).isEqualTo(body);
        verify(activityTracker).startTracking(any(Exchange.clreplaced));
        verifyActivityStepTracking(START_STEP, 1);
        verifyActivityStepTracking(SPLIT_STEP, 0);
        verifyActivityStepTracking(MOCK_STEP, 3);
        verifyActivityStepTracking(AGGREGATE_STEP, 0);
        verify(activityTracker, times(4)).track(eq("exchange"), anyString(), eq("step"), anyString(), eq("id"), anyString(), eq("duration"), anyLong(), eq("failure"), isNull());
        verify(activityTracker).finishTracking(any(Exchange.clreplaced));
    } finally {
        context.stop();
    }
}

19 Source : SplitAggregateStepHandlerTest.java
with Apache License 2.0
from syndesisio

@Test
public void testSplitAggregateWithTrailingSteps() throws Exception {
    final CamelContext context = new DefaultCamelContext();
    try {
        final RouteBuilder routes = newIntegrationRouteBuilder(activityTracker, new Step.Builder().id(START_STEP).stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("direct").putConfiguredProperty("name", "expression").build()).build()).build(), new Step.Builder().id(SPLIT_STEP).stepKind(StepKind.split).build(), new Step.Builder().id("mock-before").stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("mock").putConfiguredProperty("name", "split").build()).build()).build(), new Step.Builder().id(AGGREGATE_STEP).stepKind(StepKind.aggregate).build(), new Step.Builder().id(MOCK_STEP).stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("mock").putConfiguredProperty("name", "afterSplit").build()).build()).build());
        // Set up the camel context
        context.setUuidGenerator(KeyGenerator::createKey);
        context.addLogListener(new IntegrationLoggingListener(activityTracker));
        context.addInterceptStrategy(new ActivityTrackingInterceptStrategy(activityTracker));
        context.addRoutes(routes);
        context.start();
        // Dump routes as XML for troubleshooting
        dumpRoutes(context);
        final ProducerTemplate template = context.createProducerTemplate();
        final MockEndpoint split = context.getEndpoint("mock:split", MockEndpoint.clreplaced);
        final MockEndpoint afterSplit = context.getEndpoint("mock:afterSplit", MockEndpoint.clreplaced);
        final List<String> body = Arrays.asList("a", "b", "c");
        split.expectedBodiesReceived("a", "b", "c");
        afterSplit.expectedMessageCount(1);
        List<?> response = template.requestBody("direct:expression", body, List.clreplaced);
        split.replacedertIsSatisfied();
        afterSplit.replacedertIsSatisfied();
        replacedertions.replacedertThat(afterSplit.getExchanges().get(0).getIn().getBody()).isEqualTo(body);
        replacedertions.replacedertThat(response).isEqualTo(body);
        verify(activityTracker).startTracking(any(Exchange.clreplaced));
        verifyActivityStepTracking(START_STEP, 1);
        verifyActivityStepTracking(SPLIT_STEP, 0);
        verifyActivityStepTracking(MOCK_STEP, 1);
        verifyActivityStepTracking(AGGREGATE_STEP, 0);
        verifyActivityStepTracking("mock-before", 3);
        verify(activityTracker, times(5)).track(eq("exchange"), anyString(), eq("step"), anyString(), eq("id"), anyString(), eq("duration"), anyLong(), eq("failure"), isNull());
        verify(activityTracker).finishTracking(any(Exchange.clreplaced));
    } finally {
        context.stop();
    }
}

19 Source : SplitAggregateStepHandlerTest.java
with Apache License 2.0
from syndesisio

@Test
public void testSplitAggregateWithOriginalAggregationStrategy() throws Exception {
    final CamelContext context = new DefaultCamelContext();
    try {
        final RouteBuilder routes = newIntegrationRouteBuilder(activityTracker, new Step.Builder().id(START_STEP).stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("direct").putConfiguredProperty("name", "expression").build()).build()).build(), new Step.Builder().id(SPLIT_STEP).stepKind(StepKind.split).putConfiguredProperty("language", "tokenize").putConfiguredProperty("expression", "|").putConfiguredProperty("aggregationStrategy", "original").build(), new Step.Builder().id(MOCK_STEP).stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("mock").putConfiguredProperty("name", "split").build()).build()).build(), new Step.Builder().id(AGGREGATE_STEP).stepKind(StepKind.aggregate).build());
        // Set up the camel context
        context.setUuidGenerator(KeyGenerator::createKey);
        context.addLogListener(new IntegrationLoggingListener(activityTracker));
        context.addInterceptStrategy(new ActivityTrackingInterceptStrategy(activityTracker));
        context.addRoutes(routes);
        context.start();
        // Dump routes as XML for troubleshooting
        dumpRoutes(context);
        final ProducerTemplate template = context.createProducerTemplate();
        final MockEndpoint result = context.getEndpoint("mock:split", MockEndpoint.clreplaced);
        final String body = "a|b|c";
        result.expectedBodiesReceived((Object[]) body.split("|"));
        String response = template.requestBody("direct:expression", body, String.clreplaced);
        result.replacedertIsSatisfied();
        replacedertions.replacedertThat(body).isEqualTo(response);
        verify(activityTracker).startTracking(any(Exchange.clreplaced));
        verifyActivityStepTracking(START_STEP, 1);
        verifyActivityStepTracking(SPLIT_STEP, 0);
        verifyActivityStepTracking(MOCK_STEP, 5);
        verifyActivityStepTracking(AGGREGATE_STEP, 0);
        verify(activityTracker, times(6)).track(eq("exchange"), anyString(), eq("step"), anyString(), eq("id"), anyString(), eq("duration"), anyLong(), eq("failure"), isNull());
        verify(activityTracker).finishTracking(any(Exchange.clreplaced));
    } finally {
        context.stop();
    }
}

19 Source : SplitAggregateStepHandlerTest.java
with Apache License 2.0
from syndesisio

@Test
public void testSplitAggregateScriptAggregationStrategy() throws Exception {
    final CamelContext context = new DefaultCamelContext();
    try {
        final RouteBuilder routes = newIntegrationRouteBuilder(activityTracker, new Step.Builder().id(START_STEP).stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("direct").putConfiguredProperty("name", "expression").build()).build()).build(), new Step.Builder().id(SPLIT_STEP).stepKind(StepKind.split).putConfiguredProperty("language", "tokenize").putConfiguredProperty("expression", "|").putConfiguredProperty("aggregationStrategy", "script").putConfiguredProperty("aggregationScriptLanguage", "nashorn").putConfiguredProperty("aggregationScript", "newExchange.in.body += oldExchange ? oldExchange.in.body : '';\n" + "newExchange;").build(), new Step.Builder().id(MOCK_STEP).stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("mock").putConfiguredProperty("name", "split").build()).build()).build(), new Step.Builder().id(AGGREGATE_STEP).stepKind(StepKind.aggregate).build());
        // Set up the camel context
        context.setUuidGenerator(KeyGenerator::createKey);
        context.addLogListener(new IntegrationLoggingListener(activityTracker));
        context.addInterceptStrategy(new ActivityTrackingInterceptStrategy(activityTracker));
        context.addRoutes(routes);
        context.start();
        // Dump routes as XML for troubleshooting
        dumpRoutes(context);
        final ProducerTemplate template = context.createProducerTemplate();
        final MockEndpoint result = context.getEndpoint("mock:split", MockEndpoint.clreplaced);
        final String body = "a|b|c";
        result.expectedBodiesReceived((Object[]) body.split("|"));
        String response = template.requestBody("direct:expression", body, String.clreplaced);
        result.replacedertIsSatisfied();
        replacedertions.replacedertThat(response).isEqualTo("c|b|a");
        verify(activityTracker).startTracking(any(Exchange.clreplaced));
        verifyActivityStepTracking(START_STEP, 1);
        verifyActivityStepTracking(SPLIT_STEP, 0);
        verifyActivityStepTracking(MOCK_STEP, 5);
        verifyActivityStepTracking(AGGREGATE_STEP, 0);
        verify(activityTracker, times(6)).track(eq("exchange"), anyString(), eq("step"), anyString(), eq("id"), anyString(), eq("duration"), anyLong(), eq("failure"), isNull());
        verify(activityTracker).finishTracking(any(Exchange.clreplaced));
    } finally {
        context.stop();
    }
}

19 Source : SplitAggregateStepHandlerTest.java
with Apache License 2.0
from syndesisio

@Test
public void testSplitAggregateWithTransformation() throws Exception {
    final CamelContext context = getDefaultCamelContextWithMyBeanInRegistry();
    try {
        final RouteBuilder routes = newIntegrationRouteBuilder(activityTracker, new Step.Builder().id(START_STEP).stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("direct").putConfiguredProperty("name", "expression").build()).build()).build(), new Step.Builder().id(SPLIT_STEP).stepKind(StepKind.split).build(), new Step.Builder().id("bean-step").stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("bean").putConfiguredProperty("beanName", "myBean").putConfiguredProperty("method", "myProcessor").build()).build()).build(), new Step.Builder().id(MOCK_STEP).stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("mock").putConfiguredProperty("name", "split").build()).build()).build(), new Step.Builder().id(AGGREGATE_STEP).stepKind(StepKind.aggregate).build(), new Step.Builder().id("mock-after").stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("mock").putConfiguredProperty("name", "afterSplit").build()).build()).build());
        // Set up the camel context
        context.setUuidGenerator(KeyGenerator::createKey);
        context.addLogListener(new IntegrationLoggingListener(activityTracker));
        context.addInterceptStrategy(new ActivityTrackingInterceptStrategy(activityTracker));
        context.addRoutes(routes);
        context.start();
        // Dump routes as XML for troubleshooting
        dumpRoutes(context);
        final ProducerTemplate template = context.createProducerTemplate();
        final MockEndpoint split = context.getEndpoint("mock:split", MockEndpoint.clreplaced);
        final MockEndpoint afterSplit = context.getEndpoint("mock:afterSplit", MockEndpoint.clreplaced);
        final List<String> body = Arrays.asList("a", "b", "c");
        split.expectedBodiesReceived("A", "B", "C");
        afterSplit.expectedMessageCount(1);
        List<?> response = template.requestBody("direct:expression", body, List.clreplaced);
        split.replacedertIsSatisfied();
        afterSplit.replacedertIsSatisfied();
        replacedertions.replacedertThat(afterSplit.getExchanges().get(0).getIn().getBody()).asList().containsOnly("A", "B", "C");
        replacedertions.replacedertThat(response).hreplacedize(3);
        verify(activityTracker).startTracking(any(Exchange.clreplaced));
        verifyActivityStepTracking(START_STEP, 1);
        verifyActivityStepTracking(SPLIT_STEP, 0);
        verifyActivityStepTracking(MOCK_STEP, 3);
        verifyActivityStepTracking(AGGREGATE_STEP, 0);
        verifyActivityStepTracking("bean-step", 3);
        verifyActivityStepTracking("mock-after", 1);
        verify(activityTracker, times(8)).track(eq("exchange"), anyString(), eq("step"), anyString(), eq("id"), anyString(), eq("duration"), anyLong(), eq("failure"), isNull());
        verify(activityTracker).finishTracking(any(Exchange.clreplaced));
    } finally {
        context.stop();
    }
}

19 Source : SplitAggregateStepHandlerTest.java
with Apache License 2.0
from syndesisio

@Test
public void testSplitAggregateTokenize() throws Exception {
    final CamelContext context = new DefaultCamelContext();
    try {
        final RouteBuilder routes = newIntegrationRouteBuilder(activityTracker, new Step.Builder().id(START_STEP).stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("direct").putConfiguredProperty("name", "expression").build()).build()).build(), new Step.Builder().id(SPLIT_STEP).stepKind(StepKind.split).putConfiguredProperty("language", "tokenize").putConfiguredProperty("expression", "|").build(), new Step.Builder().id(MOCK_STEP).stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("mock").putConfiguredProperty("name", "split").build()).build()).build(), new Step.Builder().id(AGGREGATE_STEP).stepKind(StepKind.aggregate).build());
        // Set up the camel context
        context.setUuidGenerator(KeyGenerator::createKey);
        context.addLogListener(new IntegrationLoggingListener(activityTracker));
        context.addInterceptStrategy(new ActivityTrackingInterceptStrategy(activityTracker));
        context.addRoutes(routes);
        context.start();
        // Dump routes as XML for troubleshooting
        dumpRoutes(context);
        final ProducerTemplate template = context.createProducerTemplate();
        final MockEndpoint result = context.getEndpoint("mock:split", MockEndpoint.clreplaced);
        final String body = "a|b|c";
        result.expectedBodiesReceived((Object[]) body.split("|"));
        List<?> response = template.requestBody("direct:expression", body, List.clreplaced);
        result.replacedertIsSatisfied();
        replacedertions.replacedertThat(response).hreplacedize(5);
        replacedertions.replacedertThat(response.stream().map(Object::toString).collect(Collectors.joining())).isEqualTo(body);
        verify(activityTracker).startTracking(any(Exchange.clreplaced));
        verifyActivityStepTracking(START_STEP, 1);
        verifyActivityStepTracking(SPLIT_STEP, 0);
        verifyActivityStepTracking(MOCK_STEP, 5);
        verifyActivityStepTracking(AGGREGATE_STEP, 0);
        verify(activityTracker, times(6)).track(eq("exchange"), anyString(), eq("step"), anyString(), eq("id"), anyString(), eq("duration"), anyLong(), eq("failure"), isNull());
        verify(activityTracker).finishTracking(any(Exchange.clreplaced));
    } finally {
        context.stop();
    }
}

19 Source : FilterStepHandlerTest.java
with Apache License 2.0
from syndesisio

@Test
public void testExpressionFilterStep() throws Exception {
    final CamelContext context = new DefaultCamelContext();
    try {
        final RouteBuilder routes = newIntegrationRouteBuilder(activityTracker, new Step.Builder().id(START_STEP).stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("direct").putConfiguredProperty("name", "start").build()).build()).build(), new Step.Builder().id(FILTER_STEP).stepKind(StepKind.expressionFilter).putConfiguredProperty("filter", "${body.name} == 'James'").build(), new Step.Builder().id(MOCK_STEP).stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("mock").putConfiguredProperty("name", "result").build()).build()).build());
        // Set up the camel context
        context.setUuidGenerator(KeyGenerator::createKey);
        context.addLogListener(new IntegrationLoggingListener(activityTracker));
        context.addInterceptStrategy(new ActivityTrackingInterceptStrategy(activityTracker));
        context.addRoutes(routes);
        context.start();
        // Dump routes as XML for troubleshooting
        dumpRoutes(context);
        final List<String> matchingMessages = Collections.singletonList(buildPersonJson("James"));
        final List<String> notMatchingMessages = Collections.singletonList(buildPersonJson("Jimmi"));
        final ProducerTemplate template = context.createProducerTemplate();
        final MockEndpoint result = context.getEndpoint("mock:result", MockEndpoint.clreplaced);
        List<String> allMessages = new ArrayList<>();
        allMessages.addAll(matchingMessages);
        allMessages.addAll(notMatchingMessages);
        result.expectedBodiesReceived(matchingMessages);
        for (Object body : allMessages) {
            template.sendBody("direct:start", body);
        }
        result.replacedertIsSatisfied();
        verify(activityTracker, times(allMessages.size())).startTracking(any(Exchange.clreplaced));
        verifyActivityStepTracking(MOCK_STEP, matchingMessages.size());
        verifyActivityStepTracking(FILTER_STEP, allMessages.size());
        verify(activityTracker, times(allMessages.size())).finishTracking(any(Exchange.clreplaced));
    } finally {
        context.stop();
    }
}

19 Source : FilterStepHandlerTest.java
with Apache License 2.0
from syndesisio

@Test
public void testRuleFilterStepWithJsonComplexPath() throws Exception {
    final CamelContext context = new DefaultCamelContext();
    try {
        final RouteBuilder routes = newIntegrationRouteBuilder(activityTracker, new Step.Builder().id(START_STEP).stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("direct").putConfiguredProperty("name", "start").build()).build()).build(), new Step.Builder().id(FILTER_STEP).stepKind(StepKind.ruleFilter).putConfiguredProperty("type", "rule").putConfiguredProperty("predicate", "OR").putConfiguredProperty("rules", "[{\"path\":\"user.name\",\"op\":\"==\",\"value\":\"James\"}, {\"path\":\"user.name\",\"op\":\"==\",\"value\":\"Roland\"}]").build(), new Step.Builder().id(MOCK_STEP).stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("mock").putConfiguredProperty("name", "result").build()).build()).build());
        // Set up the camel context
        context.setUuidGenerator(KeyGenerator::createKey);
        context.addLogListener(new IntegrationLoggingListener(activityTracker));
        context.addInterceptStrategy(new ActivityTrackingInterceptStrategy(activityTracker));
        context.addRoutes(routes);
        context.start();
        // Dump routes as XML for troubleshooting
        dumpRoutes(context);
        final List<String> matchingMessages = Arrays.asList(buildUserJson("James"), buildUserJson("Roland"));
        final List<String> notMatchingMessages = Collections.singletonList(buildUserJson("Jimmi"));
        final ProducerTemplate template = context.createProducerTemplate();
        final MockEndpoint result = context.getEndpoint("mock:result", MockEndpoint.clreplaced);
        List<String> allMessages = new ArrayList<>();
        allMessages.addAll(matchingMessages);
        allMessages.addAll(notMatchingMessages);
        result.expectedBodiesReceived(matchingMessages);
        for (Object body : allMessages) {
            template.sendBody("direct:start", body);
        }
        result.replacedertIsSatisfied();
        verify(activityTracker, times(allMessages.size())).startTracking(any(Exchange.clreplaced));
        verifyActivityStepTracking(MOCK_STEP, matchingMessages.size());
        verifyActivityStepTracking(FILTER_STEP, allMessages.size());
        verify(activityTracker, times(allMessages.size())).finishTracking(any(Exchange.clreplaced));
    } finally {
        context.stop();
    }
}

19 Source : FilterStepHandlerTest.java
with Apache License 2.0
from syndesisio

@Test
public void testRuleFilterStepWithJsonSimplePath() throws Exception {
    final CamelContext context = new DefaultCamelContext();
    try {
        final RouteBuilder routes = newIntegrationRouteBuilder(activityTracker, new Step.Builder().id(START_STEP).stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("direct").putConfiguredProperty("name", "start").build()).build()).build(), new Step.Builder().id(FILTER_STEP).stepKind(StepKind.ruleFilter).putConfiguredProperty("type", "rule").putConfiguredProperty("predicate", "OR").putConfiguredProperty("rules", "[{\"path\":\"name\",\"op\":\"==\",\"value\":\"James\"}, {\"path\":\"name\",\"op\":\"==\",\"value\":\"Roland\"}]").build(), new Step.Builder().id(MOCK_STEP).stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("mock").putConfiguredProperty("name", "result").build()).build()).build());
        // Set up the camel context
        context.setUuidGenerator(KeyGenerator::createKey);
        context.addLogListener(new IntegrationLoggingListener(activityTracker));
        context.addInterceptStrategy(new ActivityTrackingInterceptStrategy(activityTracker));
        context.addRoutes(routes);
        context.start();
        // Dump routes as XML for troubleshooting
        dumpRoutes(context);
        final List<String> matchingMessages = Arrays.asList(buildPersonJson("James"), buildPersonJson("Roland"));
        final List<String> notMatchingMessages = Collections.singletonList(buildPersonJson("Jimmi"));
        final ProducerTemplate template = context.createProducerTemplate();
        final MockEndpoint result = context.getEndpoint("mock:result", MockEndpoint.clreplaced);
        List<String> allMessages = new ArrayList<>();
        allMessages.addAll(matchingMessages);
        allMessages.addAll(notMatchingMessages);
        result.expectedBodiesReceived(matchingMessages);
        for (Object body : allMessages) {
            template.sendBody("direct:start", body);
        }
        result.replacedertIsSatisfied();
        verify(activityTracker, times(allMessages.size())).startTracking(any(Exchange.clreplaced));
        verifyActivityStepTracking(MOCK_STEP, matchingMessages.size());
        verifyActivityStepTracking(FILTER_STEP, allMessages.size());
        verify(activityTracker, times(allMessages.size())).finishTracking(any(Exchange.clreplaced));
    } finally {
        context.stop();
    }
}

19 Source : FilterStepHandlerTest.java
with Apache License 2.0
from syndesisio

@Test
public void testPlaintextFilterStep() throws Exception {
    final CamelContext context = new DefaultCamelContext();
    try {
        final RouteBuilder routes = newIntegrationRouteBuilder(activityTracker, new Step.Builder().id(START_STEP).stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("direct").putConfiguredProperty("name", "start").build()).build()).build(), new Step.Builder().id(FILTER_STEP).stepKind(StepKind.expressionFilter).putConfiguredProperty("filter", "${body} contains 'number'").build(), new Step.Builder().id(MOCK_STEP).stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("mock").putConfiguredProperty("name", "result").build()).build()).build());
        // Set up the camel context
        context.setUuidGenerator(KeyGenerator::createKey);
        context.addLogListener(new IntegrationLoggingListener(activityTracker));
        context.addInterceptStrategy(new ActivityTrackingInterceptStrategy(activityTracker));
        context.addRoutes(routes);
        context.start();
        // Dump routes as XML for troubleshooting
        dumpRoutes(context);
        final List<String> matchingMessages = Collections.singletonList("Body: [number:9436] Log zo syndesisu");
        final List<String> notMatchingMessages = Collections.singletonList("something else");
        final ProducerTemplate template = context.createProducerTemplate();
        final MockEndpoint result = context.getEndpoint("mock:result", MockEndpoint.clreplaced);
        List<String> allMessages = new ArrayList<>();
        allMessages.addAll(matchingMessages);
        allMessages.addAll(notMatchingMessages);
        result.expectedBodiesReceived(matchingMessages);
        for (Object body : allMessages) {
            template.sendBody("direct:start", body);
        }
        result.replacedertIsSatisfied();
        verify(activityTracker, times(allMessages.size())).startTracking(any(Exchange.clreplaced));
        verifyActivityStepTracking(MOCK_STEP, matchingMessages.size());
        verifyActivityStepTracking(FILTER_STEP, allMessages.size());
        verify(activityTracker, times(allMessages.size())).finishTracking(any(Exchange.clreplaced));
    } finally {
        context.stop();
    }
}

19 Source : FilterStepHandlerTest.java
with Apache License 2.0
from syndesisio

@Test
public void testRuleFilterStepWithPOJO() throws Exception {
    final CamelContext context = new DefaultCamelContext();
    try {
        final RouteBuilder routes = newIntegrationRouteBuilder(activityTracker, new Step.Builder().id(START_STEP).stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("direct").putConfiguredProperty("name", "start").build()).build()).build(), new Step.Builder().id(FILTER_STEP).stepKind(StepKind.ruleFilter).putConfiguredProperty("type", "rule").putConfiguredProperty("predicate", "OR").putConfiguredProperty("rules", "[{\"path\":\"name\",\"op\":\"==\",\"value\":\"James\"}, {\"path\":\"name\",\"op\":\"==\",\"value\":\"Roland\"}]").build(), new Step.Builder().id(MOCK_STEP).stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("mock").putConfiguredProperty("name", "result").build()).build()).build());
        // Set up the camel context
        context.setUuidGenerator(KeyGenerator::createKey);
        context.addLogListener(new IntegrationLoggingListener(activityTracker));
        context.addInterceptStrategy(new ActivityTrackingInterceptStrategy(activityTracker));
        context.addRoutes(routes);
        context.start();
        // Dump routes as XML for troubleshooting
        dumpRoutes(context);
        final List<User> matchingMessages = Arrays.asList(new User("James"), new User("Roland"));
        final List<User> notMatchingMessages = Collections.singletonList(new User("Jimmy"));
        final ProducerTemplate template = context.createProducerTemplate();
        final MockEndpoint result = context.getEndpoint("mock:result", MockEndpoint.clreplaced);
        List<User> allMessages = new ArrayList<>();
        allMessages.addAll(matchingMessages);
        allMessages.addAll(notMatchingMessages);
        result.expectedBodiesReceived(matchingMessages);
        for (Object body : allMessages) {
            template.sendBody("direct:start", body);
        }
        result.replacedertIsSatisfied();
        verify(activityTracker, times(allMessages.size())).startTracking(any(Exchange.clreplaced));
        verifyActivityStepTracking(MOCK_STEP, matchingMessages.size());
        verifyActivityStepTracking(FILTER_STEP, allMessages.size());
        verify(activityTracker, times(allMessages.size())).finishTracking(any(Exchange.clreplaced));
    } finally {
        context.stop();
    }
}

19 Source : FilterStepHandlerTest.java
with Apache License 2.0
from syndesisio

@Test
public void testExpressionFilterStepOnArray() throws Exception {
    final CamelContext context = new DefaultCamelContext();
    try {
        final RouteBuilder routes = newIntegrationRouteBuilder(activityTracker, new Step.Builder().id(START_STEP).stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("direct").putConfiguredProperty("name", "start").build()).build()).build(), new Step.Builder().id(FILTER_STEP).stepKind(StepKind.expressionFilter).putConfiguredProperty("filter", "${body.size()} > 0 && ${body[0].name} == 'James'").build(), new Step.Builder().id(MOCK_STEP).stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("mock").putConfiguredProperty("name", "result").build()).build()).build());
        // Set up the camel context
        context.setUuidGenerator(KeyGenerator::createKey);
        context.addLogListener(new IntegrationLoggingListener(activityTracker));
        context.addInterceptStrategy(new ActivityTrackingInterceptStrategy(activityTracker));
        context.addRoutes(routes);
        context.start();
        // Dump routes as XML for troubleshooting
        dumpRoutes(context);
        final List<String> matchingMessages = Collections.singletonList(buildPersonJsonArray("James"));
        final List<String> notMatchingMessages = Arrays.asList(buildPersonJsonArray(), buildPersonJsonArray("Jimmi"));
        final ProducerTemplate template = context.createProducerTemplate();
        final MockEndpoint result = context.getEndpoint("mock:result", MockEndpoint.clreplaced);
        List<String> allMessages = new ArrayList<>();
        allMessages.addAll(matchingMessages);
        allMessages.addAll(notMatchingMessages);
        result.expectedBodiesReceived(matchingMessages);
        for (Object body : allMessages) {
            template.sendBody("direct:start", body);
        }
        result.replacedertIsSatisfied();
        verify(activityTracker, times(allMessages.size())).startTracking(any(Exchange.clreplaced));
        verifyActivityStepTracking(MOCK_STEP, matchingMessages.size());
        verifyActivityStepTracking(FILTER_STEP, allMessages.size());
        verify(activityTracker, times(allMessages.size())).finishTracking(any(Exchange.clreplaced));
    } finally {
        context.stop();
    }
}

19 Source : FilterStepHandlerTest.java
with Apache License 2.0
from syndesisio

@Test
public void testRuleFilterStepWithJsonArrayPath() throws Exception {
    final CamelContext context = new DefaultCamelContext();
    try {
        final RouteBuilder routes = newIntegrationRouteBuilder(activityTracker, new Step.Builder().id(START_STEP).stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("direct").putConfiguredProperty("name", "start").build()).build()).build(), new Step.Builder().id(FILTER_STEP).stepKind(StepKind.ruleFilter).putConfiguredProperty("type", "rule").putConfiguredProperty("predicate", "AND").putConfiguredProperty("rules", "[{\"path\":\"size()\",\"op\":\"==\",\"value\":\"2\"}, {\"path\":\"[0].user.name\",\"op\":\"==\",\"value\":\"James\"}, {\"path\":\"[1].user.name\",\"op\":\"==\",\"value\":\"Roland\"}]").build(), new Step.Builder().id(MOCK_STEP).stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("mock").putConfiguredProperty("name", "result").build()).build()).build());
        // Set up the camel context
        context.setUuidGenerator(KeyGenerator::createKey);
        context.addLogListener(new IntegrationLoggingListener(activityTracker));
        context.addInterceptStrategy(new ActivityTrackingInterceptStrategy(activityTracker));
        context.addRoutes(routes);
        context.start();
        // Dump routes as XML for troubleshooting
        dumpRoutes(context);
        final List<String> matchingMessages = Collections.singletonList(buildUserJsonArray("James", "Roland"));
        final List<String> notMatchingMessages = Arrays.asList(buildUserJsonArray(), buildUserJsonArray("Jimmi"), buildUserJsonArray("Jimmi", "Roland"), buildUserJsonArray("James", "Roland", "Jimmi"));
        final ProducerTemplate template = context.createProducerTemplate();
        final MockEndpoint result = context.getEndpoint("mock:result", MockEndpoint.clreplaced);
        List<String> allMessages = new ArrayList<>();
        allMessages.addAll(matchingMessages);
        allMessages.addAll(notMatchingMessages);
        result.expectedBodiesReceived(matchingMessages);
        for (Object body : allMessages) {
            template.sendBody("direct:start", body);
        }
        result.replacedertIsSatisfied();
        verify(activityTracker, times(allMessages.size())).startTracking(any(Exchange.clreplaced));
        verifyActivityStepTracking(MOCK_STEP, matchingMessages.size());
        verifyActivityStepTracking(FILTER_STEP, allMessages.size());
        verify(activityTracker, times(allMessages.size())).finishTracking(any(Exchange.clreplaced));
    } finally {
        context.stop();
    }
}

19 Source : ChoiceStepHandlerTest.java
with Apache License 2.0
from syndesisio

@Test
public void testChoiceStepWithDefaultFlow() throws Exception {
    final CamelContext context = new DefaultCamelContext();
    try {
        final RouteBuilder integrationRoute = newIntegrationRouteBuilder(activityTracker, new Step.Builder().id(START_STEP).stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("direct").putConfiguredProperty("name", "flow").build()).build()).build(), new Step.Builder().id(CHOICE_STEP).stepKind(StepKind.choice).putConfiguredProperty("routingScheme", "mock").putConfiguredProperty("default", "default-flow").putConfiguredProperty("flows", "[" + "{\"condition\": \"${body} contains 'Hello'\", \"flow\": \"hello-flow\"}," + "{\"condition\": \"${body} contains 'Bye'\", \"flow\": \"bye-flow\"}" + "]").build(), new Step.Builder().id(MOCK_STEP).stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("mock").putConfiguredProperty("name", "result").build()).build()).build());
        // Set up the camel context
        context.setUuidGenerator(KeyGenerator::createKey);
        context.addLogListener(new IntegrationLoggingListener(activityTracker));
        context.addInterceptStrategy(new ActivityTrackingInterceptStrategy(activityTracker));
        context.addRoutes(integrationRoute);
        context.start();
        // Dump routes as XML for troubleshooting
        dumpRoutes(context);
        final ProducerTemplate template = context.createProducerTemplate();
        final MockEndpoint result = context.getEndpoint("mock:result", MockEndpoint.clreplaced);
        final MockEndpoint defaultResult = context.getEndpoint("mock:default-flow", MockEndpoint.clreplaced);
        final MockEndpoint helloResult = context.getEndpoint("mock:hello-flow", MockEndpoint.clreplaced);
        final MockEndpoint byeResult = context.getEndpoint("mock:bye-flow", MockEndpoint.clreplaced);
        final List<String> messages = Arrays.asList("Hello Camel!", "Bye Camel!", "And Now for Something Completely Different");
        result.expectedBodiesReceived(messages);
        defaultResult.expectedBodiesReceived("And Now for Something Completely Different");
        helloResult.expectedBodiesReceived("Hello Camel!");
        byeResult.expectedBodiesReceived("Bye Camel!");
        for (String message : messages) {
            template.sendBody("direct:flow", message);
        }
        result.replacedertIsSatisfied();
        helloResult.replacedertIsSatisfied();
        byeResult.replacedertIsSatisfied();
        verify(activityTracker, times(3)).startTracking(any(Exchange.clreplaced));
        verifyActivityStepTracking(CHOICE_STEP, 3);
        verifyActivityStepTracking(MOCK_STEP, 3);
        verify(activityTracker, times(3)).finishTracking(any(Exchange.clreplaced));
    } finally {
        context.stop();
    }
}

19 Source : ChoiceStepHandlerTest.java
with Apache License 2.0
from syndesisio

@Test
public void testChoiceStepNoConfiguredFlows() throws Exception {
    final CamelContext context = new DefaultCamelContext();
    try {
        final RouteBuilder integrationRoute = newIntegrationRouteBuilder(activityTracker, new Step.Builder().id(START_STEP).stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("direct").putConfiguredProperty("name", "flow").build()).build()).build(), new Step.Builder().id(CHOICE_STEP).stepKind(StepKind.choice).build(), new Step.Builder().id(MOCK_STEP).stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("mock").putConfiguredProperty("name", "result").build()).build()).build());
        // Set up the camel context
        context.setUuidGenerator(KeyGenerator::createKey);
        context.addLogListener(new IntegrationLoggingListener(activityTracker));
        context.addInterceptStrategy(new ActivityTrackingInterceptStrategy(activityTracker));
        context.addRoutes(integrationRoute);
        context.start();
        // Dump routes as XML for troubleshooting
        dumpRoutes(context);
        final ProducerTemplate template = context.createProducerTemplate();
        final MockEndpoint result = context.getEndpoint("mock:result", MockEndpoint.clreplaced);
        final List<String> messages = Arrays.asList("Hello Camel!", "Bye Camel!", "And Now for Something Completely Different");
        result.expectedBodiesReceived(messages);
        for (String message : messages) {
            template.sendBody("direct:flow", message);
        }
        result.replacedertIsSatisfied();
        verify(activityTracker, times(3)).startTracking(any(Exchange.clreplaced));
        verifyActivityStepTracking(CHOICE_STEP, 3);
        verifyActivityStepTracking(MOCK_STEP, 3);
        verify(activityTracker, times(3)).finishTracking(any(Exchange.clreplaced));
    } finally {
        context.stop();
    }
}

19 Source : AbstractTemplateStepHandlerTest.java
with Apache License 2.0
from syndesisio

@AfterEach
public void tearDown() throws Exception {
    context.stop();
    context = null;
}

19 Source : ComponentProxyComponentTest.java
with Apache License 2.0
from syndesisio

@AfterEach
public void stop() throws Exception {
    camel.stop();
}

19 Source : ConnectorTestSupport.java
with Apache License 2.0
from syndesisio

@SuppressWarnings("PMD.SignatureDeclareThrowsException")
@AfterEach
public final void stop() throws Exception {
    producer.stop();
    camel.stop();
}

19 Source : IntegrationTestBase.java
with Apache License 2.0
from syndesisio

@AfterEach
public void teardown() throws Exception {
    context.stop();
}

19 Source : AbstractEmailTest.java
with Apache License 2.0
from syndesisio

@AfterEach
public void tearDown() throws Exception {
    if (context != null) {
        context.stop();
        context = null;
    }
}

19 Source : JMSMessageToQueueSender.java
with GNU Lesser General Public License v3.0
from schic

/**
 * Close the camel related resources.
 *
 * @throws Exception
 */
public void close() throws Exception {
    camelContext.stop();
}

19 Source : DirectVMTest.java
with Apache License 2.0
from monodot

@After
public void tearDown() throws Exception {
    camelContext1.stop();
    camelContext2.stop();
}

19 Source : RouteTest.java
with GNU General Public License v3.0
from fgiloux

@Test
public void testRouteInternal() throws Exception {
    context.start();
    String body = FileUtils.readFileToString(new File("src/test/data/body1.txt"));
    producer.sendBody("direct:input", body);
    MockEndpoint resultEndpoint = MockEndpoint.resolve(context, "mock:amqp:{{message.output}}");
    LOG.info("endpoint id:" + resultEndpoint.getId());
    LOG.info("endpoint name:" + resultEndpoint.getName());
    String message = resultEndpoint.getExchanges().get(0).getIn().getBody(String.clreplaced);
    LOG.info("Message received: {}", message);
    resultEndpoint.expectedMessageCount(1);
    resultEndpoint.replacedertIsSatisfied();
    replacedertNotNull(message);
    replacedertEquals(body.trim(), message.trim());
    context.stop();
}

19 Source : RouteTest.java
with GNU General Public License v3.0
from fgiloux

@Test
public void testRouteRunning() throws Exception {
    context.start();
    replacedertTrue(context.getRouteStatus("main").isStarted());
    context.stop();
}

19 Source : CamelSteps.java
with Apache License 2.0
from citrusframework

private void destroyCamelContext() {
    if (globalCamelContext) {
        // do not destroy global Camel context
        return;
    }
    try {
        if (camelContext != null) {
            camelContext.stop();
            camelContext = null;
        }
    } catch (Exception e) {
        throw new IllegalStateException("Failed to stop existing Camel context", e);
    }
}

19 Source : CamelStreamer.java
with Apache License 2.0
from apache

/**
 * Starts the streamer.
 *
 * @throws IgniteException In cases when failed to start the streamer.
 */
public void start() throws IgniteException {
    // Ensure that the endpoint URI is provided.
    A.notNullOrEmpty(endpointUri, "endpoint URI must be provided");
    // Check that one and only one tuple extractor is provided.
    A.ensure(!(getSingleTupleExtractor() == null && getMultipleTupleExtractor() == null), "tuple extractor missing");
    // If a custom CamelContext is not provided, initialize one.
    if (camelCtx == null)
        camelCtx = new DefaultCamelContext();
    // If the camel context is not started then simply start it up
    if (!camelCtx.isStarted())
        camelCtx.start();
    if (!camelCtx.isRunAllowed())
        throw new IgniteException("Failed to start Camel streamer (CamelContext not in a runnable state).");
    log = getIgnite().log();
    // Instantiate the Camel endpoint.
    try {
        endpoint = CamelContextHelper.getMandatoryEndpoint(camelCtx, endpointUri);
    } catch (Exception e) {
        U.error(log, e);
        camelCtx.stop();
        throw new IgniteException("Failed to start Camel streamer [errMsg=" + e.getMessage() + ']');
    }
    // Create the Camel consumer.
    try {
        consumer = endpoint.createConsumer(this);
    } catch (Exception e) {
        U.error(log, e);
        camelCtx.stop();
        throw new IgniteException("Failed to start Camel streamer [errMsg=" + e.getMessage() + ']');
    }
    // Start the Camel services.
    try {
        ServiceHelper.startService(camelCtx, endpoint, consumer);
    } catch (Exception e) {
        U.error(log, e);
        camelCtx.stop();
        try {
            ServiceHelper.stopAndShutdownServices(camelCtx, endpoint, consumer);
            consumer = null;
            endpoint = null;
        } catch (Exception e1) {
            throw new IgniteException("Failed to start Camel streamer; failed to stop the context, endpoint or " + "consumer during rollback of failed initialization [errMsg=" + e.getMessage() + ", stopErrMsg=" + e1.getMessage() + ']');
        }
        throw new IgniteException("Failed to start Camel streamer [errMsg=" + e.getMessage() + ']');
    }
    U.log(log, "Started Camel streamer consuming from endpoint URI: " + endpointUri);
}

19 Source : CustomShutdownStrategyTest.java
with Apache License 2.0
from apache

@Test
public void testCustomShutdown() throws Exception {
    ShutdownStrategy stat = camelContext.getShutdownStrategy();
    replacedertEquals(60000, stat.getTimeout());
    replacedertTrue(stat instanceof MyShutdown);
    camelContext.stop();
    replacedertTrue(((MyShutdown) stat).isInvoked());
}

19 Source : CamelSpringBootTemplateShutdownTest.java
with Apache License 2.0
from apache

@Test
public void shouldStopTemplatesWithCamelShutdown() throws Exception {
    replacedertTrue(((ServiceSupport) consumerTemplate).isStarted());
    replacedertTrue(((ServiceSupport) producerTemplate).isStarted());
    replacedertTrue(((ServiceSupport) fluentProducerTemplate).isStarted());
    camelContext.stop();
    replacedertTrue(camelContext.isStopped());
    replacedertTrue(((ServiceSupport) consumerTemplate).isStopped());
    replacedertTrue(((ServiceSupport) producerTemplate).isStopped());
    replacedertTrue(((ServiceSupport) fluentProducerTemplate).isStopped());
}

19 Source : CamelContextRuntime.java
with Apache License 2.0
from apache

@Override
public void stop() {
    camelContext.stop();
}

19 Source : QuteTestBase.java
with Apache License 2.0
from apache

@AfterEach
void afterEach() {
    if (template != null) {
        template.stop();
    }
    if (context != null) {
        context.stop();
    }
}

19 Source : AbstractLocalCamelControllerTest.java
with Apache License 2.0
from apache

@After
public void stopContext() throws Exception {
    context.stop();
}

19 Source : AbstractLocalCamelController.java
with Apache License 2.0
from apache

@Override
public void stopContext(String camelContextName) throws Exception {
    CamelContext context = getLocalCamelContext(camelContextName);
    if (context != null) {
        context.stop();
    }
}

19 Source : KuraRouter.java
with Apache License 2.0
from apache

@Override
public void stop(BundleContext bundleContext) throws Exception {
    log.debug("Stopping bundle {}.", bundleContext.getBundle().getBundleId());
    camelContext.stop();
    log.debug("Bundle {} stopped.", bundleContext.getBundle().getBundleId());
}

19 Source : SyslogService.java
with Apache License 2.0
from apache

@Override
public void afterAll(ExtensionContext context) {
    camelContext.stop();
    TestUtils.waitFor(camelContext::isStopped);
}

19 Source : AbstractContextAwareRepoEvent.java
with GNU Lesser General Public License v3.0
from Alfresco

@AfterClreplaced
public static void afterAll() throws Exception {
    CAMEL_CONTEXT.stop();
}

18 Source : SimpleEndpointStepHandlerTest.java
with Apache License 2.0
from syndesisio

@Test
public void testSimpleEndpointStepWithSplitAggregate() throws Exception {
    final CamelContext context = getDefaultCamelContextWithMyBeanInRegistry();
    try {
        final RouteBuilder routes = newIntegrationRouteBuilder(activityTracker, new Step.Builder().stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("direct").putConfiguredProperty("name", "start").build()).build()).build(), new Step.Builder().stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("bean").putConfiguredProperty("beanName", "myBean").putConfiguredProperty("method", "myProcessor").build()).build()).build(), new Step.Builder().stepKind(StepKind.split).putConfiguredProperty("language", "tokenize").putConfiguredProperty("expression", "|").build(), new Step.Builder().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());
        // Set up the camel context
        context.setUuidGenerator(KeyGenerator::createKey);
        context.addLogListener(new IntegrationLoggingListener(activityTracker));
        context.addInterceptStrategy(new ActivityTrackingInterceptStrategy(activityTracker));
        context.addRoutes(routes);
        context.start();
        // Dump routes as XML for troubleshooting
        dumpRoutes(context);
        final ProducerTemplate template = context.createProducerTemplate();
        final MockEndpoint result = context.getEndpoint("mock:result", MockEndpoint.clreplaced);
        final String body = "a|b|c";
        final String[] expected = body.toUpperCase().split("|");
        result.expectedMessageCount(3);
        result.expectedBodiesReceived((Object[]) expected);
        template.sendBody("direct:start", body);
        result.replacedertIsSatisfied();
        verify(activityTracker).startTracking(any(Exchange.clreplaced));
        verify(activityTracker, times(7)).track(eq("exchange"), anyString(), eq("step"), anyString(), eq("id"), anyString(), eq("duration"), anyLong(), eq("failure"), isNull());
        verify(activityTracker).finishTracking(any(Exchange.clreplaced));
    } finally {
        context.stop();
    }
}

18 Source : SimpleEndpointStepHandlerTest.java
with Apache License 2.0
from syndesisio

@Test
public void testSimpleEndpointStep() throws Exception {
    final CamelContext context = getDefaultCamelContextWithMyBeanInRegistry();
    try {
        final RouteBuilder routes = newIntegrationRouteBuilder(activityTracker, new Step.Builder().stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("direct").putConfiguredProperty("name", "start").build()).build()).build(), new Step.Builder().stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("bean").putConfiguredProperty("beanName", "myBean").putConfiguredProperty("method", "myProcessor").build()).build()).build(), new Step.Builder().stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("mock").putConfiguredProperty("name", "result").build()).build()).build());
        // Set up the camel context
        context.setUuidGenerator(KeyGenerator::createKey);
        context.addLogListener(new IntegrationLoggingListener(activityTracker));
        context.addInterceptStrategy(new ActivityTrackingInterceptStrategy(activityTracker));
        context.addRoutes(routes);
        context.start();
        // Dump routes as XML for troubleshooting
        dumpRoutes(context);
        final ProducerTemplate template = context.createProducerTemplate();
        final MockEndpoint result = context.getEndpoint("mock:result", MockEndpoint.clreplaced);
        final String body = "testSimpleEndpointStep";
        result.expectedBodiesReceived(body.toUpperCase());
        template.sendBody("direct:start", body);
        result.replacedertIsSatisfied();
        verify(activityTracker).startTracking(any(Exchange.clreplaced));
        verify(activityTracker, times(3)).track(eq("exchange"), anyString(), eq("step"), anyString(), eq("id"), anyString(), eq("duration"), anyLong(), eq("failure"), isNull());
        verify(activityTracker).finishTracking(any(Exchange.clreplaced));
    } finally {
        context.stop();
    }
}

18 Source : LogsAndErrorsTest.java
with Apache License 2.0
from syndesisio

@Test
public void testRoute() throws Exception {
    final CamelContext context = new DefaultCamelContext();
    try {
        final RouteBuilder routes = newIntegrationRouteBuilder(new io.syndesis.common.model.integration.Step.Builder().id("s1").stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("direct").putConfiguredProperty("name", "expression").build()).build()).build(), new io.syndesis.common.model.integration.Step.Builder().id("s2").stepKind(StepKind.extension).action(new StepAction.Builder().descriptor(new StepDescriptor.Builder().kind(StepAction.Kind.STEP).entrypoint(LogExtension.clreplaced.getName()).build()).build()).build(), new io.syndesis.common.model.integration.Step.Builder().id("s3").stepKind(StepKind.extension).action(new StepAction.Builder().descriptor(new StepDescriptor.Builder().kind(StepAction.Kind.STEP).entrypoint(ErrorExtension.clreplaced.getName()).build()).build()).build(), new io.syndesis.common.model.integration.Step.Builder().id("s4").stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("mock").putConfiguredProperty("name", "expression").build()).build()).build());
        // Set up the camel context
        context.addRoutes(routes);
        context.start();
        // Dump routes as XML for troubleshooting
        dumpRoutes(context);
        final ProducerTemplate template = context.createProducerTemplate();
        final MockEndpoint result = context.getEndpoint("mock:expression", MockEndpoint.clreplaced);
        result.expectedBodiesReceived("1", "3");
        Exchange e1 = template.request("direct:expression", e -> e.getIn().setBody("1"));
        replacedertThat(e1.isFailed()).isFalse();
        Exchange e2 = template.request("direct:expression", e -> e.getIn().setBody("2"));
        replacedertThat(e2.isFailed()).isTrue();
        Exchange e3 = template.request("direct:expression", e -> e.getIn().setBody("3"));
        replacedertThat(e3.isFailed()).isFalse();
        result.replacedertIsSatisfied();
    } finally {
        context.stop();
    }
}

18 Source : HeadersStepHandlerTest.java
with Apache License 2.0
from syndesisio

@Test
public void testRemoveHeadersStepHandler() throws Exception {
    final CamelContext context = new DefaultCamelContext();
    try {
        final RouteBuilder routes = newIntegrationRouteBuilder(new Step.Builder().stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().id(KeyGenerator.createKey()).descriptor(new ConnectorDescriptor.Builder().connectorId("new").componentScheme("direct").putConfiguredProperty("name", "start").build()).build()).build(), new Step.Builder().stepKind(StepKind.headers).putConfiguredProperty("action", "set").putConfiguredProperty("MyHeader1", "1").putConfiguredProperty("MyHeader2", "2").build(), new Step.Builder().stepKind(StepKind.headers).putConfiguredProperty("action", "remove").putConfiguredProperty("MyHeader1", "").build(), new Step.Builder().stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("mock").putConfiguredProperty("name", "result").build()).build()).build());
        // Set up the camel context
        context.addRoutes(routes);
        context.start();
        // Dump routes as XML for troubleshooting
        dumpRoutes(context);
        final ProducerTemplate template = context.createProducerTemplate();
        final MockEndpoint result = context.getEndpoint("mock:result", MockEndpoint.clreplaced);
        result.expectedMessageCount(1);
        result.expectedMessagesMatches(e -> !e.getIn().getHeaders().containsKey("Myheader1"));
        result.expectedMessagesMatches(e -> e.getIn().getHeaders().containsKey("Myheader2"));
        template.sendBody("direct:start", "");
        result.replacedertIsSatisfied();
    } finally {
        context.stop();
    }
}

18 Source : HeadersStepHandlerTest.java
with Apache License 2.0
from syndesisio

@Test
public void testSetHeadersStepHandler() throws Exception {
    final CamelContext context = new DefaultCamelContext();
    try {
        final RouteBuilder routes = newIntegrationRouteBuilder(new Step.Builder().stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().id(KeyGenerator.createKey()).descriptor(new ConnectorDescriptor.Builder().connectorId("new").componentScheme("direct").putConfiguredProperty("name", "start").build()).build()).build(), new Step.Builder().stepKind(StepKind.headers).putConfiguredProperty("action", "set").putConfiguredProperty("MyHeader1", "1").putConfiguredProperty("MyHeader2", "2").build(), new Step.Builder().stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("mock").putConfiguredProperty("name", "result").build()).build()).build());
        // Set up the camel context
        context.addRoutes(routes);
        context.start();
        // Dump routes as XML for troubleshooting
        dumpRoutes(context);
        final ProducerTemplate template = context.createProducerTemplate();
        final MockEndpoint result = context.getEndpoint("mock:result", MockEndpoint.clreplaced);
        result.expectedMessageCount(1);
        result.expectedHeaderReceived("MyHeader1", "1");
        result.expectedHeaderReceived("MyHeader2", "2");
        template.sendBody("direct:start", "");
        result.replacedertIsSatisfied();
    } finally {
        context.stop();
    }
}

18 Source : ConnectorStepHandlerTest.java
with Apache License 2.0
from syndesisio

@Test
public void testConnectorStepHandler() throws Exception {
    final CamelContext context = new DefaultCamelContext();
    PropertiesComponent propertiesComponent = new PropertiesComponent();
    Properties extra = new Properties();
    extra.setProperty("flow-0.twitter-timeline-0.accessToken", "at");
    extra.setProperty("flow-0.twitter-timeline-0.accessTokenSecret", "ats");
    extra.setProperty("flow-0.twitter-timeline-0.consumerKey", "ck");
    extra.setProperty("flow-0.twitter-timeline-0.consumerSecret", "cs");
    propertiesComponent.setOverrideProperties(extra);
    context.addComponent("properties", propertiesComponent);
    try {
        final RouteBuilder routes = newIntegrationRouteBuilder(new Step.Builder().stepKind(StepKind.endpoint).action(TWITTER_MENTION_ACTION).connection(new Connection.Builder().connector(TWITTER_CONNECTOR).putConfiguredProperty("accessToken", "at").putConfiguredProperty("accessTokenSecret", "ats").putConfiguredProperty("consumerKey", "ck").putConfiguredProperty("consumerSecret", "cs").build()).putConfiguredProperty("delay", "1234").build(), new Step.Builder().stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("mock").putConfiguredProperty("name", "result").build()).build()).build());
        // Set up the camel context
        context.addRoutes(routes);
        context.setAutoStartup(false);
        context.start();
        replacedertThat(context.getComponentNames()).contains("twitter-timeline");
        replacedertThat(context.getComponentNames()).doesNotContain("twitter-timeline-twitter-timeline-0-1");
        for (Endpoint endpoint : context.getEndpoints()) {
            if (endpoint instanceof TwitterTimelineEndpoint) {
                replacedertThat(endpoint.getEndpointUri()).isEqualTo("twitter-timeline://MENTIONS?accessToken=at&accessTokenSecret=ats&consumerKey=ck&consumerSecret=cs&delay=1234");
            }
            if (endpoint instanceof ComponentProxyEndpoint) {
                replacedertThat(endpoint.getEndpointUri()).isEqualTo("twitter-timeline-0-0");
            }
        }
        // Dump routes as XML for troubleshooting
        dumpRoutes(context);
    } finally {
        context.stop();
    }
}

18 Source : ComponentProxyWithCustomEndpointTest.java
with Apache License 2.0
from syndesisio

// *************************
// Tests
// *************************
@Test
public void testCustomizeDelegatedEndpoint() throws Exception {
    final boolean binary = true;
    final String username = "my-user";
    Map<String, Object> properties = new HashMap<>();
    properties.put("transfer-mode-binary", Boolean.toString(binary));
    properties.put("username", username);
    properties.put("host", "localhost");
    ComponentProxyComponent component = new ComponentProxyComponent("my-ftp-proxy", "ftp") {

        @Override
        protected void configureDelegateEndpoint(ComponentDefinition definition, Endpoint endpoint, Map<String, Object> options) {
            replacedertThat(endpoint).isNotNull();
            replacedertThat(endpoint).isInstanceOf(FtpEndpoint.clreplaced);
            FtpEndpoint<?> ftpEndpoint = FtpEndpoint.clreplaced.cast(endpoint);
            boolean binary = Objects.equals("true", options.get("transfer-mode-binary"));
            ftpEndpoint.getConfiguration().setBinary(binary);
            replacedertThat(ftpEndpoint.getConfiguration().isBinary()).isEqualTo(binary);
        }
    };
    component.setOptions(properties);
    SimpleRegistry registry = new SimpleRegistry();
    registry.put(component.getComponentId() + "-component", component);
    final CamelContext context = new DefaultCamelContext(registry);
    try {
        context.setAutoStartup(false);
        context.addRoutes(new RouteBuilder() {

            @Override
            public void configure() throws Exception {
                from("direct:start").to("my-ftp-proxy").to("mock:result");
            }
        });
        context.start();
        Collection<String> names = context.getComponentNames();
        replacedertThat(names).contains("my-ftp-proxy");
        replacedertThat(names).contains("ftp-my-ftp-proxy");
        replacedertThat(context.getEndpointMap().keySet()).contains("ftp-my-ftp-proxy://localhost?username=my-user");
        FtpEndpoint<?> ftpEndpoint = context.getEndpoint("ftp-my-ftp-proxy://localhost?username=my-user", FtpEndpoint.clreplaced);
        replacedertThat(ftpEndpoint).isNotNull();
        replacedertThat(ftpEndpoint.getConfiguration()).hasFieldOrPropertyWithValue("binary", binary);
        replacedertThat(ftpEndpoint.getConfiguration()).hasFieldOrPropertyWithValue("username", username);
    } finally {
        context.stop();
    }
}

See More Examples