use of org.apache.camel.spring.SpringCamelContext in project syndesis by syndesisio.
the class StepWithIdTest method testWithIdStep.
@Test
public void testWithIdStep() throws Exception {
final CamelContext context = new SpringCamelContext(applicationContext);
try {
final RouteBuilder routes = newIntegrationRouteBuilder(new Step.Builder().id("endpoint-1").stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("direct").putConfiguredProperty("name", "expression").build()).build()).build(), new Step.Builder().id("split-1").stepKind(StepKind.split).build(), new Step.Builder().id("endpoint-2").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);
RouteDefinition routeDefinition = context.getRouteDefinition("test-integration");
assertThat(routeDefinition).isNotNull();
assertThat(routeDefinition).hasFieldOrPropertyWithValue("id", "test-integration");
assertThat(routeDefinition.getInputs()).hasSize(1);
assertThat(routeDefinition.getInputs().get(0)).hasFieldOrPropertyWithValue("id", "endpoint-1");
assertThat(routeDefinition.getOutputs()).hasSize(2);
assertThat(routeDefinition.getOutputs().get(1)).hasFieldOrPropertyWithValue("id", "split-1");
assertThat(routeDefinition.getOutputs().get(1).getOutputs()).hasSize(3);
assertThat(routeDefinition.getOutputs().get(1).getOutputs().get(1)).hasFieldOrPropertyWithValue("id", "endpoint-2");
} finally {
context.stop();
}
}
use of org.apache.camel.spring.SpringCamelContext in project syndesis by syndesisio.
the class IntegrationSchedulerTest method integrationSchedulerTest.
@Test
public void integrationSchedulerTest() throws Exception {
final CamelContext context = new SpringCamelContext(applicationContext);
try {
final RouteBuilder routes = new IntegrationRouteBuilder("", Collections.emptyList()) {
@Override
protected Integration loadIntegration() throws IOException {
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());
return new Integration.Builder().createFrom(integration).scheduler(new Scheduler.Builder().type(Scheduler.Type.timer).expression("1s").build()).build();
}
};
// Set up the camel context
context.addRoutes(routes);
context.start();
dumpRoutes(context);
RouteDefinition routeDefinition = context.getRouteDefinition("test-integration");
assertThat(routeDefinition).isNotNull();
assertThat(routeDefinition).hasFieldOrPropertyWithValue("id", "test-integration");
assertThat(routeDefinition.getInputs()).hasSize(1);
assertThat(routeDefinition.getInputs().get(0).getEndpointUri()).isEqualTo("timer:integration?period=1s");
assertThat(routeDefinition.getOutputs()).hasSize(4);
assertThat(routeDefinition.getOutputs().get(0)).hasFieldOrPropertyWithValue("endpointUri", "log:timer");
assertThat(routeDefinition.getOutputs().get(1)).isInstanceOf(ProcessDefinition.class);
assertThat(routeDefinition.getOutputs().get(2)).hasFieldOrPropertyWithValue("endpointUri", "mock:timer");
assertThat(routeDefinition.getOutputs().get(3)).isInstanceOf(ProcessDefinition.class);
assertThat(routeDefinition.getInputs().get(0)).hasFieldOrPropertyWithValue("id", "integration-scheduler");
assertThat(routeDefinition.getOutputs().get(0)).hasFieldOrPropertyWithValue("id", "step-1");
assertThat(routeDefinition.getOutputs().get(1)).hasFieldOrPropertyWithValue("id", "step-1-capture");
assertThat(routeDefinition.getOutputs().get(2)).hasFieldOrPropertyWithValue("id", "step-2");
assertThat(routeDefinition.getOutputs().get(3)).hasFieldOrPropertyWithValue("id", "step-2-capture");
} finally {
context.stop();
}
}
use of org.apache.camel.spring.SpringCamelContext in project citrus-samples by christophd.
the class EndpointConfig method camelContext.
@Bean
public CamelContext camelContext() throws Exception {
SpringCamelContext context = new SpringCamelContext();
context.addRouteDefinition(new RouteDefinition().from("jms:queue:JMS.Queue.News").to("log:com.consol.citrus.camel?level=INFO").to("spring-ws:http://localhost:18009?soapAction=newsFeed"));
return context;
}
use of org.apache.camel.spring.SpringCamelContext in project wildfly-camel by wildfly-extras.
the class SpringExplicitConfigurationTest method testSpringJavaConfig.
@Test
public void testSpringJavaConfig() throws Exception {
AnnotationConfigApplicationContext appctx = new AnnotationConfigApplicationContext(MyConfiguration.class);
CamelContext camelctx = new SpringCamelContext(appctx);
camelctx.addRoutes(appctx.getBean(RouteBuilder.class));
camelctx.start();
try {
ProducerTemplate producer = camelctx.createProducerTemplate();
String result = producer.requestBody("direct:start", "Kermit", String.class);
Assert.assertEquals("Hello Kermit", result);
} finally {
camelctx.close();
}
}
Aggregations