Java Code Examples for org.apache.camel.spring.SpringCamelContext#getEndpoint()
The following examples show how to use
org.apache.camel.spring.SpringCamelContext#getEndpoint() .
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: OutMessageCaptureProcessorTest.java From syndesis with Apache License 2.0 | 4 votes |
@Test public void testCapture() throws Exception { final SpringCamelContext 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.class.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.class.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.class); result.expectedBodiesReceived("-862545276"); template.sendBody("direct:expression", "World"); result.assertIsSatisfied(); Exchange exchange1 = result.getExchanges().get(0); Map<String, Message> messages = OutMessageCaptureProcessor.getCapturedMessageMap(exchange1); assertThat(messages).hasSize(4); assertThat(messages.get("s1").getBody()).isEqualTo("World"); assertThat(messages.get("s2").getBody()).isEqualTo("Hello World"); assertThat(messages.get("s3").getBody()).isEqualTo(-862545276); assertThat(messages.get("s4").getBody()).isEqualTo(-862545276); } finally { context.stop(); } }
Example 2
Source File: OutMessageCaptureProcessorTest.java From syndesis with Apache License 2.0 | 4 votes |
@Test public void testCaptureWithSplitAggregate() throws Exception { final SpringCamelContext 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.class.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.class.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.class); result.expectedBodiesReceived("-862545276"); template.sendBody("direct:expression", "World"); result.assertIsSatisfied(); Exchange exchange1 = result.getExchanges().get(0); Map<String, Message> messages = OutMessageCaptureProcessor.getCapturedMessageMap(exchange1); assertThat(messages).hasSize(5); assertThat(messages.get("s-split").getBody()).isEqualTo("World"); assertThat(messages.get("s2").getBody()).isEqualTo("Hello World"); assertThat(messages.get("s3").getBody()).isEqualTo(-862545276); assertThat(messages.get("s4").getBody()).isEqualTo(-862545276); assertThat(messages.get("s-aggregate").getBody()).isEqualTo(Collections.singletonList(-862545276)); } finally { context.stop(); } }
Example 3
Source File: OutMessageCaptureProcessorTest.java From syndesis with Apache License 2.0 | 4 votes |
@Test public void testCaptureWithSplitAggregateAndSchedule() throws Exception { final SpringCamelContext 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.class.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.class); result.expectedBodiesReceived("Hello Hiram", "Hello World"); result.assertIsSatisfied(); Exchange exchange1 = result.getExchanges().get(0); Map<String, Message> messages = OutMessageCaptureProcessor.getCapturedMessageMap(exchange1); assertThat(messages.get("s-split").getBody()).isEqualTo("Hiram"); assertThat(messages.get("s2").getBody()).isEqualTo("Hello Hiram"); Exchange exchange2 = result.getExchanges().get(1); Map<String, Message> messages2 = OutMessageCaptureProcessor.getCapturedMessageMap(exchange2); assertThat(messages2.get("s-split").getBody()).isEqualTo("World"); assertThat(messages2.get("s2").getBody()).isEqualTo("Hello World"); } finally { context.stop(); } }